Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to find devices on your local network UNIX
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...
    •    
  • Currently 2.88 / 5
  You rated: 1 / 5 (8 votes cast)
 
[130,290 views]  

How to find devices on your local network | 21 comments | Create New Account
Click here to return to the 'How to find devices on your local network' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to send a find devices on your local network
Authored by: jcbeckman on May 30, '06 08:29:40AM

The output of the ifconfig command in the terminal will tell you the
broadcast address to use for each interface. For example:

en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST>
mtu 1500
inet 10.50.6.8 netmask 0xffffff00 broadcast 10.50.6.255



[ Reply to This | # ]
How to send a find devices on your local network
Authored by: jamiefiedler on May 30, '06 08:32:36AM

once you've executed the xxx.xxx.xxx.255 broadcast ping, type "arp -a" and it will
show you a list of known IPs and their associated ethernet mac address. match
the ethernet mac address to the label that is most likely attached to the back/
side/bottom of your device, and you're done.



[ Reply to This | # ]
How to find devices on your local network
Authored by: foilpan on May 30, '06 08:59:29AM

or if you have a recent build of nmap installed, you can use the following to scan the whole subnet:

nmap -sP 192.168.1.1/24

substitute your IP range and subnet, of course.



[ Reply to This | # ]
How to find devices on your local network
Authored by: lukasha on May 30, '06 09:08:44AM

2 questions. What if the device doesn't respond to ping. I can't tell you how
many times I've seen that. Also, what if you have a device that was configured
with a static IP on another network and then brought to yours and you don't
know what it's set to. If you know the MAC address, can you find it on the
network and configure it that way?

Jeff



[ Reply to This | # ]
How to find devices on your local network
Authored by: skully dazed on May 30, '06 09:30:46AM

If it doesn't respond to ping, you can still find the address like so:

x=0
while [ $x < 255 ]; do
    ping -c 1 192.168.1.$x &
    x=$(expr $x + 1)
done
# Wait a few seconds for the pings above to finish
arp -a

This will ping every address in your subnet (Adjust the local address as needed, and if your block is larger than a /24 you'll have to modify the script accordingly) and then show every machine that responded to the arp request. Even if it doesn't respond to a ping, it'll respond to the arp request. The ping is just used to generate the arp request.

I've used this to locate APs that blocked pings by default.



[ Reply to This | # ]
How to find devices on your local network
Authored by: lukasha on May 30, '06 06:11:01PM

Pardon my stupidity, but when I type that straight into terminal, I get "-bash:
255: No such file or directory" and when I put it in ultraping.sh and do a "sh
ultraping.sh" I get "ultraping.sh: line 2: 255: No such file or directory". How do I
use your instructions and can I make it into a command line command script?
Thanks in advance.

Jeff



[ Reply to This | # ]
How to find devices on your local network
Authored by: skully dazed on Jun 09, '06 05:28:23PM

Whoops. I make a mistake in my original post.

x=0
while [ $x -lt 255 ]; do
ping -c 1 192.168.1.$x &
x=$(expr $x + 1)
done
# Wait a few seconds for the pings above to finish
arp -a

Hopefully that works for people where my original didn't. :)



[ Reply to This | # ]
How to find devices on your local network
Authored by: xfile087 on May 30, '06 09:48:32AM

Ummm... I have Mac OS X 10.4.6 running and I tried the command and it works,
but it keeps looping? I don't get it. Can anyone help?



[ Reply to This | # ]
How to find devices on your local network
Authored by: superg on May 30, '06 09:51:41AM

pings will keep going until you end it with <cntrl-c>



[ Reply to This | # ]
How to find devices on your local network
Authored by: xfile087 on May 30, '06 10:13:48AM

Aah. Simple. Many thanks!



[ Reply to This | # ]
How to find devices on your local network
Authored by: rpaege on May 30, '06 11:50:34AM

if you type a -c# flag after the ping command it will only report back once, as in:

ping -c2 192.168.1.255



[ Reply to This | # ]
How to find devices on your local network
Authored by: unforeseen:X11 on May 30, '06 02:28:01PM

...as said, ctrl + C or in Apples Terminal Command + "."

---
this is not the sig you`re looking for.



[ Reply to This | # ]
How to find devices on your local network
Authored by: rspress on May 30, '06 12:02:52PM

If you want to learn a little more about what is going on you might want to read
this page:

http://www.comptechdoc.org/independent/networking/guide/netbroadcasting.html

Knowing EVERYTHING about IP addressing was part of my CompTIA and MCSE
certifications.



[ Reply to This | # ]
How to find devices on your local network
Authored by: sgi_oh_too on May 30, '06 06:18:49PM

Wow! You know everything about something? Great job! Now you just have to
learn not to tell people that ; )



[ Reply to This | # ]
With Static IPs
Authored by: EatingPie on May 30, '06 02:18:50PM

With Static IPs, the broadcast address, as listed in the hint, most likely won't work. So you need to find your broadcast addy! Just type the following:

ifconfig -a

This gives a big list. Under either "eth0" or "lo0" you will find an entry like:

en0: flags...
...
inet xx.xx.173.212 netmask 0xffffffe0 broadcast xx.xx.173.223
...

That xx.xx.173.223 is my broadcast, and it does the trick when I ping it.


---
-Pie



[ Reply to This | # ]
How to find devices on your local network
Authored by: ianmac77 on May 30, '06 05:03:32PM

Just to let everyone know. The address to ping on a AirPort network is 10.0.1.255.

Check the network panel of system prefrences to see your IP address and replace
the last digits with 255, as explained above.



[ Reply to This | # ]
How to find devices on your local network
Authored by: albertoricart on May 30, '06 07:13:46PM
How to find devices on your local network
Authored by: Mac112 on May 31, '06 12:07:04AM

Just to clarify:
The amount of 255's must equal the number of 0's in the subnet mask. IE, if you
have a subnet mask of 255.255.255.0, the ping is x.x.x.255, if you have a subnet
mask of 255.255.0.0 the ping is x.x.255.255 and so on.



[ Reply to This | # ]
How to find devices on your local network
Authored by: tanvach on May 31, '06 02:59:28AM
Here's a modifies version which works on my system:

x=0
while [ "$x" -lt "255" ]; do
ping -c 1 10.0.0.$x &
x=$(expr $x + 1)
done
# Wait a few seconds for the pings above to finish
arp -a


[ Reply to This | # ]

How to find devices on your local network
Authored by: Just Fred on Jun 12, '06 06:10:22AM
This does NOT work in my network environment. Mine is a strange setup, however: I use the 169.254.x.x addressing scheme (the Automatic Private IP Addressing [APIPA] for reasons I will not go into here. When I attempt to ping the broadcast address (either 169.254.0.255 or 169.254..255.255) I either receive a single ping reply or none at all.

I believe the problem lies in the rather unique status this address range has. (A brief discussion of this may be found at http://www.duxcw.com/faq/network/autoip.htm).

---
--

[ Reply to This | # ]

How to find devices on your local network
Authored by: Nonsanity on Jun 14, '06 01:19:05PM
If you use a router's DHCP for all computers on your LAN, logging into it will likely give you a list of all DHCP devices by name. In my case, this means web browsing to: http://192.169.2.1/lan_dhcp.html

This won't find static IP address on your LAN, but it does give the NAMES of the devices it does find. Yeay for human readability! :)

[ Reply to This | # ]