Where is your Raspberry Pi?
https://gratisography.com/

Where is your Raspberry Pi?

Help! I can't find the IP address of my Raspberry Pi!

I was working on a project at my friends cabin. The Raspberry Pi was in a waterproof container with no keyboard, mouse, or monitor attached. I planned to communicate with the Raspberry Pi using VNC or SSH on a separate computer. But I realized that on this new network, I didn’t know the IP address of the Raspberry Pi - and so couldn’t communicate with it over the network.

There are lots of ways to do this, let’s start from what I think is easiest. Be aware that some of these may not work depending on your network configuration. If you don’t get the IP address using one method, try another...

ping

Let’s start with a simple ping.

Ping -4 raspberrypi

The "-4" tells ping to use IP4 addressing. IP6 will give you a longer address - probably more than you need. Detailing “raspberrypi” tells ping what device to look for. Ping will then tell you if that device is available, and the IP address it is using. Obviously, don’t do this from the Raspberry Pi - that will only tell you the local address. Instead, do this from another computer.

You should see something like this...

Pinging raspberrypi.local [10.0.0.244] with 32 bytes of data:

Reply from 10.0.0.244: bytes=32 time=3ms TTL=64
Reply from 10.0.0.244: bytes=32 time=4ms TTL=64
Reply from 10.0.0.244: bytes=32 time=2ms TTL=64
Reply from 10.0.0.244: bytes=32 time=2ms TTL=64

Ping statistics for 10.0.0.244:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 4ms, Average = 2ms


Write to boot

Another method is to instruct the Raspberry Pi to write the IP address to /boot. This needs to be set up to start at system boot. In a previous Raspberry Pi Weekly I discussed using systemd to do this and in fact - the example dot-service file from that session will write the ip address to the boot partition

[Unit]
Description=Save IP address
Documentation=https://niemannross.com/link/saverpiip
After=network-online.target

[Service]
ExecStart=/bin/sh -c "ifconfig > /boot/myIPAddress.txt"

[Install]
WantedBy=network-online.target


We talked about the next step in the Raspberry Pi session on /boot. Start up the Raspberry Pi, give it a couple of minutes to finish the boot process, then shut it down. Remove the SD card and insert it in your desktop computer to read the new text file. This IP address is probably the address of the Raspberry Pi - assuming that the router doesn’t reassign an IP address.

Arp -a

arp -a command will list all active IP addresses on network.

Arp -a

Unfortunately, this doesn’t tell you which address is the Raspberry Pi. It does give you a list of addresses you can start with. Try each of them to see if you can open an ssh or vnc connection.

IP scanner

There are various IP scanners available for download. I’ve tried advanced IP scanner. It’s free and easy to use. Pressing scan produces a list of all IP addresses in use on the local network - as well as the computers using them.

nmap

Nmap is a serious network administration tool with a broad range of abilities. In fact, there is an entire course in this library dedicated to how to use this powerful tool. If you need to use nmap, I suggest you start with this course.

Summary

There are a lot of options for finding an IP address for a headless Raspberry Pi. Which one you use will depend on the tools you have available.

Subscribe

If you liked this dose of Raspberry Pi goodness, please subscribe to my newsletter!

Ryan Bedford

IoT Platform Engineer at Raspberry Street

3 年

You forgot to mention Raspberry Street in all the ways to help keep track for your Pi (including the IP address). That's what Raspberry Street is all about! ?? https://www.dhirubhai.net/company/raspberrystreet Thanks for the article!

要查看或添加评论,请登录

Mark Niemann-Ross的更多文章

  • Documenting My Code ... For Me

    Documenting My Code ... For Me

    There are two signs of old age: old age, and ..

  • R Meets Hardware

    R Meets Hardware

    R is a programming language for statistical computing and data visualization. It has been adopted in the fields of data…

    2 条评论
  • Party Buzz Kill: modifying data

    Party Buzz Kill: modifying data

    So Steve (SQL), Marsha (C), Bob (Python), and I (R) are at this party. We have TOTALLY cleared the room, especially now…

    2 条评论
  • Rain - Evapotranspiration = mm Water

    Rain - Evapotranspiration = mm Water

    "Eeee-VAP-oooo-TRANS-PURR-ation," I savor the word as I release it into our conversation. I'm still at the party with…

  • Party Buzz Kill: Data Storage

    Party Buzz Kill: Data Storage

    I'm at this party where Bob and Marsha and I are discussing the best languages for programming a Raspberry Pi. Bob…

    5 条评论
  • R Waters My Garden

    R Waters My Garden

    I'm at a party, and the topic of programming languages comes up. A quarter of the room politely leaves, another half…

    10 条评论
  • Caning and Naming

    Caning and Naming

    We've been back from Port Townsend for a week. Progress on the boat isn't as dramatic as it is when we're spending the…

    1 条评论
  • Irrigate with R and Raspberry Pi

    Irrigate with R and Raspberry Pi

    I’m working on my irrigation system. This requires a controller to turn it on and off.

    3 条评论
  • 5 Reasons to Learn Natural Language Processing with R

    5 Reasons to Learn Natural Language Processing with R

    Why learn R? Why learn Natural Language Processing? Here's five reasons..

    1 条评论
  • Performing Natural Language Processing with R

    Performing Natural Language Processing with R

    I recently released a course on Educative covering topics in Natural Language Processing. Different Learners -…

    1 条评论

社区洞察

其他会员也浏览了