12

I've configured my RPi to be headless, and plugged it into my router. How do I discover the local IP address so I can ssh into it?

Update: Lots of documents point out that you can log into the router and look at the DHCP table. What if you don't have login credentials to the router? (I apologize for adding that restriction post-facto!)

  • 90% of the time people never change the login credentials from the factory defaults. If you can actually get your hands on the router, there is a very good chance that the username is admin and the password is the serial number. Or just locate the make and model and google search the default login credentials. – Dbo Apr 8 '14 at 12:29
  • Try telling that to Verizon/FIOS! :) (In my case, the router is in my in-law's apartment and Verizon set the password when they installed it.) – fearless_fool Apr 8 '14 at 17:43
11

Try:

arp -a

You can also try tcpdump, but that isn't as clear.

If you know the routers local IP address, type that into your browser and login. From there, depending on your router, you'll have a different set of options with information about your network including all wireless devices connected to the routers.

Apple's time machine/airport express makes this easy.

From any other router you'll probably have to look for a LAN tab then your IP Address allocations tab.

  • Would have commented for your router type but not enough reputation. – Dbo Apr 8 '14 at 6:53
  • arp -a is way faster than nmap -sS, and doesn't require root privs! thanks for the tip. – fearless_fool Apr 8 '14 at 10:32
  • @fearless_fool my pleasure – Dbo Apr 8 '14 at 13:40
  • Strangely enough: Immediately after booting my RPi for the first time, arp -a doesn't find it, but sudo nmap -sS 192.168.1.0/24 does. Caveat emptor. – fearless_fool Aug 23 '14 at 22:38
7

Using arp -a is fast and easy, but I have found that under certain circumstances, it doesn't list all of the devices. (As an aside, I don't know why that happens. Any ideas?) Here's an approach that -- so far -- always appears to work. It just takes longer...

In a shell window on your host machine (you said you did want to log in using ssh, right?), type:

sudo nmap -sS 192.168.1.0/24

(This assumes your local network is 192.168.1.xxx). This will scan for devices on the local network. It may take a while, but when it completes, it will print out a number of entries, including one that reads something like this:

Nmap scan report for raspberrypi.home (192.168.1.8)
Host is up (0.016s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
5900/tcp open  vnc
6000/tcp open  X11
MAC Address: 80:1F:02:DA:AF:0D (Edimax Technology Co.)

From this, we know the DHCP-assigned address is 192.168.1.8. If you're using the default user account, it's now possible to log in via:

$ ssh pi@192.168.1.8
3

Edit:

When configuring your a headless RPi you can connect it directly to your computers ethernet port (must be model B).

On a Mac you must turn on "Internet Sharing" within "System Preferences". This will allow your computer to create a connection between your WiFi and the ethernet port, which your pi should be plugged into.

In this "Internet Sharing" scenario your computer will take the IP address 192.168.2.1 (by default) while creating a DHCP server in the 192.168.2.X range.

Trying 192.168.2.2 is what I almost always connected to when I didn't have a monitor. If not that I'd always get 192.168.1.3.

When you finally gain remote access, take note of the IP and MAC addresses. Once you got them, look into DHCP Reservations and port mapping. Again, depending on your router, this might be very easy or very complicated.

Just use arp -a

  • But that's not true. Your router hands out addresses depending on what's plugged into it, so you can't assume that the RPi is at xxx.xxx.xxx.2 – fearless_fool Apr 8 '14 at 17:42
  • @fearless_fool Completely changed my answer. It has to do with connecting directly to your computers RJ45. – 1'' Apr 8 '14 at 23:41
  • Bumping you up a point -- I found it convenient to plug my new headless RPi into my MacBook enet port. I found I needed to do: Share From: Wi-Fi To computers using: Ethernet (and turned on Internet Sharing). Then my RPi turned up on subnet 2, just as you said, at 192.168.2.2. (Maybe one of us should edit your answer!) – fearless_fool Oct 23 '14 at 4:39
2

I use a solution that requires internet access. It might be a bit of a workaround, but has done well for me:

When booting, my Raspberry Pi automatically sends an email with its own IP-address to a gmail account I created solely for that purpose. On my work notebook, I use thunderbird to automatically mark any email received via that gmail account as read, therefore I don't get annoyed by it. If I need to ssh, I look at the latest email and it states the IP.

The script works like this: cron triggers a python script when booted (see here), which then sends the email: elinux wiki - Python Script.

I hope this helps,

Lukas

  • Heh. Configuring the RPi to send you e-mail means you had a way to communicate with it in the first place, e.g. a keyboard and display. That's what we're trying to avoid here. – fearless_fool Apr 28 '14 at 18:26
  • You could also edit the appropriate files directly on the sd card from another computer ;) that's how I do it... – LuWi Apr 28 '14 at 18:32
  • The script in the wiki link did not work for me. It crashed when I tried running it. I found this script worked: gist.github.com/johnantoni/8199088 – levibostian Feb 14 '18 at 21:43
