raspberry pi static ip address configuration

3 Easy Ways To Set A Static IP Address On Raspberry Pi

When you plug a Raspberry Pi into the network and boot it, it will generally get a “random” IP from the DHCP server. This IP address might change almost every time you use it, which is not convenient at all. Let’s see how to set a fixed IP address, so the Raspberry Pi always use the same one.

There are three ways to set a static IP address on Raspberry Pi: assign an IP address to your Raspberry Pi in the router configuration, set a static IP in the desktop environment, or change the dhcpcd.conf configuration file to always use the same IP.

We’ll explore these 3 methods, but first, let’s make sure you understand your current network, it’s an important prerequisite to avoid any IP address conflicts or network malfunctions.

If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.

Prerequisites: Understand the network configuration

I put the word “random” in quotation marks in my introduction because there is nothing truly random with computers. Before picking an IP address and trying to configure it on the Raspberry Pi, we need to take a few minutes to study the current network.

Get the IP address of your router

On most networks, especially at home, the main router is your Internet provider box. It provides Internet access for all devices and is often the DHCP server too (the main equipment in charge of assigning IP addresses to all devices).

By accessing its web interface, you can generally get a clearer overview of the network configuration.

The IP address of the router is mentioned as the gateway when you check the network configuration of any device connected to it.

From a Raspberry Pi or Linux computer, you can use this command to find the IP address:
route -n

In my case, my router IP address is (because I configured it). But in most cases, it will be or

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

On Windows, you can use the system settings, or start a command prompt, and type:

Once you have the IP address, you can try to access the web interface via your web browser. It will be password protected, so you may need to find your Internet provider documentation to access it.

Once connected, I recommend doing two things to make sure you don’t do anything wrong by using one of the three methods mentioned in the article:

  • Find the DHCP range for the clients, meaning the list of IP addresses that can be assigned automatically by your router (if possible, your static IP should be outside this range).
  • Find the already used IP addresses, to avoid any conflict.

I’ll show you how to do this now.

Get the DHCP range

First, you need to find the DHCP range. In general, you have a network that goes from to, but the DHCP range is maybe only from 1.100 to 1.150. This will be useful to avoid any conflict.

We don’t want to set the Raspberry Pi IP address to 1.110 if the DHCP may assign it to your computer.

You can also find this information in your DHCP server configuration (so your Internet provider router in most cases). For me, it looks like this:

Well, I guess my configuration is not typical, as it covers all the IP addresses, probably because I changed it. A smart move, if you have something similar, would be to reduce the range (from 222.2 to 222.100 for example).

If you find that your DHCP range is from 1.100 to 1.150 for example, we’ll just avoid picking an IP address in this range. You can, for example, use 1.160 if it’s not taken by another device with a static IP.

How do you know? That’s the last step before changing the Raspberry Pi configuration.

Let's Build a School Together
Just $75 can create educational opportunities for a child in need.

Get a list of the currently used IP addresses

To be safe, it’s a good practice to get a list of the IP addresses that are currently used on the network. This can be done from the router interface directly, or via a network scan.

On the router configuration page, you may have access to a list of all the computers and other devices connected to your network, with their current IP addresses. Not only the one assigned by the DHCP server but all of them.

This will give a good overview of the current state of the network. If you can’t find this, don’t worry, you can also do a network scan.

From a Windows computer, you can also use the Advanced IP Scanner tool, which will give you something like:

And on Linux, you can install nmap with:
sudo apt install nmap
And use it to do a network scan:
nmap -sP <network> | grep report
So, for example:

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

