Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find client's mac address with PHP

I want to find the MAC address of my client, for my website based on PHP. Currently I am using the code provided to fetch the mac address on a linux OS. I want to know will this method work on any linux distro , and if not, then how can I fetch the MAC address for any OS. Also is there anything that works on any OS, wether linux or windows or mac.

$mac_linux = shell_exec('cat /sys/class/net/*/address');
$mac = trim($mac_linux); 
$data   = preg_split('/\s+/', $mac);
$mac1 = $data[0];
$mac2 = $data[1];
$mac3 = $data[2];
like image 844
Abhishek Rautela Avatar asked Mar 10 '26 11:03

Abhishek Rautela


1 Answers

You can't access your client's MAC address. The thing you are trying to do with the code above will get you your own machine's MAC address. You can refer to this question and find the detailed answer.

like image 81
TamirNahum Avatar answered Mar 13 '26 01:03

TamirNahum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!