How to find the current IP address of the Raspberry Pi?


Finding the IP address on a Raspberry Pi is often one of the first steps to take after any fresh installation, or maybe even after a reboot.
Unfortunately, it’s not the easiest thing to do, especially if you are new on this device. Let’s see how to do this.

How to find the current IP of your Raspberry Pi on the network?
Ifconfig is a Linux command showing the IP address in a terminal. It works on most systems, with or without desktop interface.
If there is no screen on the Raspberry Pi, a network scan is the best alternative.

In this tutorial, we’ll see how to find the IP of your Raspberry in different ways:
– with a screen (on a desktop or a minimal operating system)
– from another PC on the network (Linux or windows)
– from a network equipment (internet box, router, …)

We will also see how to set a static IP on the Raspberry Pi to avoid this issue in the future.

How to get the current IP address? (screen plugged)

Here is how to find the Raspberry IP address if you have a screen connected to it (or if you can connect one easily).

Command line :

The fastest way to display the IP is to open a terminal and type the following command:
ifconfig

You will get something like this:

eth0 is the LAN (wired) interface, and wlan0 is the WLAN (wireless) network interface.

I have squared in red the IP addresses, so in my case :
– 192.168.1.22 is my LAN IP.
– 192.168.1.15 is my WLAN IP.

Master your Raspberry Pi in 30 days
From beginner to expert in Raspberry Pi.
Learn useful Linux skills and practice multiples projects with step-by-step guides.

Graphical way :

If you prefer to use graphical tools, no problem, go to the taskbar, and mouse over the network icon on the right.
You will get something like this :

current ip from task bar

You will find the same information:
– wlan0 = WiFi = 192.168.1.15
– eth0 = RJ45 cable = 192.168.1.22

So if you have a screen, you normally get the IP address of your Raspberry Pi pretty quickly

How to find the IP address from another computer?

Finding the IP address from another PC will be less obvious, but you can also do it.

From a Linux/Mac PC :

From a Linux computer, there are many possibilities.
I give you three so pick the one that adapts better and more efficiently to your environment.

Arp cache :

A quick way to find it is to display the arp cache of your machine.
The arp cache is a list of associations IP <=> mac address for your network.

On Linux or Mac you can display it by doing :
$ arp -a | grep raspberry
raspberrypi.home (192.168.1.15) at b8:27:eb:1a:40:c0 [ether] on wlxc8d7193bf721

Remove the grep command if you want to show everything.

Nmap :

Nmap is a network scanner used to discover computers on a network.
That’s precisely what we want to do!
If needed, you have to install it with this command for a Debian-like system:
sudo apt-get install nmap

Then you can use Nmap to scan the network and display all results :
$ sudo nmap -sP 192.168.1.0/24 | grep raspberry
Nmap scan report for raspberrypi.home (192.168.1.15)

The same thing here, the grep command is not mandatory.

Ping :

I tell you because it can help with some systems where the other tools are not available, but it’s a very slow solution.

Ping is a tool that you probably know, which allows knowing if an IP address answers (and therefore if it is connected to the network).
There is a lesser-known option that allow you to ping your entire network, and collect responses.

You will get the list of used IP addresses and can find which one corresponds to your Raspberry Pi.
Do this command and wait:
ping -b 192.168.1.255

From Windows :

From Windows, you can also use ping broadcast address.
But I recommend a free tool, which is called Advanced IP Scanner that can scan an entire network or just a portion of it.

The interface is very intuitive, and it might be useful for other projects.
I put you a screenshot here so that you can get an idea of it and you can download it on their official website.

advanced ip scanner

Your router :

If the other solutions did not work, or if your Raspberry Pi is on an isolated network, consider using your router to find its current IP address.

Most routers display the list of devices connected to the network, with their IP address and their mac address.
If you have access to this interface, it should help you.

Given the number of routers on the market, I can’t help you in detail.
You will have to turn yourself to the router instructions for this one.

How to set a static IP? (LAN or WLAN)

Ok, so this time we managed to find the Raspberry Pi on the network, but it would be better to set a static IP address.
This will allow us to connect to it without doing the same thing each time, just by entering IP address that we will define now.

Some network concepts

If you lost your Raspberry Pi today, it’s probably because it was set on DHCP until now.

What is DHCP?

A DHCP is a system that automatically assigns IP addresses on a network.
At home, you generally have an internet box that takes care of that.
It will distribute IP addresses on a predefined network (for example 192.168.1.X) and a range of IP addresses reserved for DHCP (for example from 1.100 to 1.150).

The first thing to do before setting your Raspberry Pi in static IP is to know your network configuration.
Ideally, you should avoid choosing a static IP in the DHCP range.

How to define my static IP address?

In my example, I can set the IP address of the Raspberry to 192.168.1.200.
The DHCP server will no longer have any impact on the Raspberry Pi once the IP address is set to static.

If you do not have this information, try choosing a new IP far from the IP addresses assigned to your other computers.

Via command line or ssh

Ok, now that you know which IP to choose for your Raspberry Pi, let’s see how to do it using the command line for now.

Ethernet connection :

  1. Edit the configuration file :
    nano /etc/dhcpcd.conf
  2. Add this line (or uncomment them) :
    interface eth0
    static ip_address=192.168.1.200/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

    Don’t forget to replace this values with your network configuration.

  3. Reboot your Raspberry Pi :
    sudo reboot

After the reboot, you can check your new static IP with ipconfig.

Wireless connection :

It’s almost the same thing if you are using your Wi-Fi connection:

  1. Edit the configuration file :
    nano /etc/dhcpcd.conf
  2. Add this line (or uncomment them) :
    interface wlan0
    static ip_address=192.168.1.201/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1

    Don’t forget to replace this values with your network configuration.
  3. Reboot your Raspberry Pi :
    sudo reboot

Via the desktop GUI

As usual, if you prefer the GUI, here’s how to do the same thing (and it’s rather simple for once):

  1. Right-click on the Network icon in the taskbar.
  2. Select “Wireless and Wired Network Settings”.
  3. And you will get a window in which you have to fill your network settings (eth0 = Wired, wlan0 = Wi-Fi).

All you have to do is restart your Raspberry Pi to apply the settings.

Via your router (again) :

Again, on most routers and internet boxes it is possible to configure the DHCP server to assign an IP address to a host (mac address).
This configuration allows you to leave your Raspberry Pi in DHCP, but make sure it always gets the same IP.

This can be a good solution, especially if you are not always using the Raspberry Pi on the same network.

Video

How to Get the Raspberry Pi IP Address?

Conclusion :

And that’s it!
You have learned how to find your Raspberry Pi on a network, and how to assign a static IP so you will never look for it again!
You may have even learned some basic networking concepts 🙂

One thought on “How to find the current IP address of the Raspberry Pi?

Leave a Reply to Geoffrey Callaghan Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts