PHP (iP Address & Mac Address)


I am currently making php code for user who wanted to know their IP and Mac address with just a click away,

how do I get local IP address and Mac Address to be shown in PHP,

Thank you,


Hi tommythetimmy. I usually find that such questions have been answered before, such as here:
and here

I saw that too, actually I can find the IP address and Mac Address in command prompt,

But if it can be shown on the browser with lesser step to find would be great,

Any recommendation,

Thank you,

PS: its not from other subnet or networked, it is opening php file from my own computer

Just out of interest, what’s the goal with this? Even if that’s possible with PHP, you’d need some kind of dev environment set up on your computer, which sounds like more work that just viewing details about your computer the standard way. (E.g. On a Mac it’s just  > About this Mac.)

My Lab has 20 computer connected with same subnet, I would like to get the mac address,

It said that I could get mac address of computer connected within the same subnet,

But so far I have not found a single working code yet,

Why I want to do this? because computer can change IP but mac address will stay the same,

I would like to manage those mac address,

if it is not possible, I am thinking about just showing local mac address of each computer, WHY?

Because with that simple step, I could solve a lot of problem, like whether the computer connected to our server, the computer can compile php file and many more,

I hope it could clarify the purpose of me making this,

The problem has been there since 2004 but till date it is yet to be solved,

Wish we could solve this,

Thank you,

Try looking into how freeradius gets integrated apps like CoovaChilli.
We do a lot with wifi captive portals and CoovaChilli sends in the clients MAC address in the querystring.

This will have to be accomplished on your network controller but when it works you can log all kinds of valuable network data on individual MAC addresses.

If your network controller can integrate with a radius server, you are home free. coogle for it’s make + radius + captive portal,
This will tell you how to configure your controller. (We use MikroTik)

Here are some links that may help.

(mac= Calling-Station-id - the MAC address of the subscriber),d.b2I&cad=rja

Thanks Sir for the guide,

Working on it now,


Radius stuff is too complicated, we can propose that but the production wanted simpler method,

I was thinking one day, if there is a code to show mac address and post it to our server that would be good,

What do you think?

Thank you,

I was looking at this design,

We put a code to check mac address of a computer, and when the client submit a post form, the mac address also being sent,

What do you think?

1st action: the code get IP address & mac address of client,
2nd action: the system read the IP & mac address and put into a form in background
3rd action: the server receive the IP address and Mac Address and validate it with currently connected IP,

Thank you,

No :slight_smile:

There is nothing that stops me from intercepting step 2 and changing the values that are sent over with step 3.

Though please understand that basing any security on the mac address is even less secure than the IP address. The reason for this is that it is easier to change your mac address, than to change your IP address. I.e. faking a mac address is very simple, while faking a IP address is quite difficult (with the exception of a local network and if the hardware that normally run that IP is shut down).

Most network cards has engineer tools that allow you to change it, and to make it even simpler there is also a lot of software out there that allow you to “override” your real mac address on a OS level.

I would recommend you to look into if there is any other ways you can archive the result your looking for.

Thank you, TheRedDevil for pointing out the issue of mac address changes, All the computer is managed by our team, so the chance of changes in mac address does not affect our network design,