0

Not quite answering your question, but I find it easier to assign fixed IP addresses to my RPis. In my router I configure the DHCP settings so they allocate in a range (say 100-255) then I assign fixed IP addresses in the range below 100 for some on my machines.

Assuming I want to assign the IP address 192.168.0.42 and myrouter (gateway) is 192.168.0.1, my /etc/network/interfaces file looks like:

# loopback
auto lo
iface lo inet loopback

# My config, Static IP
auto eth0
iface eth0 inet static
address 192.168.0.42
gateway 192.168.0.1
netmask 255.255.255.0

# Network address "family"
network 192.168.0.0
broadcast 192.168.0.255

  • Yep, that works. It requires that you know the DHCP range assigned by your router. And there's a bootstrapping problem: editing /etc/network/interfaces without a keyboard & monitor is a bit tricky. – fearless_fool Apr 8 '14 at 10:26
  • You are right about the bootstrapping. I have a spare keyboard, mouse and monitor that I use when I'm setting up my PI installation. Once I've got the basics done (like the networking), I can go headless. It would be good to be able to build a configured installation, say from another machine, but that's a bit beyond me. – Derek Knight Apr 17 '14 at 0:29
  • I did a fairly detailed (but simple) writeup on setting up an RPi from scratch w/o a keyboard or mouse in the RPi forum: raspberrypi.org/forums/viewtopic.php?f=91&t=74176 – fearless_fool Apr 17 '14 at 2:41
0

if you cannot access the pi because you have no monitor or whatsoever you can access your router and check connected devices.

In your working computer type ifconfig (if linux) or ipconfig(if windows) you'll see your own IP and your default gateway. For me, for instance, it is: my IP 192.168.1.101 and my gateway 192.168.1.1. Your's will probably look similar.

Then go to your browser and visit http://192.168.1.1 (the gateway you discovered) and you'll be in your router webpage. If it asks for a password look around the router case, it may be printed somewhere, or in the papers they gave you with the router, or try admin.. it really works pretty often.

In the router you'll have a bunch of options but there is always one section where you can check the status of the device and the already connected devices (specially if you are in the Wlan)

If no device exhibits a clear name (like Raspberry, or anything you set in the raspberry) try unplug and re-plug the raspi and see what device disappears and re-appears in the list. This is your raspberry :)

0

You can configure Avahi Daemon so that your Pi is always listening on the address raspberrypi.local. See Step 1

You can also use Advanced IP scanner to search for it.

Hope this helps!

  • But you can only configure Ahavi Daemon if you have a keyboard and display to plug into it in the first place. That's what we're trying to avoid! :) And as Dbo points out, you can use arp rather than a commercial product to find the RPi's address. – fearless_fool Apr 28 '14 at 18:25
0

I just tried to get the IP address of my new RasPi 2. First boot and on the works DHCP network. So here's how you get the address:

1) Plug it into the network, boot the RasPi and wait for a the SD Card light to extinguish for at least 20 seconds. 2) Unplug the RasPi and connect it to you laptop or pc running wireshark and watch for packets that have the MAC address starting as "Raspberr_cd:38:32", the cd:38:32 is my last 3 digits of my MAC so yours will be different. 3) You should see some packets which have a arp request saying "who has IP address: x.x.x.x" and also "Tell n.n.n.n" Where n.n.n.n is the RasPi's address.

HTH, Dan

0

I spend little time on it to figure out and finally one solution that worked fine.

Have a look at this one http://angryip.org/download/#windows

I believe "arp -a" will also give the IP but the tool which I mentioned above will give info in detail.

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.