6

I have a Raspberry Pi connected to the Internet via LAN or via wireless. How do I scan my local network for its IP address so I can SSH into it?

While I can just connect it to a monitor and manually run ifconfig, I was hoping there was an easier way like using nmap.

2

2 Answers 2

7

This answer on the Raspberry Pi Stack Exchange site seems to perfectly nail it. The key is all Raspberry Pi’s have a MAC address that begins with B8:27:EB so you can use nmap to scan the network and filter for that MAC address like this:

sudo nmap -sP 192.168.1.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'

Of course the 192.168.1.0/24 should be changed to match your Raspberry Pi’s networking setup, but I assume that 192.168.1.0/24 is the default Raspberry Pi range anyway.

Also, this page seems to have another nice method of achieving the same goal by using arp and grep to find traffic based on only the MAC address; no network range needed:

arp -a | grep b8:27:eb | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
1

Assuming your on linux, you can try nmap. You can try something like :

$ nmap 192.168.1.0/24  

Nmap scan report for pi (192.168.1.10)  
Host is up (0.023s latency).  
Not shown: 999 closed ports  
PORT   STATE SERVICE  
22/tcp open  ssh  

This will list all the host on the network 192.168.1.0/24, and list the tcp ports open on each of them. Typically, you'll find your raspberry py has port 22 open, and some other if you have some other services running.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .