For a personal project I’m working on, I need to monitor all the devices currently on my home network. Getting PHP to poll the network for devices is hard… I believe there is a way to poll devices in perl, but I was looking for something easier. The quickest solution I was able to come up with is to screen scrap my router’s “Device List” page. My router is a Linksys E2000 (For all the nerds out there, it’s a Broadcom BCM4716 chip rev 1 pkg 9, overclocked to a blazin’ 356MHz). It’s currently running Tomato Version 1.28.
Grepping the page turned out to be pretty easy. All it took was a file_get_contents() with a basic auth header. The “dhcpd_lease” contains everything I need (i.e., MAC address, IP, and the device name) and is stored as a JavaScript object on the page. All I needed to do was clean it up and explode it into an array. Piece of cake.
The results are var_dump()’ed to the page (again, this is just adown and dirty hack). They look something like this: