How can I get the MAC and the IP address of a connected client in PHP?

前端 未结 16 2357
长发绾君心
长发绾君心 2020-11-22 02:29

I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?

16条回答
  •  梦如初夏
    2020-11-22 03:07

    You can do this easily using openWRT. If yo use a captive portal you can mix php and openWRT and make a relation between the IP and the mac.

    You can write a simple PHP code using:

     $localIP = getHostByName(getHostName()); 
    

    Later, using openWRT you can go to /tmp/dhcp.leases, you will get something with the form:

     e4:a7:a0:29:xx:xx 10.239.3.XXX DESKTOP-XXX 
    

    There, you have the mac, the IP address and the hostname.

提交回复
热议问题