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 learn how to fix it, and tell the Raspberry Pi to 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 are 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: Get 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.
If you don’t know its IP address, it should be mentioned as “gateway” in the network configuration of any computer connected to the Internet. It’s often the DNS server too.

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

Get My Commands Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

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

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.

Set a static IP for the Raspberry Pi on the router

If the network main router is also the DHCP server, the easiest way to set a static IP address for the Raspberry Pi is to use its web interface. We call this a DHCP lease, and it’s possible to set a static lease for any equipment already connected to the network.

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.

Get the DHCP range

If you can’t or don’t want to use this recommended method, you need a bit more information before configuring the Raspberry Pi manually.

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).
Anyway, we’ll do a quick audit after that to choose a free IP address.

Get My Commands Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

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.

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 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:

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.

Help me help them <3
Help me raise funds for education by donating to my Pencils of Promise campaign.
Together we could fund a school for them!

Set a static IP on Raspberry Pi OS Desktop

On Raspberry Pi OS with Desktop, we can set a static IP address by editing the wireless and wired network settings from the top menu.

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 probably need to reboot the Raspberry Pi (main menu > Shutdown > Reboot), unplug/plug the network cable, or disable/enable the Wi-Fi.

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).

Get My Commands Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

If you are looking for exclusive tutorials, I post a new course each month, available for premium members only. Join the community to get access to all of them right now!

Set a static IP in 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:

Get My Commands Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

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.

Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Recent Posts