Find your Raspberry Pi's IP address on a network

Use cases

If you are like me, you often use your Raspberry Pi headlessly. Meaning it is not hooked up to a monitor. The Pi is great for headless use, however sometimes you find yourself unable to SSH into it because the IP has changed since the last time you used it. Or perhaps you just simply forgot the IP address.

Install nmap

nmap is a dependancy that you’ll need to install. Installation directions can be found here.

Determining your Network Mask

Since I’m on a MacBook and I’m on the same network as my Pi I can run the following command..

ipconfig getifaddr en1

note: I’m using ‘en1’ because my MacBook is running of Wifi only and no network cable connected. If you are on wired connection only, try ‘en0’.

So after running this command, the terminal returns the IP address from my MacBook. We’ll take that and replace the last number with ‘0/24’ so for example..


Let’s Scan

We’ll want to scan the entire network for port 22 responses. So finally our command should look something like this…

nmap -T5 -n -p 22 --open --min-parallelism 200 ###.##.#.0/24

note: You’ll replace the ‘#’ symbols with the numbers you determined in the step above.

After running this command you should get a list back. Should look like this..

Nmap scan report for ###.##.#.##
Host is up (0.035s latency).
22/tcp open  ssh

If you get back more than one device, try SSHing into one. One of them is your Pi.

Alternative Options

Adafruit has an great little tool called PiFinder. Check it out here. Another idea would to be use a static IP. This is only an option if you control your network. (may not be an option in an office)