How to find devices on your local network

May 30, '06 07:30:00AM

Contributed by: robg

Experienced Unix users, look away now, please -- the following is a very simple hint. Over the weekend, I "lost track" of a device on my network. We've got a wireless video camera, but I've had it unplugged for a very long time. I plugged it in this weekend, but couldn't even begin to remember what IP address I'd assigned to it. So I wanted a simple way to just poll my network and see what was out there, which would let me find the camera by process of elimination.

Some versions of the ping command support the -b broadcast flag, which will send a ping request to any device capable of receiving such requests on your network, and report back with the addresses of those that replied. Unfortunately, Mac OS X's version of ping doesn't seem support the flag -- it doesn't work if you try to use it, and it's not listed in the man page. Just as I was about to go find and build a new ping, a much more Unix savvy friend of mine offered this alternative:

ping 192.168.1.255
Run that, and you'll see a response from anything on your network (192.168.1.xxx, in my case), like this:
robg $> ping 192.168.1.255
PING 192.168.1.255 (192.168.1.255): 56 data bytes
64 bytes from 192.168.1.53: icmp_seq=0 ttl=64 time=0.175 ms
64 bytes from 192.168.1.2: icmp_seq=0 ttl=150 time=0.660 ms (DUP!)
64 bytes from 192.168.1.70: icmp_seq=0 ttl=64 time=1.027 ms (DUP!)
64 bytes from 192.168.1.116: icmp_seq=0 ttl=60 time=3.966 ms (DUP!)
64 bytes from 192.168.1.92: icmp_seq=0 ttl=64 time=1.728 ms (DUP!)
...
...
So our ping does support broadcast pings, by placing the 255 value in the field you wish to vary -- the last field of the IP address for a typical home network. Of course, once I had the list, I then had to figure out what was what, but that was relatively trivial.

See, I told you it was a simple hint. And yet, in all my years of OS X usage, I had no idea you could do such a thing. So perhaps this will help some other relatively inexperienced Unix user out there...

Comments (21)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060530064822804