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
Greenonline
  • 2,448
  • 4
  • 18
  • 33
Alex Garulli
  • 483
  • 1
  • 4
  • 7
  • 3
    This is so a duplicate. http://raspberrypi.stackexchange.com/questions/6714/how-to-get-the-raspberry-pis-ip-address-for-ssh?rq=1 and http://raspberrypi.stackexchange.com/questions/38/prepare-for-ssh-without-a-screen?rq=1 – 11684 Dec 23 '13 at 15:31
  • How did you install lseases on pi architecture ? .. there are no binaries for ARMv6hf – user2649476 Aug 17 '16 at 05:56
  • I got the solution with just one command no software is required. I have prepare tutorial on it. [https://www.youtube.com/watch?v=PWMVowAK6wg](http://www.youtube.com/watch?v=PWMVowAK6wg) – Kraj Technocrates Oct 27 '17 at 15:20
  • Possible duplicate of [Prepare for ssh without a screen](https://raspberrypi.stackexchange.com/q/38/50099). –  Apr 10 '19 at 04:10
  • Possible duplicate of [How to get the Raspberry Pi's IP address for SSH](https://raspberrypi.stackexchange.com/questions/6714/how-to-get-the-raspberry-pis-ip-address-for-ssh) – Brian Carlton Apr 19 '19 at 03:29

12 Answers12

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.

Ghanima
  • 15,578
  • 15
  • 58
  • 113
geoji
  • 674
  • 6
  • 5
  • 3
    Using samba on a RPi just to broadcast its hostname is like killing a fly with a sledgehammer. Better use avahi. http://thomasloughlin.com/broadcast-hostname-and-services-on-raspberrypi-to-apples-zeroconf/ – ripat Feb 26 '14 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 '14 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 '14 at 07: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 '14 at 18:46
  • What worked for me on Windows is `ping raspberrypi.local` – Naveen Jun 29 '19 at 12:22
  • `ping raspberrypi.local` on Ubuntu too – Noel Evans Aug 07 '19 at 20:24
  • 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. – The Coding Clan Aug 26 '19 at 12:21
  • Speaking of samba, how am I supposed to install it if I cannot login into my Pi? Not a real question, I just wanted to point out that installing samba does not seem to be viable. – Kar.ma Sep 07 '22 at 12:04
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.

einnocent
  • 494
  • 6
  • 10
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

11684
  • 455
  • 1
  • 3
  • 13
  • 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 '14 at 14:07
  • @ripat Wow, that renders it almost useless. – 11684 Feb 27 '14 at 07: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](http://raspberrypi.stackexchange.com/questions/13936/find-raspberry-pi-address-on-local-network/13946#13946) – ripat Feb 27 '14 at 08:11
  • ... and you need to run that above command as root `sudo nmap .....` – ripat Feb 27 '14 at 08: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

Tho
  • 161
  • 1
  • 2
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...

sebastian
  • 151
  • 1
  • 4
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 pi@raspberrypi.local'. 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 mama@papagoose.local'. If you are secure shelling from a windows OS, just drop the '.local'.

1

It's actually quite simple. Once your pi is connected to wifi, you can just use user@devicename.local. For the default settings, your command would be the following:

ssh pi@raspberrypi.local

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

Anvay
  • 111
  • 5
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.

Bex
  • 2,919
  • 3
  • 24
  • 34
jeffresc
  • 199
  • 4
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.

mozcelikors
  • 211
  • 2
  • 6
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.

user2609980
  • 101
  • 1
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/

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