nmap for Finding the IP Address of Raspberry Pi, Beaglebone, Edison, etc.

Working a lot with embedded linux devices these days and really appreciating the usefulness of nmap. I’m always wondering why this isn’t recommended more often.

When working on something like a Raspberry Pi that connects to wifi automatically, typically you would write some sort of script that emails you the IP address of the device. This obviously has one big dependency in that you must have Internet access which can be hard to fulfill for most art installations or performances.

nmap provides a nice solution when you are connected to the same network as the embedded device. It basically scans and pings all IPs on the network and reports back.

You can run nmap like this in a terminal to scan all IPs on the network:

1
nmap -sn 192.168.1.*

Usually, I’ll install a little mini wifi router near the embedded devices so I can access them easily when I come into the router’s range (I’m also noticing a lot of people thinking that a wifi router implies Internet connectivity which is very wrong. Wifi routers just connect computers together with or without Internet in case you aren’t sure).

nmap will report back all the active IP addresses on the network giving you each device’s IP. Easy!

Of course you have to put in the right network mask. For instance if your IP address is 10.0.0.143 you would run this:

1
nmap -sn 10.0.0.*

Still confused by the output? To be absolutely sure, run nmap once before turning on your devices, then once after a minute of all devices being turned on. Look for the new IP addesses.

If you are wondering what the -sn means, it simply means scan without a portscan or rather a “ping scan.” You might also see it in this form:

1
nmap -sP 192.168.1.*

which is an older version of the same thing.

Drawbacks

This is suited specifically for small local networks. If your device is connected to a much larger network like a school or office network its not going to work as there will be too many IPs to ping and sort through.