In most cases, your DHCP server assigns IP addresses at the beginning of the range. In both examples, all IP addresses are given between 2 and 40. IP addresses 100 and 150 are static IPs.
So, if I pick something like 200 for my Raspberry Pi, it should be safe (

At this point, you should know which IP address you’ll configure on your Raspberry Pi. I’ll give you 2 methods, one from the desktop environment, and the other one in the command lines.

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.

Set a static IP for the Raspberry Pi on the router

The easiest way to set a static IP address for the Raspberry Pi is to assign it a static lease in the DHCP server configuration (most likely your Internet router).

The interface will be slightly different for each provider and router brand, but in my case, it looks like this:

I can pick the name of any device on my network, and set a static IP address. I can also enter a MAC address if the device is not listed (here is how to find the MAC address on Raspberry Pi).

If you can find something similar on your router, it would be the easiest solution. Nothing to change on the Raspberry Pi, and even when you reinstall the Raspberry Pi, it will stay with the same IP address.

It will also avoid most issues as it’s configured directly on the DHCP server.

Set a static IP on Raspberry Pi OS Desktop

On Raspberry Pi OS Desktop, a static IP address can be set manually by editing the wireless and wired network settings. Right-click on the network icon in the top-right panel, open the settings and fill the configuration manually.

Here are the exact steps:

  • Right-click on the network icon in the right corner of the top panel.
  • Choose “Wireless & Wired Network Settings”.

    I’m doing this procedure for the wired connection (eth0), but it works the same way for the Wi-Fi connection (wlan0).
  • Fill the form with your network configuration, for example:
    • Take a free IP address to put in the “IPv4 address”. If possible, try to pick something outside the DHCP range. But in general, DHCP servers are smart enough to not assign an IP address that is already taken.
      Don’t forget the network mask at the end (/24) or it won’t work.
    • The router IP address we got earlier with:
      route -n
    • And the DNS server is often the same for a home network.
      You can either check your current configuration with:
      cat /etc/resolv.conf
      And use the same IP. Or use a public DNS server, like the one offered by Google ( or OpenDNS (
      If you use Pi-Hole or AdGuard, you obviously need to adjust this and set it to the other Raspberry Pi IP address.
  • Click “Apply” to save the changes, and then “Close” (it doesn’t close automatically).

To really apply the changes, you need to reboot the Raspberry Pi (main menu > Shutdown > Reboot), unplug/plug the network cable, or disable/enable the Wi-Fi interface.

After the reboot or reconnection, you can put your mouse over the network icon to find out if your IP address has changed to the configured static IP address (more details here).

Set a static IP via the command line

On a Lite edition of Raspberry Pi OS, a static IP address can be configured in /etc/dhcpcd.conf. It will force the system to use this IP address instead of the one assigned by the DHCP server.

Here are the steps to follow:

  • Open the configuration file with:
    sudo nano /etc/dhcpcd.conf
  • Paste these lines at the end of the file:
    interface eth0
    static ip_address=
    static routers=
    static domain_name_servers=

  • Change the interface if needed (eth0 for a wired connection, wlan0 with Wi-fi).
  • Change the IP addresses according to your network.
    The first one is the IP address you want to use, followed by the network mask (/24 in most cases).
    The second is your gateway (the Internet router in general).
    And finally, the DNS server (often the router if you didn’t change it).

And that’s it. Once, you have a good idea of your network configuration and know where to change the Raspberry Pi configuration, it’s not that complicated.

I hope this article was useful, and if you want to learn more about network administration, you should check these other tutorials on the website:

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.


Does a Raspberry Pi need a static IP?

Using a static IP on Raspberry Pi is convenient, but not mandatory. Its utility is minimal for desktop use. For servers, a unique hostname serves the same purpose as a static IP address in most cases.

For specific network servers (DNS, DHCP, ad-blocker, etc.) where you use the IP address in the clients configuration, it’s recommended to set a static IP. But when the hostname can be use, or a quick scan done, it’s not mandatory.

How to set a static IP address before booting?

The easiest way to set a static IP address before booting is to assign a reserved IP address in the DHCP server configuration. The MAC address is the only information required, the system doesn’t matter.

You can follow the instructions given in the first method listed in this article to know how to do this on your router.

💰 Make Money Sharing Your Raspberry Pi Expertise!
Help others navigate the world of Raspberry Pi with your insights.
Become a RaspberryTips Contributor!

What’s the difference between a public and private IP addresses?

Public IP addresses identify devices on the internet, enabling global access to the Raspberry Pi. Private IP addresses are used within local networks, like home setups, allowing communication with devices such as your main computer.

If your goal is to give access to your Raspberry Pi via Internet from anywhere in the world, you should probably read this: How to Install and Use No-IP on Raspberry Pi? (Dynamic DNS).

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

Additional Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand, and improve any Python script for your Raspberry Pi.
Learn the essentials step-by-step without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Similar Posts