1

Basically I want to be able to display the Mac addresses of the Eth0 and Wlan0 interfaces via a PHP page.

I was sure there would be an easy way to do this but I haven't found one yet.

The Page is being hosted on raspbian (jesse) system, with Nginx and php.

Rahim Khoja
  • 695
  • 13
  • 26

1 Answers1

1
exec("ifconfig -a", $config);
$temp_array = array();
foreach ( $config as $value ){
    if(preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i",$value, $temp_array )){
        $mac_addr = $temp_array[0]; 
        break;
    }
} 
unset($temp_array);
echo $mac_addr;
steve
  • 1,358
  • 5
  • 16
  • 26