38

I have a Raspberry Pi connected to Ethernet and with a Mac (though USB cable).

I'm trying to SSH in the Pi but I don't know the IP address. I have tried :

 ifconfig

but I have I can't see eth0

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=2b<RXCSUM,TXCSUM,VLAN_HWTAGGING,TSO4>
        ether a8:20:66:09:f8:36 
    media: autoselect (none)
    status: inactive
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 7c:d1:c3:d8:b5:dd 
    inet6 fe80::7ed1:c3ff:fed8:b5dd%en1 prefixlen 64 scopeid 0x5 
    inet 192.168.91.16 netmask 0xffffff00 broadcast 192.168.91.255
        media: autoselect
    status: active
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
        lladdr 00:3e:e1:ff:fe:7f:a0:82 
    media: autoselect <full-duplex>
    status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0e:d1:c3:d8:b5:dd 
    media: autoselect
        status: inactive
5

12 Answers 12

20

Try Pi Finder for Mac to discover the RPi's IP with a headless RPi unit.

Though in your edited question, it appears the IP is listed under en0 as 192.168.91.16, assuming that your ifconfig output is coming from the RPi.

1
  • Con gusto :) And fwiw, the other utilities Pi Filler and Pi Copier are pretty useful, too.
    – einnocent
    Dec 23, 2013 at 20:14
30

You can lookup the IP address by hostname. Assuming the hostname of your Pi is "raspberrypi"

Here is how you obtain the IP address using ping command and hostname.

From Linux: ping raspberrypi
From Windows: ping raspberrypi
From OS X: ping raspberrypi.local

In order for the command to work from Windows, you need to have Samba running on your Pi. You can install Samba using the command sudo apt-get install samba.

8
  • 3
    Using samba on a RPi just to broadcast its hostname is like killing a fly with a sledgehammer. Better use avahi. thomasloughlin.com/…
    – ripat
    Feb 26, 2014 at 12:18
  • Some people want the easiest solution. Some people want the most efficient solution. For those looking for an easy solution, it cannot get easier than the one line command to install samba. Plus the avahi solution that you suggested works easily only from OS X. If you want to make it work from Windows, you need Bonjour which you get by installing iTunes. So you are basically replacing the samba sledgehammer with the iTunes sledgehammer.
    – geoji
    Feb 26, 2014 at 16:24
  • Though I think the number of people who have iTunes installed because they need it anyways for their iDevice is greater than the number of people with Samba. @geoji
    – 11684
    Feb 27, 2014 at 7:39
  • You don't need to install samba on the client machine. Samba needs to be installed just once on the raspberry Pi. The downside of the iTunes approach is that you need to have it installed on every single machine from which you need to find the IP address from.
    – geoji
    Feb 27, 2014 at 18:46
  • 1
    ping raspberrypi.local works on windows in the web browser and for ssh on a new raspbian system out of the box with a ssh file in boot. both samba and itunes are unnecessary. Aug 26, 2019 at 12:21
13

Are the Pi and the Mac in the same network? In that case, I just used arp -a to find it. There's a number of other methods though, listed here: https://apple.stackexchange.com/questions/19783/how-do-i-know-the-ip-addresses-of-other-computers-in-my-network?rq=1

4
  • 3
    arp -a will work if, and only if, the Mac already successfully probed or connected to a host. Try yourself by restarting your Mac and displaying the arp table. It will be almost empty. To populate that table you need to run something like a ping scan: nmap -sP 192.168.91.0/24
    – ripat
    Feb 26, 2014 at 14:07
  • @ripat Wow, that renders it almost useless.
    – 11684
    Feb 27, 2014 at 7:36
  • 1
    Workaround: nmap -sP 192.168.91.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}' see my comment on this thread
    – ripat
    Feb 27, 2014 at 8:11
  • ... and you need to run that above command as root sudo nmap .....
    – ripat
    Feb 27, 2014 at 8:29
6

I developed a cross-platform tool for finding local IP address of Raspberry Pi faster:

The article about it: Pi-oi: a Tool for Finding the Local IP Address of Your Raspberry Pi

3
  • Super! Works great! Oct 13, 2016 at 9:52
  • Tested. Observed: Wrongly recognized Orange Pi as Pi! However could not recognize Raspbian on Rpi 0 & Rpi 2 even when Host response shows Raspbian. Jul 24, 2017 at 12:33
  • Can you paste a shot screen?
    – Tho
    Jul 24, 2017 at 12:39
5

Using ping and arp wouldn't work for me, because on my network, the raspberry has been assigned a different hostname.

But I succeeded using lsleases, this is also recommended on the Raspberry PI site.

After installing lsleases, start the server with sudo lsleases -s; then reboot your Raspberry PI and wait for the IP address to appear.

$ sudo lsleases -s
[sudo] password for sebastian: 
2015/01/15 15:36:40 startup -  version:  1.4.0
2015/01/15 15:36:40 enable active check - ping every: 15m

# Reboot your Raspberry PI and wait

2015/01/15 15:37:10 new DHCP Lease: '132.231.71.116  b8:27:eb:f5:c3:4a raspberrypi'

Voila...

1
  • IMO best answer, fastest and 100% work guarantee. Jan 17, 2021 at 12:36
2

'en1' is your ethernet address using 'ifconfig'. But you don't need to look up IP addresses - that's what Hostnames and DNS are for. You say you're on a mac, so just 'ssh [email protected]'. Let DNS do the work in the background. If you had given your PI a hostname, say, 'papagoose', and you have a username of 'mama', type 'ssh [email protected]'. If you are secure shelling from a windows OS, just drop the '.local'.

1

If it's your home network, you can easily login to your router as most of them display client IP addresses somewhere in there. Your router IP can be found by typing ipconfig (Windows) or ifconfig (Mac, Linux, etc.) and it will be listed under Gateway. The router IP is commonly 192.168.1.1.

1

If you want to use a GUI application for it, you can use Yakala tool (https://github.com/mozcelikors/yakala) for Debian/Ubuntu. This tool helps you not only search for available Type B and Type C networks, but also helps you to directly SSH into the network:

sudo add-apt-repository ppa:mozcelikors/yakala
sudo apt-get update
sudo apt-get install yakala

or

git clone https://github.com/mozcelikors/yakala
cd yakala && sudo ./install.sh

https://raw.githubusercontent.com/mozcelikors/yakala/master/docs/img/peekx2.gif

Disclaimer: I am the creator of Yakala. Any suggestions/bugs are taken very seriously.

1

It's actually quite simple. Once your pi is connected to wifi, you can just use [email protected]. For the default settings, your command would be the following:

ssh [email protected]

Update: It actually works for other OS's, I think.

1
  • 1
    This should be the accepted answer! Jan 16, 2022 at 11:45
0

This is how I login to my Raspberry Pi:

IP=$(sudo nmap -p 22 --open -sV 192.168.0.0/24 | grep 192 | awk '{print $NF}') && ssh pi@$IP

Find open SSH port on the local network, get the ip, SSH into it.

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

0

For me arp works perfectly most of the times if you mac and raspberry are in the same network.

arp -na | grep b8:27

or you can use nmap (Change CIDR with yours)

nmap -sn 192.168.1.0/24

https://installvirtual.com/find-ip-of-raspberry-pi/

1
  • Using arp and nmap was already said in previous answers. It doesn't help just repeating answers.
    – Ingo
    Mar 4, 2019 at 16:32

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