78

I need to find the Raspberry PI IP address on local network without connect the Raspberry to a monitor. How do I do it on Linux or Mac OS systems?

16 Answers 16

97

All raspberry devices MAC addresses started with B8:27:EB.

So, on *nix systems, this can be accomplished by executing the following command:

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

where 192.168.1.* will be your local network mask. You will get an answer like:

Nmap scan report for raspberrypi.localnetwork.lan (192.168.1.179)

The 192.168.1.179 is the Raspberry Pi IP address on you network.

If you are on a Mac system you can use Homebrew to install nmap:

brew install nmap

On Windows, you might use Wireshark and use the following display filter:

eth.addr[0:3] == B8:27:EB
| improve this answer | |
  • 2
    Or with less pipes: nmap -sP 192.168.1.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}' – ripat Feb 26 '14 at 12:08
  • 2
    Thanks @ripat, that is a lot more concise - updated! One little detail, you need to run as administrator or the nmap will not display the MAC address. – J. Costa Feb 26 '14 at 15:13
  • 3
    You would not appreciate the importance of this answer until you have tried to headlessly locate your raspberrypi in an office setting where IP's are dished out using DHCP. Cheers for this @ripat – Voke Ransom Anighoro Apr 17 '14 at 11:53
  • 1
    This answer didn't work for me since nmap wasn't spitting out the hostnames for me. However, it did inspire me to search for open ssh ports with nmap and that did enable me to find the pi: sudo nmap -p 22 --open -sV 192.168.0.0/24 per this guy's post. – Ross Rogers Jul 8 '15 at 17:06
  • isn't "sudo nmap -sP 192.168.1.0/24" enough (it wored for me)? – Marian Paździoch Dec 14 '15 at 10:54
52

If you're running MacOS or Linux, try this one:

$ arp -na | grep -i b8:27:eb

On windows, you can use:

arp -a | findstr b8-27-eb
| improve this answer | |
  • 3
    This solution is much faster than an nmap solution! – ryanm Dec 29 '15 at 3:49
  • This solution worked for me, unlike the nmap solution which gave only part of the list. – Wilbert Feb 15 '16 at 7:42
  • 7
    This will only show hosts which have made it into your arp tables, so sometimes misses the quiet ones. It might help to do an nmap scan once first. – Joseph Sheedy Mar 10 '16 at 0:36
  • It might, but for me this never failed. Plus it's an easy first try. – amenthes Feb 9 '18 at 10:44
  • Thanks for this. I modified it slightly and use arp -n | awk '/b8:27:eb/ {print $1}' now. – 0x01 Apr 6 '18 at 12:02
8

I use mDNS/Bonjour to give my Pi a local name like pi.local. I dont need to know it's IP address and this works for shortcuts and when you need to embed a link...

How and Why to assign a local name to your Pi

| improve this answer | |
  • Awesome! I used to fiddle around with /etc/hosts locally to get this functionality on my desktop, this is a MUCH better solution! Thanks so much for the pointer! – 0x01 Apr 6 '18 at 12:10
7

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.

| improve this answer | |
  • 1
    Classful networking was abandoned in 1993, which is a very long time ago. – Lightness Races in Orbit Mar 26 '18 at 17:28
  • What is classfull networking? – Denis Jun 22 '19 at 10:23
6

By default the raspberry's name is raspberrypi. You can just 'ping raspberrypi' and the ICMP echo reply gives you the IP address. It worked for me. Make sure though the DHCP server is reachable as the raspberry's NIC is by default in DHCP client mode. Otherwise the raspberry gets an APIPA address.

| improve this answer | |
4

In linux and MAC, you can also type in "arp - a" in the terminal and you can get a list of connected devices, look for the one with B8 in it, example: 192.168.4.5 @ B8... will be the raspberry pi IP.

| improve this answer | |
4

I use the free Fing app in my android smartphone. It scans the network and shows the connected devices by type, including Raspberry Pi, as well as scanning available ports. Handy to see if SSH, web or VNC are enabled and running.

| improve this answer | |
3

Or you could access to your Router via browser and find your android device -almost every router GUI has a service where you can check all devices that are currently connected to your network.

| improve this answer | |
3

If you run MacOS, use PiFinder, it is an application that will tell you the IP of a Raspberry Pi on your network.

| improve this answer | |
2

Copy the following into your Terminal/Console/Shell:

for i in $(jot - 1 254); do ping -t 1 192.168.1.$i && arp -a | cut -f 2,4 -d " " | tr [:lower:] [:upper:] | grep B8:27:EB; done

Please adapt 192.168.1. to your individual network.

The output will look something like this:

(192.168.1.109) B8:27:EE:DD:CC:A

192.168.1.109 would be your Raspberry Pi's IP… :)

| improve this answer | |
2

Put this in pi.php on your web server:

<?php
$fp = fopen('pi', 'w');
fwrite($fp, $_REQUEST['ip'],1000);
fclose($fp);
?>

You may have to create the file pi on your web server with write permissions for your web server.

Put

curl http://yourwebserver/pi.php -d ip=`hostname -I`

in /etc/rc.local on your pi.

Get the IP of your pi by browsing http://yourwebserver/pi

| improve this answer | |
2

When using a fresh install of NOOBS or Raspbian, the default hostname is "raspberrypi" and in some network configurations (i.e. if mDNS is in use and configured) you could use "raspberrypi.local". Another option is to run arp -a and look for raspberrypi

NOTE: This won't work for every instance.

| improve this answer | |
  • That answer seems to mix up several things: different IP versions, DNS, and maybe mDNS. Whether .local can be used usually doesn't depend on IPv6, and also not on having a router present. When mDNS support is available then pi-name.local resolves, IPv6 or not. Some home routers also use .local as their local DNS domain, again this is independent of IPv6 and depends on the router model. Some home routers use different domains, such as pi-name.fritz.box. – TheDiveO Feb 18 '18 at 23:35
2

My router assigns newly discovered systems an ip-address starting at 192.168.1.2, sequentially. I went through every system in my home one day and reserved addresses for them.

That way when I create a new system, chances are that its ip-address will be 192.169.1.18.

Another way to use the serial console. You can use a serial terminal program in order to log into your raspberry pi. I would suggest using the 8N1 (8-bits, no parity bit, 1 stop bit) setting with a speed (baud rate) of 115,200. You'll need a USB to serial (3V3) connector.

| improve this answer | |
1

I assume you cannot connect to you PI, otherwise you'd know its IP.

If you go to your router page (usually something like 192.168.1.1 in your browser) there you should have a section with the already connected devices. You can try to plug and unplug the PI (and one device should appear / dissapear from the list)

| improve this answer | |
1

'Fing' or 'Net Analyzer' on Android. Shows your whole network.

| improve this answer | |
1

If you are on Windows I suggest you to try out this script. It is mostly based on the "arp -a" command, but it saves you some extra digging and helps you when your Raspberry is not already in the Arp table.

Create a text file with the following content and rename it as find_raspberry_pi.bat

@echo off
:: This script, run from a Windows (10) machine, finds a Raspberry Pi on local network

set raspIp=
set myip=
set subnet=

:: Get IP for local PC
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set myip=%%b
set myip=%myip:~1%
echo IP for local PC: %myip%

:: Get subnet
set subnet=%myip%
setlocal enabledelayedexpansion
for /l %%a in (1,1,31) do if NOT "!subnet:~-1!"=="." set subnet=!subnet:~0,-1!
set subnet=%subnet:~0,-1%
setlocal disabledelayedexpansion  
echo Subnet: %subnet%
echo.

:top
:: Loop through arp table entries and look for Raspberry Pi's MAC address
for /f "tokens=1" %%f  in ('arp -a ^| findstr b8-27-eb') do (set raspIp=%%f)

if "%raspIp%"=="" (
    echo Discovering network...
    :: Ping all IPs in subnet from 1 to 254
    for /L %%N in (1,1,254) do start /b ping -n 1 -w 200 %subnet%.%%N >nul
    timeout 1 >nul
    goto :top
) else (
    echo Found Raspberry PI with IP: %raspIp%
)
echo.
pause

Disclaimers:

  1. I am not the author of the original script, I just adapted it a little bit to work with a Raspberry Pi. Sadly, I cannot find the original contributor.
  2. It's not bullet-proof, it will not work if the subnet it starts scanning is not the correct one.

Still, I used it many times and it's a simple solution

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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