How to Set a Static IP Address on Raspberry Pi

Make sure your Pi has the same IP every time you boot.

Static IP Address for Raspberry Pi

If you're trying to access a Raspberry Pi on your local network, there are times when you'll really need its IP address. Sure, you can usually SSH or VNC into a Pi by using its hostname, but for something like port forwarding on a router (which you'll use to create an externally-accessible Minecraft server or web server), an actual IP v4 address may be needed. The problem: every time you reboot your Pi, the IP address can change, based on what the router decides to assign at the moment.

Fortunately, there's a simple way to make sure that your Raspberry Pi always gets the same IP address on your local network or, at least, always tries to get the same address on your local network. It almost goes without saying that if, at the time it boots, another device that's powered on is already using the address in question, your Pi will either have no IP v4 address at all or (if you configured it as such) it will choose an alternative one. So keep that in mind.

Note that this tutorial assumes you already have a Raspberry Pi that's connected to your network. If not, please see our tutorials on how to set up a Raspberry Pi and how to set up a headless Raspberry Pi (no monitor required).

How to Assign a Static IP to a Raspberry Pi

1. Determine your Raspberry PI's current IP v4 address if you don't already know it. The easiest way to do this is by using the hostname -I command at the command prompt. If you know its hostname, you can also ping the Pi from a different computer on the network.

2. Get your router's IP address if you don't already know it. The easiest way to do this is to use the command ip r and take the address that appears after "default via."

3. Get the IP address of your DNS (domain name server) by enter the command below. This may or may not be the same as your router's IP. 

Now that you have the IP address your Pi is currently using, the router's IP address and the DNS IP address, you can edit the appropriate configuration file.

4. Open /etc/dhcpcd.conf for editing in nano.

5. Add the following lines to the bottom of the file. If such lines already exist and are not commented out, remove them.

Replace the comments in brackets in the box below with the correct information. Interface will be either wlan0 for Wi-Fi or eth0 for Ethernet.

In our case, it looked like this.

You may wish to substitute "inform" for "static" on the last line. Using inform means that the Raspberry Pi will attempt to get the IP address you requested, but if it's not available, it will choose another. If you use static, it will have no IP v4 address at all if the requested one is in use.

6. Save the file by hitting CTRL + X and reboot . 

From now on, upon each boot, the Pi will attempt to obtain the static ip address you requested.

Using the Raspberry Pi OS Guide to Set a Static IP

If you already have all the information about your router's IP and DNS IP, you can configure the static IP address using the Network Preferences menu instead of editing the dhcpcd.conf file.

1. Right click on the network status icon and select the Wireless & Wired Network Settings.

2. Select the appropriate interface . If you're configuring a static IP for Wi-FI, choose wlan0. For Ethernet, choose eth0.

3. Enter the IP addresses into the relevant fields.  Your desired IP address will be in the IPv4 field, followed by a /24. Your router's IP and DNS server's IP will be in the fields named after them.

4. Click Apply , close the window and reboot your Pi.

Your Pi will now attempt to use your desired IP address at each boot. However, the Network Preferences menu sets this as a preference, not an absolute. So, if the IP address you asked for is not available, it will use another.

Stay on the Cutting Edge

Join the experts who read Tom's Hardware for the inside track on enthusiast PC tech news — and have for over 25 years. We'll send breaking news and in-depth reviews of CPUs, GPUs, AI, maker hardware and more straight to your inbox.

Avram Piltch

Raspberry Pi Mood Light Changes Color by Detecting Your Emotions

Raspberry Pi Pico Powers DIY E Ink Train Departure Board

AMD Claims Starfield Devs Have the Power to Add DLSS Support

  • AusMatt Typo: grep "namesever" /etc/resolv.conf Should read: grep "name r sever" /etc/resolv.conf Reply
  • alan tracey wootton With an Arduino that is serving a web page one can use mDns instead of keeping track of the local IP address. Add this to your Setup(): if (MDNS.begin("esp32")) { MDNS.setInstanceName("count server demo"); MDNS.addService("http", "tcp", 80); MDNS.addServiceTxt("http","tcp","counter","true"); }Then that webpage is available locally in chrome and safari as: http://esp32.local./I didn't test the other browsers. I'm sure this works for a Pi also even though I haven't tried it yet. mDns might be on by default. The url would be http:// raspberrypi .local./To check, try this command: dns-sd -B _http._tcpWhen I do that I find that both of my printers are serving http (a supply level page) in addition to the microcontroller. Reply
  • wl84 When I run the nameserver command I get two results back - and I tried both in the config and I can't connect to anythign with either. I'm trying to setup pihole Reply
  • View All 3 Comments

Most Popular

By Les Pounder July 29, 2023

By Stewart Bendle July 28, 2023

By Sammy Ekaran July 28, 2023

By Abhishek Mishra July 27, 2023

By Sammy Ekaran July 27, 2023

By Matt Safford July 26, 2023

By Sammy Ekaran July 25, 2023

By Sydney Butler July 23, 2023

By Sydney Butler July 21, 2023

By Ed Tittel July 20, 2023

By Abhishek Mishra July 19, 2023


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

change ip raspberry pi

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

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

change ip raspberry pi

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:

change ip raspberry pi

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.

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:

change ip raspberry pi

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:

change ip raspberry pi

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:

change ip raspberry pi

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.

change ip raspberry pi

  • 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

change ip raspberry pi

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

  • How to use Raspberry Pi to monitor network?
  • Network Boot With Raspberry Pi: Everything you need to know
  • How to use your Raspberry Pi as a DNS Server (And Speed Up Internet)

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

  • 25 awesome Raspberry Pi project ideas at home
  • 15 best operating systems for Raspberry Pi (with pictures)
  • My book: Master your Raspberry Pi in 30 days

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.

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

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 .

' src=

I'm the lead author and owner of 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 web developer experience.

Similar Posts

Step-by-Step Guide: Configuring a Firewall on Raspberry Pi

Step-by-Step Guide: Configuring a Firewall on Raspberry Pi

The Raspberry Pi has so many uses, that sometimes it’s important to consider security steps in our projects. One great use is to install a firewall on the Raspberry Pi to protect the hosted services or data. In this article, I will show you how to install and use one easily. The easiest way to…

Android TV + Google Apps On Raspberry Pi: step-by-step guide

Android TV + Google Apps On Raspberry Pi: step-by-step guide

Using Android TV on your Raspberry Pi and connecting it to your TV is an excellent alternative to Kodi (with OSMC or LibreElec). The system is more intuitive, as you can install apps directly from the Play Store, and it works well out of the box. The installation has improved over the years, but it’s…

Install Pi-Hole on Raspberry Pi (Free Ad Blocker in 15 min)

Install Pi-Hole on Raspberry Pi (Free Ad Blocker in 15 min)

Blocking ads and pop-ups on all of your devices can sometimes take a lot of time and effort. Today, I’ll show you how to install an ad blocker for your entire network in 15 minutes. We’ll use Pi-Hole, which is a famous ad-blocker for Raspberry Pi. Pi-Hole is a free and open-source ad-blocker that can…

How to Install & Use Vim on a Raspberry Pi (Text Editor)

How to Install & Use Vim on a Raspberry Pi (Text Editor)

Vim is a well-known text editor on Linux, that can be used on a Raspberry Pi (instead of Nano, for example). I was used to it before I started finding it too buggy, and then it was removed on recent Debian-like distributions. But it’s still a decent alternative to other free text editors, and today…

How to Install Manjaro on Raspberry Pi?

How to Install Manjaro on Raspberry Pi?

I’m always looking for new Linux distributions to try, and in the last few months, one of them has caught my attention: Manjaro.Manjaro is currently one of the top viewed distributions on Distrowatch and is available on Raspberry Pi.The perfect choice for a review :). The easiest way to install Manjaro on a Raspberry Pi…

TeamViewer On Raspberry Pi: Everything You Need to Know

TeamViewer On Raspberry Pi: Everything You Need to Know

If you need remote access to your Raspberry Pi, Teamviewer is a great option (I used it at work for many years). But it’s a commercial app, aimed mainly at businesses, so it can be a bit tricky to get started with it on Raspberry Pi. That’s why I wrote this tutorial, to give you…

Level Up Your Raspberry Pi Skills: Free PDF with Must-Know Linux Commands!

How to Configure a Static IP Address on the Raspberry Pi

Raspberry Pi Static IP Address

The network capabilities on the Raspberry Pi make it possible to create some really fun projects. Once in a while, you'll come across a project that could benefit from a static IP address. If you're using your Raspberry Pi for storage as a NAS device, an FTP server—or any other kind of server for that matter—a static IP address can be a big help.

Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

Update Raspberry Pi OS

Update Raspbian

This guide should work with any Raspberry Pi using Raspberry Pi OS (formerly Raspbian). Make sure your copy of is up to date. If you're not sure where to begin, visit our guide on how to update Raspberry Pi OS .

Find your router IP address

Raspberry Pi OS Find Router IP

We'll need both your router IP address and name server IP. We can find this information by running a few commands in a terminal on the Pi. Remote into the Pi using SSH or open a terminal window from within Raspberry Pi OS.

To find your router IP address, enter the following command: ip r | grep default The router IP address will appear after the text "default via"—take note of it. The name server can be found in the resolv.conf file. Open it using the following command. sudo nano /etc/resolv.conf Take note of the name server IP address and close the file with CTRL + X .

Edit the dhcpcd file on the Raspberry Pi

Edit DHCPDC Raspberry Pi OS

The static IP is set by adding it to a file on the Raspberry Pi. In the terminal window, run the following command to edit the dhcpcd.conf file.

Set the static IP address

Raspberry Pi OS Static IP

This document has a few lines of code that can be activated by removing the # to the left of each line. Use the following ledger to properly set your static IP address.

  • Network = If you're using a wired connection, set this to eth0 . If you're using a wireless connection, set this to wlan0 .
  • Static_IP = This is the static IP address you want to assign to the Raspberry Pi.
  • Router_IP = This is the IP address for the router.
  • Name_Server = This is the name server address. You can use another DNS IP here if you'd like.

Enter your information into the file, be sure to remove the <> brackets. Check the screenshot for an example.

When that's completed, save the file using CTRL + X .

Test the static IP address

When the changes have been made, restart the Raspberry Pi. Now is a good time to test your project and make sure the IP address isn't changing. Disconnect and reconnect your Pi from the network. If the IP address changes, verify the information in the previous step saved properly. If it stays the same, congratulations! You've set a static IP on the Raspberry Pi.

How to Find Your Raspberry Pi's IP Address

This short guide shows you various ways to find the IP address of your Raspberry Pi.

Set up a static IP-address on the Raspberry Pi

By default, the Raspberry Pi will get a dynamically allocated IP-address, meaning it changes as you restart it or potentially when new devices are added to the network. To make it easier to connect and have a more stable connection I recommend to set up a static IP address.

Table of contents

Get a static ip-address, setting-up using the desktop, setting-up with the terminal, prioritising internet interface, disabling static ip-address.

To get a static IP-address that works, it will need to be within the range provided by the router. We will therefore first need to find the router’s ip address. This tends to be written on the bottom of the router. If not, simply open a terminal window and type in netstat -nr . Now look under Gateway :

internet gateway

You can also use the command ip route | grep default | awk '{print $3}' .

In this example it is . Using the router’s ip address we can choose a static ip address in the range between 1 and 255, which will become the last number of your ip-address, e.g. .

Determine if you want a static ip address over WiFi or Ethernet. The interfaces are called respectively wlan0 and eth0 .

It is very simple to set up your static ethernet address. Simply right-click on the Wi-Fi icon in the menu bar (top-right on the left of the speaker icon) and select the Wireless & Wired Network Settings .

Now click the empty dropdown menu and select the network interface you want to configure. Now for IPv4 Address enter your chosen ip address, for Router the IP address of the router. AS DNS Servers add . When wanting to add multiple DNSs make sure to add them one after another separate by a space. Finally, click the Disable IPv6 option.

One can also set up a static IP-address via the terminal. For this we need to change the dhcpcd.conf file:

Now scroll to the bottom, and add the following text:

replacing the words in capital by what is desired. Now save the file by pressing ctrl+x then y to exit.

When you are using multiple internet interfaces, such as Ethernet over Wifi, it is important to make sure the internet interface has priority over the other such that you get a working internet connection. To do so, we need to add a metric number to each, with the higher metric being prioritised first. Open the dhcpcd.conf file:

And add the metrics. For example:

Now finally reboot your Raspberry Pi for the changes to be incorporated:

Once your raspberry pi has finished restarting, connect to it locally to verify the static IP address hostname -I or ping from it on a networked computer ping YOURSTATICIP .

In many cases you may not want your Raspberry Pi set to use a static IP address. You can change the network configuration back by editing dhcpcd.conf again ( sudo nano /etc/dhcpcd.conf and removing all the lines you added in the previous steps.

Raspberry Pi Documentation

Remote access, introduction to remote access.

Edit this on GitHub

Sometimes you need to access a Raspberry Pi without connecting it to a monitor. Perhaps the Raspberry Pi is embedded in something like a robot, or you may want to view some information from it from elsewhere. Or perhaps you simply don’t have a spare monitor!

You can connect to your Raspberry Pi from another machine. But in order to do so you’ll need to know its IP Address.

Any device connected to a Local Area Network is assigned an IP address. In order to connect to your Raspberry Pi from another machine using SSH or VNC , you need to know the Raspberry Pi’s IP address. This is easy if you have a display connected, and there are a number of methods for finding it remotely from another machine on the network.

How to Find your IP Address

It is possible to find the IP address of your Raspberry Pi without connecting to a screen using one of the following methods:

Router devices list

In a web browser navigate to your router’s IP address e.g. , which is usually printed on a label on your router; this will take you to a control panel. Then log in using your credentials, which is usually also printed on the router or sent to you in the accompanying paperwork. Browse to the list of connected devices or similar (all routers are different), and you should see some devices you recognise. Some devices are detected as PCs, tablets, phones, printers, etc. so you should recognise some and rule them out to figure out which is your Raspberry Pi. Also note the connection type; if your Raspberry Pi is connected with a wire there should be fewer devices to choose from.

Resolving raspberrypi.local with mDNS

On Raspberry Pi OS, multicast DNS is supported out-of-the-box by the Avahi service.

If your device supports mDNS, you can reach your Raspberry Pi by using its hostname and the .local suffix. The default hostname on a fresh Raspberry Pi OS install is raspberrypi , so by default any Raspberry Pi running Raspberry Pi OS responds to:

If the Raspberry Pi is reachable, ping will show its IP address:

If you change the system hostname of the Raspberry Pi (e.g., by editing /etc/hostname ), Avahi will also change the .local mDNS address.

If you don’t remember the hostname of the Raspberry Pi, but have a system with Avahi installed, you can browse all the hosts and services on the LAN with the avahi-browse command.

nmap command

The nmap command (Network Mapper) is a free and open-source tool for network discovery, available for Linux, macOS, and Windows.

To install on Linux , install the nmap package e.g. apt install nmap .

To install on macOS or Windows , see the download page .

To use nmap to scan the devices on your network, you need to know the subnet you are connected to. First find your own IP address, in other words the one of the computer you’re using to find your Raspberry Pi’s IP address:

On Linux , type hostname -I into a terminal window

On macOS , go to System Preferences then Network and select your active network connection to view the IP address

On Windows , go to the Control Panel, then under Network and Sharing Center , click View network connections , select your active network connection and click View status of this connection to view the IP address

Now you have the IP address of your computer, you will scan the whole subnet for other devices. For example, if your IP address is , other devices will be at addresses like , , , etc. The notation of this subnet range is (this covers to ).

Now use the nmap command with the -sn flag (ping scan) on the whole subnet range. This may take a few seconds:

Ping scan just pings all the IP addresses to see if they respond. For each device that responds to the ping, the output shows the hostname and IP address like so:

Here you can see a device with hostname raspberrypi has IP address . Note, to see the hostnames, you must run nmap as root by prepending sudo to the command.

Getting IPv6 addresses by pinging from a second device

First find your own IP address(es), in other words the one of the computer you’re using to find your Raspberry Pi’s IP address by hostname -I

fd00::ba27:ebff:feb6:f293 2001:db8:494:9d01:ba27:ebff:feb6:f293

The example shows two IP addresses. The first one is a so called unique local unicast address( fc00::/7 ). The second one is the global unicast address( 2000::/3 ). It is also possible to see only one of them depending on your network (router) configuration. Both addresses are valid for reaching the Raspberry Pi within your LAN. The address out of 2000::/3 is accessible world wide, provided your router’s firewall is opened.

Now use one of IPs from the first step to ping all local nodes:

-c 2 stands for sending two echo requests

-I with the IP address, it sets the interface and the source address of the echo request, it is necessary to choose the interface’s IP address, eth0 isn’t sufficient - the answer would be the local link address( fe80::/10 ), we need the global or local unicast address

ff02::1 is a well known multicast address for all nodes on the link, so it behaves like a local broadcast, usually it is defined in /etc/hosts so you can also use the name ( ip6-allnodes or ipv6-allnodes ) instead of the literal address

Some newer systems expect the interface ID behind the multicast address.

This should result in replies from all the nodes on your (W)LAN link, with associated DNS names.

Exclude your own IP( here 2001:db8:494:9d01:ba27:ebff:feb6:f293 ), then check the others by trying to connect them via SSH.

Getting the IP address of a Raspberry Pi using your smartphone

The Fing app is a free network scanner for smartphones. It is available for Android and iOS .

Your phone and your Raspberry Pi have to be on the same network, so connect your phone to the correct wireless network.

When you open the Fing app, touch the refresh button in the upper right-hand corner of the screen. After a few seconds you will get a list with all the devices connected to your network. Scroll down to the entry with the manufacturer "Raspberry Pi". You will see the IP address in the bottom left-hand corner, and the MAC address in the bottom right-hand corner of the entry.

Setting up an SSH Server

You can access the command line of a Raspberry Pi remotely from another computer or device on the same network using the Secure Shell (SSH) protocol.

You will only have access to the command line, not the full desktop environment. For a full remote desktop, see VNC .

Set up your Local Network

Make sure your Raspberry Pi is properly set up and connected. If you are using wireless networking, this can be enabled via the desktop user interface, or using from the command line. If you are not using wireless connectivity, plug your Raspberry Pi directly into the router.

Enabling the Server

Raspberry Pi OS has the SSH server disabled by default. It can be enabled manually from the desktop:

Launch Raspberry Pi Configuration from the Preferences menu

Navigate to the Interfaces tab

Select Enabled next to SSH

Alternatively you can enable it from the terminal using the raspi-config application,

Enter sudo raspi-config in a terminal window

Select Interfacing Options

Navigate to and select SSH

Choose Finish

Secure Shell from Linux or Mac OS

You can use SSH to connect to your Raspberry Pi from a Linux desktop, another Raspberry Pi, or from an Apple Mac without installing additional software.

Open a terminal window on your computer replacing <IP> with the IP address of the Raspberry Pi you’re trying to connect to,

When the connection works you will see a security/authenticity warning. Type yes to continue. You will only see this warning the first time you connect.

Next you will be prompted for the password for the pi login: the default password on Raspberry Pi OS is raspberry .

For security reasons it is highly recommended to change the default password on the Raspberry Pi (also, you can not login through ssh if the password is blank). You should now be able to see the Raspberry Pi prompt, which will be identical to the one found on the Raspberry Pi itself.

If you have set up another user on the Raspberry Pi, you can connect to it in the same way, replacing the username with your own, e.g. [email protected]

You are now connected to the Raspberry Pi remotely, and can execute commands.

Forwarding X11

You can also forward your X session over SSH, to allow the use of graphical applications, by using the -Y flag:

Now you are on the command line as before, but you have the ability to open up graphical windows. For example, typing:

will open up the Geany editor in a window on your local desktop.

Secure Shell from Windows 10

You can use SSH to connect to your Raspberry Pi from a Windows 10 computer that is using October 2018 Update or later without having to use third-party clients.

Passwordless SSH Access

It is possible to configure your Raspberry Pi to allow access from another computer without needing to provide a password each time you connect. To do this, you need to use an SSH key instead of a password. To generate an SSH key:

Checking for Existing SSH Keys

First, check whether there are already keys on the computer you are using to connect to the Raspberry Pi:

If you see files named or then you have keys set up already, so you can skip the 'Generate new SSH keys' step below.

Generate new SSH Keys

To generate new SSH keys enter the following command:

Upon entering this command, you will be asked where to save the key. We suggest saving it in the default location ( ~/.ssh/id_rsa ) by pressing Enter .

You will also be asked to enter a passphrase, which is optional. The passphrase is used to encrypt the private SSH key, so that if someone else copied the key, they could not impersonate you to gain access. If you choose to use a passphrase, type it here and press Enter , then type it again when prompted. Leave the field empty for no passphrase.

Now look inside your .ssh directory:

and you should see the files id_rsa and :

The id_rsa file is your private key. Keep this on your computer.

The file is your public key. This is what you share with machines that you connect to: in this case your Raspberry Pi. When the machine you try to connect to matches up your public and private key, it will allow you to connect.

Take a look at your public key to see what it looks like:

It should be in the form:

Copy your Key to your Raspberry Pi

Using the computer which you will be connecting from, append the public key to your authorized_keys file on the Raspberry Pi by sending it over SSH:

Alternatively, if ssh-copy-id is not available on your system, you can copy the file manually over SSH:

If you see the message ssh: connect to host <IP-ADDRESS> port 22: Connection refused and you know the IP-ADDRESS is correct, then you may not have enabled SSH on your Raspberry Pi. Run sudo raspi-config in the Raspberry Pi’s terminal window, enable SSH, then try to copy the files again.

Now try ssh <USER>@<IP-ADDRESS> and you should connect without a password prompt.

If you see a message "Agent admitted failure to sign using the key" then add your RSA or DSA identities to the authentication agent ssh-agent then execute the following command:

Adjust Directory Permissions

If you can’t establish a connection after following the steps above there might be a problem with your directory permissions. First, you want to check the logs for any errors:

If the log says Authentication refused: bad ownership or modes for directory /home/pi there is a permission problem regarding your home directory. SSH needs your home and ~/.ssh directory to not have group write access. You can adjust the permissions using chmod :

Now only the user itself has access to .ssh and .ssh/authorized_keys in which the public keys of your remote machines are stored.

Storing the passphrase in the macOS keychain

If you are using macOS, and after verifying that your new key allows you to connect, you have the option of storing the passphrase for your key in the macOS keychain. This allows you to connect to your Raspberry Pi without entering the passphrase.

Run the following command to store it in your keychain:

Using Secure Copy

Secure Copy ( scp ) is a command for sending files over SSH. This means you can copy files between computers, say from your Raspberry Pi to your desktop or laptop, or vice-versa.

First of all, you’ll need to know your Raspberry Pi’s IP address .

Copying Files to your Raspberry Pi

Copy the file myfile.txt from your computer to the pi user’s home folder of your Raspberry Pi at the IP address with the following command:

Copy the file to the /home/pi/project/ directory on your Raspberry Pi (the project folder must already exist):

Copying Files from your Raspberry Pi

Copy the file myfile.txt from your Raspberry Pi to the current directory on your other computer:

Copying Multiple Files

Copy multiple files by separating them with spaces:

Alternatively, use a wildcard to copy all files matching a particular search with:

(all files ending in .txt )

(all files starting with m )

(all files starting with m and ending in .txt )

Copying a Whole Directory

Copy the directory project/ from your computer to the pi user’s home folder of your Raspberry Pi at the IP address with the following command:

Using rsync

You can use the tool rsync to synchronise folders between computers. You might want to transfer some files from your desktop computer or laptop to your Raspberry Pi, for example, and for them to be kept up to date, or you might want the pictures taken by your Raspberry Pi transferred to your computer automatically.

Using rsync over SSH allows you to transfer files to your computer automatically.

Here is an example of how to set up the sync of a folder of pictures on your Raspberry Pi to your computer:

On your computer, create a folder called camera :

Look up the Raspberry Pi’s IP address by logging in to it and running hostname -I . In this example, the Raspberry Pi is creating a timelapse by capturing a photo every minute, and saving the picture with a timestamp in the local folder camera on its SD card.

Now run the following command (substituting your own Raspberry Pi’s IP address):

This will copy all files from the Raspberry Pi’s camera folder to your computer’s new camera folder.

Network File System (NFS)

Network File System (NFS) allows you to share a directory located on one networked computer with other computers or devices on the same network. The computer where the directory is located is called the server , and computers or devices connecting to that server are called clients. Clients usually mount the shared directory to make it a part of their own directory structure. The shared directory is an example of a shared resource or network share.

For smaller networks, an NFS is perfect for creating a simple NAS (Network-attached storage) in a Linux/Unix environment.

An NFS is perhaps best suited to more permanent network-mounted directories, such as /home directories or regularly-accessed shared resources. If you want a network share that guest users can easily connect to, Samba is better suited to the task. This is because tools to temporarily mount and detach from Samba shares are more readily available across old and proprietary operating systems.

Before deploying an NFS, you should be familiar with:

Linux file and directory permissions

mounting and unmounting filesystems

Setting up a Basic NFS Server

Install the packages required using the command below:

For easier maintenance, we will isolate all NFS exports in single directory, into which the real directories will be mounted with the --bind option.

Suppose we want to export our users' home directories, which are in /home/users . First we create the export filesystem:

Note that /export and /export/users will need 777 permissions, as we will be accessing the NFS share from the client without LDAP/NIS authentication. This will not apply if using authentication (see below). Now mount the real users directory with:

To save us from retyping this after every reboot, we add the following line to /etc/fstab :

There are three configuration files that relate to an NFS server:




The only important option in /etc/default/nfs-kernel-server for now is NEED_SVCGSSD . It is set to "no" by default, which is fine, because we are not activating NFSv4 security this time.

In order for the ID names to be automatically mapped, the file /etc/idmapd.conf must exist on both the client and the server with the same contents and with the correct domain names. Furthermore, this file should have the following lines in the Mapping section:

However, note that the client may have different requirements for the Nobody-User and Nobody-Group. For example, on RedHat variants, it is nfsnobody for both. If you’re not sure, check via the following commands to see if nobody and nogroup are there:

This way, server and client do not need the users to share same UID/GUID. For those who use LDAP-based authentication, add the following lines to the idmapd.conf of your clients:

This will cause idmapd to know to look at nsswitch.conf to determine where it should look for credential information. If you have LDAP authentication already working, nsswitch shouldn’t require further explanation.

To export our directories to a local network , we add the following two lines to /etc/exports :

Portmap lockdown (optional)

The files on your NFS are open to anyone on the network. As a security measure, you can restrict access to specified clients.

Add the following line to /etc/hosts.deny :

By blocking all clients first, only clients in /etc/hosts.allow (added below) will be allowed to access the server.

Now add the following line to /etc/hosts.allow :

where <list of IPv4s> is a list of the IP addresses of the server and all clients. (These have to be IP addresses because of a limitation in rpcbind , which doesn’t like hostnames.) Note that if you have NIS set up, you can just add these to the same line.

Please ensure that the list of authorised IP addresses includes the localhost address ( ), as the startup scripts in recent versions of Ubuntu use the rpcinfo command to discover NFSv3 support, and this will be disabled if localhost is unable to connect.

Finally, to make your changes take effect, restart the service:

Configuring an NFS Client

Now that your server is running, you need to set up any clients to be able to access it. To start, install the required packages:

On the client, we can mount the complete export tree with one command:

You can also specify the NFS server hostname instead of its IP address, but in this case you need to ensure that the hostname can be resolved to an IP on the client side. A robust way of ensuring that this will always resolve is to use the /etc/hosts file.

Note that <nfs-server-IP>:/export is not necessary in NFSv4, as it was in NFSv3. The root export :/ defaults to export with fsid=0 .

We can also mount an exported subtree with:

To ensure this is mounted on every reboot, add the following line to /etc/fstab :

If, after mounting, the entry in /proc/mounts appears as <nfs-server-IP>:// (with two slashes), then you might need to specify two slashes in /etc/fstab , or else umount might complain that it cannot find the mount.

where <NFS server IP address> is the IP address of the server.

A More Complex NFS Server

NFS user permissions are based on user ID (UID). UIDs of any users on the client must match those on the server in order for the users to have access. The typical ways of doing this are:

Manual password file synchronisation

Use of LDAP

Note that you have to be careful on systems where the main user has root access: that user can change UIDs on the system to allow themselves access to anyone’s files. This page assumes that the administrative team is the only group with root access and that they are all trusted. Anything else represents a more advanced configuration, and will not be addressed here.

Group permissions

A user’s file access is determined by their membership of groups on the client, not on the server. However, there is an important limitation: a maximum of 16 groups are passed from the client to the server, and if a user is member of more than 16 groups on the client, some files or directories might be unexpectedly inaccessible.

DNS (optional, only if using DNS)

Add any client name and IP addresses to /etc/hosts . (The IP address of the server should already be there.) This ensures that NFS will still work even if DNS goes down. Alternatively you can rely on DNS if you want - it’s up to you.

NIS (optional, only if using NIS)

This applies to clients using NIS. Otherwise you can’t use netgroups, and should specify individual IPs or hostnames in /etc/exports . Read the BUGS section in man netgroup for more information.

First, edit /etc/netgroup and add a line to classify your clients (this step is not necessary, but is for convenience):

where myclients is the netgroup name.

Next run this command to rebuild the NIS database:

The filename yp refers to Yellow Pages, the former name of NIS.

Consider adding the following line to /etc/hosts.allow :

where <list of IPs> is a list of the IP addresses of the server and all clients. These have to be IP addresses because of a limitation in rpcbind . Note that if you have NIS set up, you can just add these to the same line.

Package installation and configuration

Install the necessary packages:

Edit /etc/exports and add the shares:

The example above shares /home and /usr/local to all clients in the myclients netgroup.

The example above shares /home and /usr/local to two clients with static IP addresses. If you want instead to allow access to all clients in the private network falling within a designated IP address range, consider the following:

Here, rw makes the share read/write, and sync requires the server to only reply to requests once any changes have been flushed to disk. This is the safest option; async is faster, but dangerous. It is strongly recommended that you read man exports if you are considering other options.

After setting up /etc/exports , export the shares:

You’ll want to run this command whenever /etc/exports is modified.

Restart services

By default, rpcbind only binds to the loopback interface. To enable access to rpcbind from remote machines, you need to change /etc/conf.d/rpcbind to get rid of either -l or -i .

If any changes are made, rpcbind and NFS will need to be restarted:

Security items to consider

Aside from the UID issues discussed above, it should be noted that an attacker could potentially masquerade as a machine that is allowed to map the share, which allows them to create arbitrary UIDs to access your files. One potential solution to this is IPSec. You can set up all your domain members to talk to each other only over IPSec, which will effectively authenticate that your client is who it says it is.

IPSec works by encrypting traffic to the server with the server’s public key, and the server sends back all replies encrypted with the client’s public key. The traffic is decrypted with the respective private keys. If the client doesn’t have the keys that it is supposed to have, it can’t send or receive data.

An alternative to IPSec is physically separate networks. This requires a separate network switch and separate Ethernet cards, and physical security of that network.


Mounting an NFS share inside an encrypted home directory will only work after you are successfully logged in and your home is decrypted. This means that using /etc/fstab to mount NFS shares on boot will not work, because your home has not been decrypted at the time of mounting. There is a simple way around this using symbolic links:

Create an alternative directory to mount the NFS shares in:

Edit /etc/fstab to mount the NFS share into that directory instead:

Create a symbolic link inside your home, pointing to the actual mount location. For example, and in this case deleting the Music directory already existing there first:

Samba (SMB/CIFS)

Samba is an implementation of the SMB/CIFS networking protocol that is used by Microsoft Windows devices to provide shared access to files, printers, and serial ports.

You can use Samba to mount a folder shared from a Windows machine so it appears on your Raspberry Pi, or to share a folder from your Raspberry Pi so it can be accessed by your Windows machine.

Installing Samba Support

By default, Raspberry Pi OS does not include CIFS/Samba support, but this can be added. The following commands will install all the required components for using Samba as a server or a client.

Mount a Folder Shared from Windows

First, you need to share a folder on your Windows device. This is quite a convoluted process!

Turn on sharing

Open the Networking and Sharing Centre by right-clicking on the system tray and selecting it

Click on Change advanced sharing settings

Select Turn on network discovery

Select Turn on file and printer sharing

Save changes

Share the folder

You can share any folder you want, but for this example, simply create a folder called share .

Create the folder share on your desktop.

Right-click on the new folder, and select Properties .

Click on the Sharing tab, and then the Advanced Sharing button

Select Share this folder ; by default, the share name is the name of the folder

Click on the Permissions button

For this example, select Everyone and Full Control (you can limit access to specific users if required); click OK when done, then OK again to leave the Advanced Sharing page

Click on the Security tab, as we now need to configure the same permissions

Select the same settings as the Permissions tab, adding the chosen user if necessary

The folder should now be shared.

Windows 10 Sharing Wizard

On Windows 10 there is a Sharing Wizard that helps with some of these steps.

Run the Computer Management application from the Start Bar

Select Shared Folders , then Shares

Right-click and select New Share , which will start up the Sharing Wizard; click Next

Select the folder you wish to share, and click Next

Click Next to use all the sharing defaults

Select Custom and set the required permissions, and click OK , then Finish

Mount the folder on the Raspberry Pi

Mounting in Linux is the process of attaching a folder to a location, so firstly we need that location.

Now, we need to mount the remote folder to that location. The remote folder is the host name or IP address of the Windows PC, and the share name used when sharing it. We also need to provide the Windows username that will be used to access the remote machine.

You should now be able to view the content of the Windows share on your Raspberry Pi.

"Host is down" error

This error is caused by a combination of two things: A SMB protocol version mismatch, and the CIFS client on Linux returning a misleading error message. In order to fix this a version entry needs to be added to the mount command. By default Raspberry Pi OS will only use versions 2.1 and above, which are compatible with Windows 7 and later. Older devices, including some NAS, may require version 1.0:

You may need to try different versions to match up with the server version. Possible values are:

Sharing a Folder from your Raspberry Pi

Firstly, create a folder to share. This example creates a folder called shared in the home folder of the current user, and assumes the current user is pi .

Now we need to tell Samba that there is a pi user when accessing that folder. When asked, enter the password of the pi user - this can be the default password, but that is well known and should be changed for better security.

Now we need to tell Samba to share this folder, using the Samba configuration file.

At the end of the file, add the following to share the folder, giving the remote user read/write permissions:

In the same file, find the workgroup line, and if necessary, change it to the name of the workgroup of your local Windows network.

That should be enough to share the folder. On your Windows device, when you browse the network, the folder should appear and you should be able to connect to it.

Virtual Network Computing (VNC)

Sometimes it is not convenient to work directly on the Raspberry Pi. Maybe you would like to work on it from another device by remote control.

VNC is a graphical desktop sharing system that allows you to remotely control the desktop interface of one computer (running VNC Server) from another computer or mobile device (running VNC Viewer). VNC Viewer transmits the keyboard and either mouse or touch events to VNC Server, and receives updates to the screen in return.

You will see the desktop of the Raspberry Pi inside a window on your computer or mobile device. You’ll be able to control it as though you were working on the Raspberry Pi itself.

VNC Connect from RealVNC is included with Raspberry Pi OS. It consists of both VNC Server, which allows you to control your Raspberry Pi remotely, and VNC Viewer, which allows you to control desktop computers remotely from your Raspberry Pi should you want to.

You must enable VNC Server before you can use it. By default, VNC Server gives you remote access to the graphical desktop that is running on your Raspberry Pi, as though you were sitting in front of it.

However, you can also use VNC Server to gain graphical remote access to your Raspberry Pi if it is headless or not running a graphical desktop. For more information on this, see Creating a virtual desktop , further below.

Installing VNC on Raspberry Pi

VNC is already installed on the full Raspberry Pi OS image, and can be installed via Recommended Software from the Preferences menu on other versions.

If you are not using a desktop you can install it from the command line as follows:

Enabling the VNC Server

You can do this graphically or at the command line.

Enabling VNC Server graphically

On your Raspberry Pi, boot into the graphical desktop.

Select Menu   › Preferences   › Raspberry Pi Configuration   › Interfaces .

Ensure VNC is Enabled .

Enabling VNC Server at the command line

You can enable VNC Server at the command line using raspi-config :

Now, enable VNC Server by doing the following:

Navigate to Interfacing Options .

Scroll down and select VNC   › Yes .

Connecting to your Raspberry Pi

There are two ways to connect to your Raspberry Pi. You can use either or both, depending on what works best for you.

Establishing a direct connection

Direct connections are quick and simple providing you’re joined to the same private local network as your Raspberry Pi. For example, this might be a wired or wireless network at home, at school, or in the office.

On your Raspberry Pi (using a terminal window or via SSH) use these instructions or run ifconfig to discover your private IP address.

On the device you’ll use to take control, download VNC Viewer. For best results, use the compatible app from RealVNC.

Enter your Raspberry Pi’s private IP address into VNC Viewer:

Establishing a cloud connection

You are entitled to use RealVNC’s cloud service for free, provided that remote access is for educational or non-commercial purposes only.

Cloud connections are convenient and encrypted end-to-end. They are highly recommended for connecting to your Raspberry Pi over the internet. There’s no firewall or router reconfiguration, and you don’t need to know the IP address of your Raspberry Pi, or provide a static one.

Sign up for a RealVNC account here: it’s free and it only takes a few seconds.

On your Raspberry Pi, sign in to VNC Server using your new RealVNC account credentials:

On the device you’ll use to take control, download VNC Viewer. You must use the compatible app from RealVNC.

Sign in to VNC Viewer using the same RealVNC account credentials, and then either tap or click to connect to your Raspberry Pi:

Authenticating to VNC Server

To complete either a direct or cloud connection, you must authenticate to VNC Server.

If you’re connecting from the compatible VNC Viewer app from RealVNC, enter the user name and password you normally use to log in to your user account on the Raspberry Pi. By default, these credentials are pi and raspberry .

If you’re connecting from a non-RealVNC Viewer app, you’ll first need to downgrade VNC Server’s authentication scheme, specify a password unique to VNC Server, and then enter that instead.

If you are in front of your Raspberry Pi and can see its screen, open the VNC Server dialog on your Raspberry Pi, select Menu   › Options   › Security , and choose VNC password from the Authentication dropdown.

Or if you’re configuring your Raspberry Pi remotely from the command line, then to make the changes for Service Mode (the default configuration for the Raspberry Pi):

Open the /root/.vnc/config.d/vncserver-x11 config file.

Replace Authentication=SystemAuth with Authentication=VncAuth and save the file.

In the command line, run sudo vncpasswd -service . This will prompt you to set a password, and will insert it for you in the right config file for VNC Server running in Service Mode.

Restart VNC Server.

Using Directly Rendered Applications

You can remotely access apps which use a directly rendered overlay such as; the text console, the Raspberry Pi Camera Module, and others.

To turn this feature on:

On your Raspberry Pi, open the VNC Server dialog.

Navigate to Menu   › Options   › Troubleshooting and select Enable experimental direct capture mode .

On the device you’ll use to take control, run VNC Viewer and connect.

Please note that direct screen capture is an experimental feature. If you’re connecting from a desktop computer and mouse movements seem erratic, try pressing F8 to open the VNC Viewer shortcut menu and selecting Relative Pointer Motion .

Creating a Virtual Desktop

If your Raspberry Pi is headless (i.e. not plugged into a monitor) or controlling a robot, it is unlikely to be running a graphical desktop.

VNC Server can create a virtual desktop for you, giving you graphical remote access on demand. This virtual desktop exists only in your Raspberry Pi’s memory:

To create and connect to a virtual desktop:

On your Raspberry Pi (using Terminal or via SSH), run vncserver . Make note of the IP address/display number that VNC Server will print to your Terminal (e.g. ).

On the device you’ll use to take control, enter this information into VNC Viewer .

To destroy a virtual desktop, run the following command:

This will also stop any existing connections to this virtual desktop.

Setting up an Apache Web Server

Apache is a popular web server application you can install on the Raspberry Pi to allow it to serve web pages.

On its own, Apache can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP.

Installing Apache

First, update the available packages by typing the following command into the Terminal:

Then, install the apache2 package with this command:

Test the Web Server

By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Raspberry Pi itself, or (whatever the Raspberry Pi’s IP address is) from another computer on the network. To find the Raspberry Pi’s IP address, type hostname -I at the command line (or read more about finding your IP address ).

Browse to the default web page either on the Raspberry Pi or from another computer on the network and you should see the following:

Apache success message

This means you have Apache working!

Changing the Default Web Page

This default web page is just an HTML file on the filesystem. It is located at /var/www/html/index.html .

Navigate to this directory in a terminal window and have a look at what’s inside:

This will show you:

This shows that by default there is one file in /var/www/html/ called index.html and it is owned by the root user (as is the enclosing folder). In order to edit the file, you need to change its ownership to your own username. Change the owner of the file (the default pi user is assumed here) using sudo chown pi: index.html .

You can now try editing this file and then refreshing the browser to see the web page change. If you know HTML you can put your own HTML files and other assets in this directory and serve them as a website on your local network.

Installing PHP for Apache

To allow your Apache server to process PHP files, you’ll need to install the latest version of PHP and the PHP module for Apache. Type the following command to install these:

Now remove the index.html file:

and create the file index.php :

Put some PHP content in it:

Now save and refresh your browser. You should see "hello world". This is not dynamic but still served by PHP. Try something dynamic:

or show your PHP info:

Network boot your Raspberry Pi

You can set up a DHCP/TFTP server which will allow you to boot a Raspberry Pi 3 or 4 from the network.

The instructions assume that you have an existing home network, and that you want to use a Raspberry Pi for the server . You will also need an additional Raspberry Pi 3 or 4 as a client to be booted. Only one SD Card is needed because the client will be booted from the server after the initial client configuration.

Client Configuration

Raspberry pi 3 model b.

Before the Raspberry Pi 3 Model B will network boot it needs to be booted from an SD Card with a config option to enable USB boot mode. This will set a bit in the OTP (One Time Programmable) memory in the Raspberry Pi SoC that enables network booting. Once this is done, the Raspberry Pi 3B will attempt to boot from USB, and from the network, if it cannot boot from the SD card.

Install Raspberry Pi OS Lite, or Raspberry Pi OS with desktop, on the SD card in the usual fashion. Next, enable USB boot mode with the following command:

This adds program_usb_boot_mode=1 to the end of /boot/config.txt . Reboot the Raspberry Pi with sudo reboot . Once the client Raspberry Pi has rebooted, check that the OTP has been programmed with:

Ensure the output 0x3020000a is correct.

The client configuration is almost done. The final thing to do is to remove the program_usb_boot_mode line from config.txt . You can do this with sudo nano /boot/config.txt , for example. Finally, shut the client Raspberry Pi down with sudo poweroff .

Raspberry Pi 4 Model B

Network boot can be enabled on the Raspberry Pi 4 using the raspi-config tool. First, run raspi-config as follows:

Within raspi-config , choose Advanced Options , then Boot Order , then Network Boot . You must then reboot the device for the change to the boot order to be programmed into the bootloader EEPROM. Once the Raspberry Pi has rebooted, check that the boot order is now 0xf21 :

For further details of configuring the Raspberry Pi 4 bootloader, see Raspberry Pi 4 Bootloader Configuration .

Ethernet MAC address

Before configuring network boot, make a note of the serial number and mac address so that the board can be identified by the TFTP/DHCP server.

On Raspberry Pi 4 the MAC address is programmed at manufacture and there is no link between the MAC address and serial number. Both the MAC address and serial numbers are displayed on the bootloader HDMI diagnostics screen.

To find the Ethernet MAC address:

To find the serial number:

Server Configuration

Plug the SD card into the server Raspberry Pi, and then boot the server. The client Raspberry Pi will need a root file system to boot from: we will use a copy of the server’s root filesystem and place it in /nfs/client1 :

Regenerate SSH host keys on the client filesystem by chrooting into it:

Find the settings of your local network. You need to find the address of your router (or gateway), which can be done with:

which should give an output like:

The first address is the IP address of your server Raspberry Pi on the network, and the part after the slash is the network size. It is highly likely that yours will be a /24 . Also note the brd (broadcast) address of the network. Note down the output of the previous command, which will contain the IP address of the Raspberry Pi and the broadcast address of the network.

Finally, note down the address of your DNS server, which is the same address as your gateway. You can find this with:

Configure a static network address on your server Raspberry Pi via the systemd networking, which works as the network handler and DHCP server.

To do that, you’ll need to create a 10-eth0.netdev and a like so:

Add the following lines:

Then create a network file:

Add the following contents:

At this point, you will not have working DNS, so you will need to add the server you noted down before to systemd/resolved.conf . In this example, the gateway address is

Uncomment the DNS line and add the DNS IP address there. Additionally, if you have a fallback DNS server, add it there as well.

Enable systemd-networkd and then reboot for the changes to take effect:

Now start tcpdump so you can search for DHCP packets from the client Raspberry Pi:

Connect the client Raspberry Pi to your network and power it on. Check that the LEDs illuminate on the client after around 10 seconds, then you should get a packet from the client "DHCP/BOOTP, Request from …​"

Now you need to modify the dnsmasq configuration to enable DHCP to reply to the device. Press CTRL + C to exit the tcpdump program, then type the following:

Then replace the contents of dnsmasq.conf with:

Where the first address of the dhcp-range line is, use the broadcast address you noted down earlier.

Now create a /tftpboot directory:

Now monitor the dnsmasq log:

You should see something like this:

Next, you will need to copy the contents of the boot folder into the /tftpboot directory.

First, press CTRL + C to exit the monitoring state. Then type the following:

Since the tftp location has changed, restart dnsmasq :

Set up NFS root

This should now allow your Raspberry Pi client to attempt to boot through until it tries to load a root file system (which it doesn’t have).

At this point, export the /nfs/client1 file system created earlier, and the TFTP boot folder.

Restart RPC-Bind and the NFS server in order to have them detect the new files.

Edit /tftpboot/cmdline.txt and from root= onwards, and replace it with:

You should substitute the IP address here with the IP address you have noted down. Also remove any part of the command line starting with init=.

Finally, edit /nfs/client1/etc/fstab and remove the /dev/mmcblk0p1 and p2 lines (only proc should be left). Then, add the boot partition back in:

Good luck! If it doesn’t boot on the first attempt, keep trying. It can take a minute or so for the Raspberry Pi to boot, so be patient.

Using pxetools

We have created a Python script that is used internally to quickly set up Raspberry Pis that will network boot.

The script takes a serial number, which you can find in cat /proc/cpuinfo , an owner name and the name of the Raspberry Pi. It then creates a root filesystem for that Raspberry Pi from a Raspberry Pi OS image. There is also a --list option which will print out the IP address of the Raspberry Pi, and a --remove option.

When prompted about saving iptables rules, say no .

The prepare_pxetools script should prepare everything you need to use pxetools .

We found that we needed to restart the nfs server after using pxetools for the first time. Do this with:

Then plug in your Raspberry Pi and it should boot!

Network booting using IPv6

There are 4 stages to booting a Raspberry Pi computer over the network:

The bootloader negotiates to get an IP address and the details of a TFTP server using DHCP.

The bootloader loads the firmware via TFTP and hands over the boot process to the firmware, passing it the details of the network.

The firmware loads the kernel and command line via TFTP.

The kernel boots the rest of the system, loading the root filesystem (rootfs) via NFS or some other mechanism.

The bootloader and firmware (stages 1 to 3) have been enhanced to support booting over IPv6.

How it works

To boot via IPv6 you need an updated version of the firmware (e.g. start4.elf ) and the bootloader. Using the Bullseye release of Raspberry Pi OS and the latest stable bootloader should be sufficient.

To mount rootfs over the network the IPv4 netboot tutorial suggests using nfsroot . This doesn’t support IPv6, so another method is needed to mount rootfs over the network.

If your ISP and router don’t support IPv6 you will be limited in what you can do.

Network addresses

The first thing the bootloader does is send a router solicitation to get the details of the network. The router responds with an advertisement packet identifying its ethernet address, which the bootloader might need if the TFTP server is on a different network.

The router advertisement includes a flag which tells it whether to use stateful (managed) or stateless (unmanaged) configuration for its IP address. Stateless configuration means that the device configures its own IP address. Currently the bootloader generates an address derived from its ethernet MAC address and a network prefix supplied by the router.

If the router indicates that stateful configuration is enabled DHCP is used to obtain the IP address of the device. This involves the device sending a solicitation request to a DHCP server which responds with an advertisement. The client then requests the address before getting a reply acknowledgement from the server.

DHCP Servers and clients identify themselves with variable length DUID (Device Unique ID). On the Raspberry Pi this is derived from the MAC address (DUID_LL).

TFTP address

Whether using stateless or stateful configuration, the DHCP server is used to obtain the TFTP server address. This is encoded in the BOOTFILE-URL parameter. We send the client architecture type value 0x29 to identify a device.

See RFC 5970 and the IANA Dynamic Host Configuration Protocol for IPv6 documentation.

Boot process

The device should now have an IP address and TFTP details. It downloads the firmware binary start4.elf from the TFTP server and continues running with this. The firmware is passed the IP address and TFTP server details so it can download the kernel and boot the rest of the system.

Kernel Boot

With IPv4 netboot, nfsroot is used to mount rootfs over the network. This doesn’t support IPv6 so another solution is required. It might involve a small RAM file system that can mount the appropriate network location before switching to the proper rootfs contents.

If you want to try this out you will need another Raspberry Pi to act as the TFTP and DHCP server.

The TFTP server can in theory be on any routable network but the DHCP server has to be on the same network as the devices it will serve.

TFTP Server

If you have a working IPv4 network boot setup you can reuse the TFTP server in dnsmasq to supply the files (it can talk to both IPv4 and IPv6).

Alternatively you can use a standalone TFTP server like tftpd-hpa .

DHCP Server

DHCP in IPv6 has changed a lot. We need DHCP to at least tell us the address of the TFTP server, which in this case is the same machine.

Modify the configuration in /etc/default/isc-dhcp-server

In /etc/dhcp/dhcpd6.conf you need to specify the TFTP server address and setup a subnet. Here the DHCP server is configured to supply some made up unique local addresses (ULA). The host test-rpi4 line tells DHCP to give a test device a fixed address.

Your server has to be assigned the IPv6 address in /etc/dhcpcd.conf

Now start the DHCP server.

Modify the configuration to tell it to attempt network boot via IPv6 rather than IPv4.

To revert to IPv4 network boot just remove the USE_IPV6 line from boot.conf .

To use IPv6 you really need a router and ISP that supports IPv6. There are sites on the internet that can check this for you or alternatively run the following command.

This sends a router solicitation to your router asking for your network details such as the network prefix, router ethernet address and whether to use DHCP for addressing. If there’s no response to this command it’s likely your network and ISP only supports IPv4. If IPv6 is supported it’s most likely that it will be configured to use stateless configuration where clients generate their own addresses.

You might be able to configure your router for stateful configuration, which means it will use DHCP to obtain an IP address.

Logs and Traces

If the boot uart is enabled you should see something like this from the serial port. The lines starting RX6 indicate that IPv6 is in use.

Here dc:a6:32:6f:73:f4 is the MAC address of the TFTP server and it has an IPv6 address of fd49:869:6f93::1 . The device itself has a MAC address e4:5f:01:20:24:0b and an IPv6 address of fd49:869:6f93::1000

Finally the bootloader hands over to firmware which should load the kernel.

Stateful configuration

You can examine network activity with tcpdump.

Below is an extract of a TCP dump where the router is configured to use stateful (DHCP) network configuration.

Device sends a router solicitation.

Router sends a response telling the device to use stateful configuration.

Device sends a DHCP solicitation.

The DHCP server replies with an advertisement.

The device sends a request for an address and TFTP details to the DHCP server.

The DHCP server replies, opt_59 is used to pass the address of the TFTP server.

The device sends a neighbour solicitation to the FTP server because it needs its MAC address.

The FTP server replies with its MAC address.

TFTP requests are made by the device which should now boot over the network.

Stateless configuration

Below is an extract of a tcp dump for a stateless (non-DHCP) network configuration.

The device sends a router solicitation.

The router replies with the network details.

The device sends an information request to the DHCP multicast address asking for the TFTP details.

The DHCP server replies with the TFTP server details ( opt_59 ).

The device asks for the TFTP server MAC address since it can tell it’s on the same network.

The device starts making TFTP requests.

Raspberry Pi documentation is copyright © 2012-2023 Raspberry Pi Ltd and is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA) licence.

Some content originates from the eLinux wiki , and is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported licence.

The terms HDMI, HDMI High-Definition Multimedia Interface, HDMI trade dress and the HDMI Logos are trademarks or registered trademarks of HDMI Licensing Administrator, Inc

change ip raspberry pi

How to configure an IP address on Raspberry Pi

Last updated on October 7, 2020 by Kristophorus Hadiono

The default Raspbian system for Raspberry Pi is set up to get an IP address automatically from the network via DHCP, whether for wired Ethernet or wireless WiFi (via a USB wireless dongle). Raspbian can support both IPv4 and IPv6. IPv4 is ready for use by default, while IPv6 must be enabled manually.

If you want to set up an IP address for wired or wireless networks on a Raspbian system, there are several ways to do it, either in the text (manual) mode or via GUI tools.

In this tutorial, I will explain several ways to configure an IP address on Raspbian-powered Raspberry Pi . IPv4 will be used in this tutorial.

Wifi-Config: Configure an Automatic DHCP Ip Address on WiFi Network

If you want to connect Raspberry Pi to a WiFi access point, you can use a USB wireless network dongle. If you plan to buy one, it is recommended to check which wireless chipset will work with Raspberry Pi before you buy. Otherwise, you may be frustrated trying to figure out how to install a necessary driver on Raspberry Pi. Refer to this page for a list of RPi-compatible USB Wi-Fi adapters.

To get an IP address for a USB WiFi dongle, follow the instructions below. Here I use Ralink USB WiFi dongle with RT5370 chipset. This chipset is recognized by Raspbian automatically.

After plugging in your USB WiFi dongle, power up Raspberry Pi.

Log in to Raspberry Pi, and launch GUI desktop by typing:

Double-click on WiFi Config icon on the desktop.

change ip raspberry pi

This will give you a wpa_gui window (see picture below).

change ip raspberry pi

Click on Scan button to open the following scan result window.

change ip raspberry pi

Click on Scan button on this window to get a list of available WiFi access points.

change ip raspberry pi

Double-click on the SSID of the access point to connect to, and then type in access password (if required).

change ip raspberry pi

Click on Add button to permanently add the configured access point to Manage Networks tab.

change ip raspberry pi

When done, click on Current Status tab, and then click on Connect button to connect the access point. It will take a couple of seconds until you get an IP address from DHCP negotiation.

change ip raspberry pi

After you get an IP address, you can close the wpa_gui window. You can still check the current status of wireless connection from desktop tray icon as shown below.

change ip raspberry pi

Text Mode: Configure a Static IP Address for Wired Ethernet

To configure Raspbian with a static IP address manually for the Ethernet, follow the instructions below.

Make sure that you plug in everything right (keyboard, HDMI monitor/TV, SD card, power cable adapter), and then turn on the power.

Wait until you are prompted to log in, and type pi for username and raspberry for password (which are default Raspbian login credentials).

A Raspbian's network configuration file is located at /etc/network/interfaces . A default configuration looks like the following, where DHCP is used for wired Ethernet.

Edit this config file with any text editor as follows. The bold font texts are newly updated configuration.

In the updated config file, the line containing dhcp is commented out, and static IP configuration (with IP address, netmask and gateway) is added. Adjust the settings according to your network condition.

Restart the networking services to activate the change without reboot.

To check whether an IP address is set or not, type ip command.

change ip raspberry pi

Wicd Tool: Configure a Static IP Address for Wired Ethernet and WiFi

Another way to set up a static IP address on Raspberry Pi is using Wicd tool, which is an open-source network manager for wired and wireless networks. Wicd tool is not installed on Raspbian by default, so you need to install it first.

Follow instructions below to install Wicd and set up a static IP address with Wicd.

To launch Wicd, run:

You will see an ncurses -based interface for listing available wired and wireless networks.

change ip raspberry pi

The instruction for setting up a static IP address on Wicd is the same for both wired Ethernet or WiFi networks (accessible via a USB WiFi dongle).

First, you need to highlight a network to configure (e.g., an Ethernet-based wired network, or a particular WiFi access point), and press right arrow button. This will open a setup window (see picture below).

change ip raspberry pi

Press space button to turn on Use Static IPs , and then fill out IP address, netmask and gateway.

change ip raspberry pi

In case of WiFi configuration, besides above information, you will also need to fill out an access point password in the Key field.

change ip raspberry pi

Press F10 button to save the entered information, which will then bring you back to the list of available networks.

Note: Wicd is also available as a full GUI version (i.e., wicd-gtk ). This version comes with wicd-tray , which will be automatically loaded when you log in to your desktop, as configured in /etc/xdg/autostart/wicd-tray.desktop. To install wicd-gtk , simply run:

Here are screenshots of wicd-gtk and its desktop tray icon.

change ip raspberry pi

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License . If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

change ip raspberry pi

Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean

How to set a static IP address on a Raspberry Pi

The Raspberry Pi is a fine addition to your home for a crazy number of reasons, but you'll probably need a static IP for it first.

Raspberry Pi Zero

The Raspberry Pi continues to be one of the most impressive computers on the planet. Not for its power, but for the possibilities. This thing can be programmed with a mindboggling number of purposes, from small servers and NAS to controlling your home automation or even just a small Linux computer to learn some new IT skills.

Whatever you want to use it for, it's a pretty solid bet that you'll need a static IP for it. Unless you're using something like the Raspberry Pi 400 hooked up to a display, you're likely using it headless. That is, without a GUI. In the case of the Raspberry Pi Zero, this is even more likely.

Setting a static IP for your Pi is really easy, and doesn't have to involve your home router which sometimes can mess it up anyway. Case in point, the last Raspberry Pi I set up on my home network I assigned a static IP in the router settings, and it just sort of forgot about it and assigned a totally different IP to my ad blocker so it didn't actually work properly. That's why you should follow these steps and set it up on the Pi itself for the best results.

Setting up your Raspberry Pi

This guide assumes that your Raspberry Pi is already set up and you've flashed it with the Raspberry Pi OS already. If you haven't and need a helping hand, we have a guide on setting up a headless Raspberry Pi using nothing but your Windows PC.

Before you can set a static IP for your Raspberry Pi you will need to know what IP address it's currently on. At this point, the quickest method is probably to log into your router's software and grab it there, especially if you're doing a headless setup. You'll need the IP address to connect over SSH and do the rest.

With the IP address in hand, open a terminal (WSL or PowerShell is fine), and connect with the following command:

Accept the fingerprint by typing yes and hitting enter. If this is the first boot you'll need to log in with the default password, which is raspberry . It's a good idea to change this, but for the purposes of what we're doing here you don't need to and can just carry on with the next step.

How to set a static IP on your Raspberry Pi

To set the static IP properly you'll need a few things. The first is the current IP of the Pi which you've already got, the next is your router's gateway IP and the current DNS IP address. We can get these last two from the Raspberry Pi terminal.

Router gateway IP address

Enter this command into the terminal:

Note down the first IP address given as this is the one you want.

Router DNS IP address

Again in the terminal, enter this command:

This will open a file in the nano text editor and the IP address you're looking for is immediately after nameserver . Note this down and press Ctrl + X to close out.

Setting the static IP address

The final step is to set the static IP address for your Raspberry Pi. It involves appending some details to the end of a configuration file. You must make sure you either use the IP address already given to your Raspberry Pi or that you're using an address that is currently vacant.

To begin, enter this command:

This will open up the dhcpcd.conf file in the nano text editor. Use your cursor keys to navigate all the way to the bottom.

Make sure not to change any of the existing items in this file, then at the bottom, you'll be entering a block of text following this template:

You'll replace the terms in capitals with the following:

  • NETWORKTYPE — Type either eth0 for ethernet or wlan0 for wireless.
  • YOURSTATICIP — Whatever static IP you want to assign to the Raspberry Pi.
  • YOURROUTERIP — The gateway IP address acquired above.
  • YOURDNSIP — The DNS IP address acquired above.

When finished you'll end up with something that looks a bit like this:

Now, press Ctrl + X followed by Y to close and save the file. You'll need to reboot the Pi for the changes to take effect, which you can do with the

Give it a minute to reboot, reconnect over SSH, and then use the

command to confirm the IP address matches what you set above. It should match, and now your Raspberry Pi should retain this IP any time it boots. Ensure you don't assign anything to this IP address either manually or through your router settings, and you should be good to go!

Get the Windows Central Newsletter

All the latest news, reviews, and guides for Windows and Xbox diehards.

Richard Devine

Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you'll find him steering the site's coverage of all manner of PC hardware and reviews. Find him on Mastodon at

  • 2 Alienware 27-inch 360Hz monitor review: Pushing the competitive gaming limits of 1080p
  • 3 Remnant 2 review: A worthy successor that could have used a little more polish
  • 4 Windows 11 will finally respect your default browser choice... in some countries
  • 5 Armored Core 6: How to beat Raven

change ip raspberry pi

How to Set a Static IP Address on Raspberry Pi

How to Set a Static IP Address on Raspberry Pi

author-Arjun Sha

Set a Static IP Address on Raspberry Pi (2021)

Set a static ip address using raspberry pi’s terminal.

Connect Headless Raspberry Pi to Windows Laptop Without Ethernet or Monitor

3. After that, execute the below command to open the dhcpcd.conf file via Nano editor. Keep in mind that Nano is a keyboard-based editor , so you can’t use your mouse to move between lines and edit the file.

How to Set a Static IP Address on Raspberry Pi

8. That’s it. You have assigned a static IP address to your Raspberry Pi in a few easy steps. Now, your router will only use the static IP address you have set for your Raspberry Pi.

Using the Router Settings to Set Static IP on Raspberry Pi

Configure Your Router

4. Click on “Add” and enter the IP address of Raspberry Pi in the “Reserved IP Address” field. You can find the IP address of your RPi board by entering hostname -I in the Terminal. To find the MAC address of your RPi , scroll down and look for the client list mentioned on the same admin page. Next, give a name in the “Description” field and turn on the “Enable This Entry” checkbox. Finally, click on “Save”. It will reserve Raspberry Pi’s current IP address, making it a static IP.

dhcp server

Assign a Static IP Address to Raspberry Pi in a Few Easy Steps!

How to Set Up Raspberry Pi Without a PC

How to Set Up Raspberry Pi Without a PC

Raspberry Pi Low-Cost Weather Station Predict the AQI

This Developer Built a Low-Cost Weather Station That Predicts the AQI Using a Raspberry Pi

Raspberry Pi OS 64-Bit version released

Raspberry Pi OS 64-Bit Arrives with Improved Performance and App Compatibility

How-to-Overclock-Raspberry-Pi-4-to-2GHz-Raspberry-Pi-OS-and-Windows-11-10 (1)

How to Safely Overclock Raspberry Pi 4

How to Install Windows 11 or Windows 10 on Raspberry Pi

How to Install Windows 11/ 10 on Raspberry Pi

How to Build an Audio Streaming Device with Raspberry Pi

How to Build an Audio Streaming Device with Raspberry Pi

WTF… This is all WIFI! What if I have my RPi connected to my router via a 1000MHz ethernet cable? You shd be more general, and not assume everyone connects thru ther wifi.

Your Comment

Your Email *

Atlas Fallen review

Atlas Fallen Review: Sand Surfing, Monster Slaying Goodness!

Deck 13 is one of my guilty pleasure game developers and publisher. So when their next title Atlas Fallen was announced, it immediately grabbed my interest even though I have a mixed relationship with The Surge. While I am critical […]

Venba cover art

Venba Review: Hits Too Close to Home

Venba has managed to turn a lot of heads since its first announcement at Nintendo Direct in late 2022. After all, you don’t get frequently games where you need to prepare South Indian cuisine throughout the experience. I gravitated toward […]

Nothing Phone 2 review – Beebom

Nothing Phone 2 Review: Price Dilutes the Hype?

The much-anticipated Nothing Phone (2) is finally here, and it created a lot of buzz in the smartphone market. While the Nothing Phone (2) looks similar to its predecessor, it is still a wake-up call for the smartphone industry. One […]

  • Domain Names
  • Domain Name Search
  • Free Domain Transfer
  • .com Domain
  • 1 Dollar Domain
  • Cheap Domain
  • Free Domain
  • Buy SSL Certificate
  • Website Builder
  • Website Platforms
  • Website Templates
  • Web Design Services
  • eCommerce Website Builder
  • Web Hosting
  • WordPress Hosting
  • 1 Dollar Hosting
  • Windows Hosting
  • Free Website Hosting
  • Create Business Email
  • HiDrive Cloud Storage
  • Microsoft 365 Business
  • Cloud Server

Your fully virtualized private server.

  • Dedicated Servers
  • Rent a Server
  • IONOS Cloud
  • Business Name Generator
  • Logo Creator
  • Favicon Generator
  • Whois Lookup
  • Website Checker
  • SSL Checker
  • IP Address Check
  • Configuration

Equip Raspberry Pi with a static IP address

How to set a Raspberry Pi with a static ip address?

A static IP address , as opposed to a dynamic IP address, doesn’t change. The single-board computer Raspberry Pi always needs a static IP address if you want to access it with other devices over a long period of time. This refers to the private IP address of the Raspberry IP that is located by a computer within the local network as well as the public IP address of the network via which the Raspberry Pi is accessible on the internet (for example, if it’s being used as a server). But how do you provide Raspberry Pi with an IP address that always remains the same? This guide explains which options you have for linking a static IP address to your Raspberry Pi.

Addressing Raspberry Pi in the LAN via a private IP address

Addressing the raspberry pi on the internet via a public ip address or ddns, assign a static private ip address to raspberry pi with a router, assign a static private ip address to raspberry pi with dhcpcd, static ip addresses for raspberry pi are sometimes vital.

$1 Domain Names

Register great TLDs for less than $1 for the first year.

Why wait? Grab your favorite domain name today!

Addressing Raspberry Pi via a static IP address

For many projects with the small computer, it’s either useful or necessary to provide Raspberry Pi with a static IP address. But before we talk more specifically about the use of such a static IP address with Raspberry Pi, we’ll first outline the differences between addressing a computer in a private (local) network or on the publicly accessible internet . Private and public IP addresses are not to be confused with each other.

Within a local network (also called a Local Area Network, or LAN for short), a router distributes data to various devices. The router is also responsible for IP address assignment – more specifically, the DHCP server integrated in the router is responsible. For example, the DHCP (Dynamic Host Configuration Protocol) automatically assigns free IP addresses to the corresponding devices. Computers, smart TVs, smartphones, or a Raspberry Pi each receive such an address via which they can communicate with other devices. Therefore, all devices are uniquely identifiable via their so-called MAC address .

Since IP addresses in a private network are individually assigned by the DHCP and the coupling of devices to an IP address is only valid within your local network, here we’re talking about private IP addresses . In the default settings, Raspberry Pi also receives its IP address via the DHCP server. The private IP addresses of individual devices can change though, depending on the configuration of the DHCP server.

To be able to reach Raspberry Pi on the same address in your own LAN, you have to provide it with a static, private IP address . One such static IP address for Raspberry Pi can be used, for example, for the remote maintenance of a computer within the network protocol SSH (Secure Shell): If you have an SSH program installed, you can control the Raspberry Pi via another computer using the SSH client. This has the advantage that you don’t have to connect a monitor and input device separately for operation anymore. But if the minicomputer only has a dynamic private IP address, then you have to reselect the current IP address for every SSH access and link it to the SSH client – you bypass this step with a static private IP address.

A static private IP address is essential for your Raspberry Pi if you want to set it up as a server in the LAN . If the Raspberry Pi server is also to continue being available outside of the local network, then you have to assign it another static address via which the server can be accessed on the internet. For example, an internet connection with a static public IP address or a DDNS service.

If the Raspberry Pi is to be used as a server accessible over the internet, then the public IP address of your internet connection comes into play. Most internet access is available via dynamic IP addresses that are changed every time they start and at the latest every 24 hours. This changes the public IP address with which the Raspberry Pi server can be reached.

If you want to set up your Raspberry Pi as an ownCloud server or in another server form, the following problem occurs: As soon as the server receives a new IP address, it can only be traced in the LAN. If you want to be found outside of the local network, you no longer know which address the server can be reached on. The solution to this is a fixed IP address. The simplest variation here would be to use an internet connection with a static public IP address . But this is usually quite expensive, and isn’t offered by all internet service providers.

Another solution is the application of dynamic DNS (DDNS) . This links your dynamic public IP address with a domain name. Every time, as soon as your IP address changes, a program redirects the new address to the domain name and makes it permanently available on the internet. Now if you link a server on Raspberry Pi with the domain name, it’s permanently accessible online.

There are both free and paid DDNS services. Before you decide on one for yourself, you should first test which DDNS providers your router supports, and whether it supports any at all . Find the DDNS support tutorial for whichever individual router your DDNS server is intended to operate on, such as this tutorial for Linksys routers .

Many routers support the ability to provide individual devices within the local network with a static IP address. With a Linksys router, the Linksys app  allows you to manage multiple devices and handle all of the router assignments remotely. Various other routers also support similar functions, and so can be used for linking Raspberry Pi with a static IP address.

A static IP address for Raspberry Pi is set up somewhat differently for each router. The basic principle is always the same, though: You open the user interface of the router in your browser; Link the MAC address of Raspberry Pi with your LAN’s IPv4 address via the manual IP configuration. Most of the time, a checkbox exists for this in the router interface. This enables you to always automatically use the IP address assigned to you.

Raspbian Jessie, or Jessie Lite – the current Raspbian operating systems at the moment – have a DHCP client daemon (DHCPCD) that can communicate with the DHCP servers from routers. The configuration file of a DHCP client daemon allows you to change the private IP address of a computer and set it up in the long term. The following instructions will assign a static IPv4 address with 32 bits (not to be confused with an IPv6 address , which has 128 bits available) to the Raspberry Pi.

Before you begin with the assignment of a private IP address for Raspberry Pi, check whether DHCPCD is already activated using the following command:

In case it’s not, activate DHCPCD as follows:

Now make sure that the configuration of the file /etc/network/interfaces has the original status . For this, the ‘iface’ configuration needs to be set at ‘manual’ for the interfaces.

For the editing of the activated DHCPCDs, start by opening the configuration file /etc/dhcpcd.conf and running the following command:

You’ll now carry out the configuration of the static IP address. If your Raspberry Pi is connected to the internet via an Ethernet or network cable, then enter the command ‘interface eth0’; if it takes place over Wi-Fi, then use the ‘interface wlan’ command.

To assign an IP address to Raspberry Pi, use the command ‘ static ip_address= ’ followed by the desired IPv4 address and the suffix ‘ /24 ’ (an abbreviation of the subnet mak ). For example, if you want to link a computer with the IPv4 address , then you need to use the command ‘static ip_address=’. It goes without saying that the address used here is not yet used anywhere else. As such, it also can’t be located in the address pool of a DHCP server.

You still then need to specify the address of your gateway and domain name server (usually both are the router). Raspberry Pi turns to the gateway address if an IP address to which it wants to send something is outside of the subnet mask (in the example, this would mean outside of the range 192.168.0). In the following command, the IPv4 address is used as an example as both the gateway and DNS server. The complete command looks like this in our example (where a network cable is used for the internet connection):

The command lines above match the IPv4 addresses that you want to use for your Raspberry Pi, or where your router is assigned. Save the changes with ‘Ctrl + O’ and then press the enter key. Close the configuration file with ‘Ctrl + X’. Restart to adopt the newly assigned static IP address in the network:

Now use a ping command to check whether the Raspberry Pi is accessible in the network with its new IP address:

If the connection of the IP address was successful, you’ll see that you can reach it under the new IP address with a ping.

In summary, it should be noted that there are basically two different IP addresses that are relevant for Raspberry Pi (and projects using it): the private IP address of the Raspberry Pi within the local network, and the public IP address of its internet connection.

A static private IP address is primarily necessary if you want to use Raspberry Pi as a server . But if you access the minicomputer via SSH more frequently, you should assign in a static address in the same way. The possibilities outlined above detail how this can be achieved with relatively simple means.

Assigning a fixed public address that allows your Raspberry Pi to be accessed via the internet is somewhat more complicated. This is necessary, for example, when attempting to make your server installed on Raspberry Pi remain constantly available online. Most internet access is available only via a dynamic public IP address, which isn’t possible here. Since a static address isn’t offered by all internet providers (and if it is, then it’s usually relatively expensive), a DDNS service presents the best solutions. But for this, you have to know which forms of dynamic DNS are supported by your router.

  • Open Source

Related articles

Creating a Raspberry Pi cloud server with owncloud

Creating a Raspberry Pi cloud server with owncloud

With ownCloud software, your Raspberry Pi can be used as a private cloud, performing the same kind of tasks as clouds from major providers such as Google, Amazon, and Dropbox. Cost-effectiveness is just one of many the benefits of creating your own personal cloud; another is the privacy and security of your data. This step-by-step Raspberry Pi cloud tutorial explains how to set up ownCloud.

Raspberry Pi mail server: using Raspberry Pi to manage e-mails

Raspberry Pi mail server: using Raspberry Pi to manage e-mails

Why use e-mail servers from commercial e-mails service providers when you can just set up your own? You can create a private server easily and affordably with a small computer known as Raspberry Pi. Having your own e-mail server, however, requires a certain amount of work and also has its disadvantages. You can find out more about how to set up your personal Raspberry Pi mail server in this…

Using Raspberry Pi as a web server

Using Raspberry Pi as a web server

Have you always wanted to operate your own web server? Raspberry Pi makes this goal more realistic, without commanding a high price and expert-level knowledge for set-up: hosting a website’s test environment or a private cloud is just as manageable for the small computer as controlling light sources, heaters, or other home devices (home automation). In our tutorial, you’ll find out all you need to…

30 Raspberry Pi projects that show the possibilities of the mini computer

30 Raspberry Pi projects that show the possibilities of the mini computer

Raspberry Pi is an inexpensive micro-computer that can behave like a standard computer in many respects. The innovative mini device can be used for a wide range of tasks - from setting up an operating system to surfing the web, to using it as a server or a media center. Discover 30 interesting Raspberry Pi projects to try out at home.

What is DHCP Snooping?

What is DHCP Snooping?

DHCP snooping makes a network more secure. There are no two ways about it: DHCP makes network configuration so much easier. This is especially the case in large networks, where devices are constantly changing and the manual assignment of IP addresses is a never-ending task. Yet by using DHCP to simplify the process, you do relinquish controls, and criminals can take advantage of this. By using…

Build or host a website, launch a server, or store your data and more with our most popular products for less.

Help Center Help Center

  • Help Center
  • Trial Software
  • Product Updates
  • Documentation

Configure Network Settings of Raspberry Pi Hardware

You can configure the network settings of your Raspberry Pi ® hardware by inspecting and editing the IP configuration of the Ethernet port.

You may need to reconfigure the IP settings if your Raspberry Pi board:

Has unknown IP settings

Is unreachable using a network connection

Is being moved to a network or direct Ethernet connection that uses static IP settings

Is being moved from a network that used static IP settings to one that uses DHCP services

There are several conditions under which networks use DHCP or static IP settings.

Use DHCP services — If your Raspberry Pi board is connected to a network with DHCP services, such as an office LAN or a home network connected to the Internet. DHCP is a network service that automatically configures the IP settings of Ethernet devices connected to a network.

Use static IP settings — If your Raspberry Pi board is directly connected to an Ethernet port on your host computer or connected to an isolated network without DHCP services.

To configure the Raspberry Pi board to use DHCP or static IP settings:

You can use a terminal window after accessing the Linux ® desktop. See Access Linux on Raspberry Pi Using Computer Peripherals .

To display the content of the /etc/dhcpcd.conf file, enter this command in the terminal.

Be default, the IP address obtained from the DHCP server that you set in the dhcp.conf file, configures the DHCP client running on the Raspberry Pi board.

By default, the DHCP client running on the Raspberry Pi board is configured to obtain an IP address from the DHCP server.

DHCP Server IP Address

You can configure a static IP address for your Raspberry Pi board by updating the dhcpcd.conf file. See the sample that shows how to configure the IP address of your Raspberry Pi board as . # Static IP configuration for eth0: interface eth0 static ip_address= static routers=

Static IP address for Raspberry Pi

To create a backup of the /etc/dhcpcd.conf file, enter this command in the terminal.

If prompted, enter the root password.

To edit the /etc/dhcpcd.conf file, enter this command in the terminal.

To configure the static IP address for your Raspberry Pi board, add these lines of code for ip_address and router at the end of the dhcpcd.conf file. # Static IP configuration for eth0: interface eth0 static ip_address= static routers=

Save the changes and exit nano :

Press Ctrl+X .

Enter Y to save the modified buffer.

For “File Name to Write: /etc/dhcpcd.conf”, press Enter .

The nano editor confirms that it “Wrote # lines” and returns control to the command line.

Reboot the board. In MATLAB ® Command Window, enter: h = raspberrypi h.execute('sudo shutdown -r now')

Test the IP settings by logging in to the board over a telnet session.

You can use the ifconfig command to temporarily change the IP settings. Rebooting the board removes the ifconfig settings and restores the /etc/dhcpcd.conf settings.

To change the IP settings temporarily, open a Linux command line. Enter ifconfig , the device id, a valid IP address, netmask , and the appropriate network mask. For example: ifconfig eth0 netmask

Related Topics

  • Run Simulink Model on Raspberry Pi Hardware
  • Get IP Address of Raspberry Pi Hardware

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

  • América Latina (Español)
  • Canada (English)
  • United States (English)
  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)

Contact your local office

  • Documentation
  • Trademark rules
  • Board index Community General discussion

Changing the Raspberry Pi’s IP address

Mon Jun 22, 2020 11:41 pm

How to Set Up a Static IP on the Raspberry Pi

Posted by Scott Campbell | Raspberry Pi | 31

How to Set Up a Static IP on the Raspberry Pi

Have you ever tried logging in to your Raspberry Pi  via SSH and were denied because the IP address couldn’t be found? Do you have to scan your network every time you connect to find your local IP address? If the IP address of your Raspberry Pi changes all the time, it’s because you’re using a  dynamic IP address . If you want your Pi to have an IP address that doesn’t change automatically, assign it a static IP address . With a static IP, you can be sure that the same IP will work each and every time.


In this tutorial, I’ll show you how to configure a static IP address using a clean installation of Raspbian Jessie and Raspbian Jessie Lite. There are pros and cons to each type of IP though, so let’s first talk about why you would want a static IP over a dynamic IP.

Static IP vs. Dynamic IP

Dynamic IP’s are good to use if you’re concerned about security. If a hacker gets access to your IP address, you’ll be less vulnerable to attack since your IP changes frequently. A dynamic IP can change every time you log in, or only at certain intervals. A program installed on your network router called the dynamic host configuration protocol (DHCP), automatically changes and assigns new dynamic IP addresses to computers on your network.

A static IP (as you could probably tell by the name) is one that doesn’t change. This makes it more reliable when using services that depend on a stable internet connection, like online gaming, VOIP, or remote desktop applications. With a static IP, you’ll be able to use the same IP address every time you connect to your Pi.

Setting up a Static IP on the Raspberry Pi

Before starting, make sure you’ve already set up and configured a way to access the command prompt. Check out our tutorials  How to Set Up WiFi on the Raspberry Pi  and How to Set Up a Raspberry Pi Without a Monitor or Keyboard  to see how to do that if you haven’t already.

In this tutorial we’ll set up static IP’s for both WiFi and ethernet connections. If you only need one or the other, just omit the code below for the connection you don’t need.

Find Out Your Network Information

The first step is to find out your  default gateway IP . This is the local IP address of your network router. The computers on your network use it to communicate with the router and access the internet. If you already know what it is, just skip this step. If not, do continue…

Power up and log into your Raspberry Pi via WiFi or ethernet, then enter route -ne at the command prompt to see your network routing information:

How to Set Up a Static IP for your Raspberry Pi - route -ne

Under the “Gateway” column, you can see your default gateway IP ( in my case). The “Iface” column lists the names for each connection – ethernet (eth0) and WiFi (wlan0). Write down your default gateway IP, we’ll need it in a minute.

Now we need to find out the IP addresses of your  domain name servers. Your Pi sends the domain names you enter into your browser (i.e. to domain name servers, which convert the domain names to IP addresses (i.e. Your Pi then uses the IP address to access the website’s server.

Enter cat /etc/resolv.conf at the command prompt to find the list of domain name servers:

How to Set Up a Static IP for your Raspberry Pi resolv conf conf file contents

Copy these IP addresses to a text editor on your PC or write them down for later.

Configure the Network Settings

Now we’re ready to configure the network settings. By default the Pi is configured with a dynamic IP address. To assign it a static IP address, you need to add your static IP, default gateway IP, and domain name servers to the dhcpcd.conf file.

At the command prompt, enter sudo nano /etc/dhcpcd.conf to edit the dhcpcd.conf file:

How to Set Up a Static IP for your Raspberry Pi - Sudo Nano dhcpcd conf

Now, without changing anything else in the file, add this code at the bottom of the dhcpcd.conf file, replacing the IP addresses with your own IP addresses found above:

  • static ip_address :  This is the static IP address you’ll use to SSH or remotely connect to your Pi. Take your default gateway IP (found in the steps above), and change the last number to any other number between 0 and 255.
  • static routers :  This is your default gateway IP address.
  • static domain_name_servers :  These are the IP’s we found in the resolv.conf file above. Separate each IP with a single space.

For example, my default gateway IP address is To get the  static ip_address  for my ethernet connection (eth0), I replaced the 1 with 100 to get To get the static ip_address for my WiFi connection (wlan0), I replaced the 1 with 99 to get I’ll use these IPs to log in to my Pi from now on.

The file should look like this (with your own IP addresses):

Static IP Address for Raspberry Pi - dhcpcd File Contents

Once you’ve replaced the IP addresses in the example code with your own IP addresses, press Ctrl-X and Y to exit and save the dhcpcd.conf file. Now enter sudo reboot to reboot the Pi. Log in with your new static ethernet IP or static WiFi IP:

Static IP Address for the Raspberry Pi in PuTTY

To check that everything is working correctly and the Pi has access to the internet, let’s ping Google. Enter sudo ping  at the command prompt:

How to Set Up a Static IP for your Raspberry Pi - Direct Ethernet Connection Ping Google

Press Ctrl-C to stop the pinging. If the connection is successful, you’ll see the packets that have been sent and received. If your connection isn’t successful, you will get a “Network is unreachable” error:

How to Set Up a Static IP for your Raspberry Pi - Direct Ethernet Connection Ping Google Network Unreachable

You should probably test the connection by pinging Google with both ethernet and WiFi static IP’s.

You can watch me set this up step by step in this video:

Now that you have a static IP set up, your Pi’s connection to the internet will be a lot more reliable. But another really useful way to connect to your Pi is with a direct ethernet connection to your laptop or desktop. A direct connection is extremely fast and stable. If you connect to your Pi via SSH a lot, I would definitely recommend setting this up. Check out our article,  How to Connect to a Raspberry Pi Directly with an Ethernet Cable to learn how.

Thanks for reading! Let me know in the comments if you have any questions about setting up your static IP, and I’ll do my best to help. And be sure to subscribe! We send out a quick email each time we publish new articles.

change ip raspberry pi

Related Posts

Raspberry Pi Touchscreen Calibration and Screen Rotation

Raspberry Pi Touchscreen Calibration and Screen Rotation

February 4, 2015

How to Send Text Messages With a Raspberry Pi

How to Send Text Messages With a Raspberry Pi

April 8, 2021

How to Write and Run a Shell Script on the Raspberry Pi

How to Write and Run a Shell Script on the Raspberry Pi

August 11, 2015

How To Setup an Accelerometer on the Raspberry Pi

How To Setup an Accelerometer on the Raspberry Pi

May 16, 2021


Great article. Just a few weeks too late for me as I finally figured it out…

It can be as simple. Lots of articles about fixed ip on the web, read at least 10 of them. All of them wrong or at least outdated (no jessie). Yours worked in no time. Mni thanks for that!

Thanks a Lot on How to setup static ip address, I looked few web site and most had wrong information.

Thank you, many “so called current” info on this on the web but all seem outdated, this is 100% correct. Thank you again.

works fine in setting static address but when trying to ping Google I get “unknown host ” If I comment out the added lines the ping works fine I use TightVNC to connect to the PI – router address is

@JarJarGeek Very nice guide, I would use this for server, but for general Pi;s I find avahi-deamon more flexible.

When i type in the cat for either files or even sudo nano it either says that te file or directory doesn’t exist or the document comes up blank (implying that it doesn’t exist).

i am using a raspberry pi 3 and am using the latest raspbian os as of may 15th 2016.

please help that way i don’t end up having to set my pi up every time i want to use it.

nevermind. got it working.

had to share this on my @RebelMouse. Thank you!

When I tried this it fails to connect. I think the problem is in the static router address. As per your instructions I came up with…

pi@VIDraspberrypi:~ $ route -ne Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface UG 0 0 0 wlan0 U 0 0 0 eth0 U 0 0 0 wlan0


will this allow graphics from a python program running on pi like pygame? or is the screen functionality merely a window into the terminal?

How will you ensure that the DHCP won’t assign this address to another device?. If my understanding is correct the DHCP does not know about this static IP and can therefore assign it to something else. If this happens there will be an IP conflict. is there anyway out of this ?

Most dhcp servers will try to ping address before assigning it to a client. But if your static IP device is switched off, the address still may be used by dhcp, and conflict will happen when you switch it on.To avoid this, you have to exclude address from your dhcp server’s address distribution range. Or you can make a reservation for that address in dhcp. In some cases reservation is even an alternative to static IP.

How can I set network mask to? Because this way it gives me mask of which is not correct in my case, Also I need to set additional classless route for via another gateway.

In fact I don’t need static address. If I do, I’d rater prefer to setup a dhcp reservation. I came to your article finding solution to a problem I have: My raspbian jessie / pi3B does not get default gateway from DHCP. It receives normaly everything else – IP address, default domain, dns and ntp servers, additional classless routes but not default gateway! What can be wrong? The DHCP server is Windows 2012 R2, if that does mater.

With Raspian Jessie (2016/09/23) a need to add “routers” and “domain_name_servers” BOTH under eth0 and wlan0:

interface eth0 static ip_address=192.168.x.x/24 static routers=192.168.x.x static domain_name_servers=x.x.x.x

interface wlan0 static ip_address=192.168.x.x/24 static routers=192.168.x.x static domain_name_servers=x.x.x.x

Thanks for the update! I’ll add this to the post.

i share with you a video on youtube how to configure your ip from dhcp to static.

When i run “sudo ifdown wlan0, sudo ifup wlan0” i get “ifdown: interface wlan0, not configured”. what is the fix for this ?

Amazing! Its truly amazing article, I have got much clear idea concerning from this piece of writing.


Hi, we have the products of raspberry pi and arduino components, and very interest in working with you.

How do i make it so the ip is the same on any network?? Working on a project and need a way to ping the pi on any network it goes to.

Great article, thank you so much for explaining each of the lines in the dhcpcd.conf file. so many articles tell you to “just add this” without explaining what it means and why. Led to me following several and losing SSH access to the pi until I reverted it.

Doesn’t get much easier that that. Thanks.

Thanks, confirming this worked for me using Raspbian Buster in January 2019

Thank you so much, this helped me a lot. May 2020

I have set static IP in Pi and check by ping and it is working fine but when I enter static IP in putty for ssh getting network error connection time out. I have checked SSH is enabled in pi as well. Can anyone please help me why getting this error?

Worked like a charm. Thank you!

Hello Your tutorial is really helpful. But I have a problem. It seems that I have mistype my static IP address so I can’t connect with my RPi. The static ip_address should be “” but I typed it “” Is there any way I could fix it? Thank you

I am having a strange issue where my resolve.conf file keeps resetting upon reboot or shutdown and I have to do the setup again!!!  The requirement for the static IP is because I am running my own VPN server with OpenVPN and the client I am using on the other end for connecting is Orbot for PC. I don't want to start from scratch hence the reset is not a choice. I did try changing the user and also chmod to 775 giving full permissions or locking it down, without much luck. Any guidance is appreciated.

Leave a reply Cancel reply

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

Save my name, email, and website in this browser for the next time I comment.

Notify me of follow-up comments by email.

Notify me of new posts by email.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use .

I agree to these terms .

Get new tutorials sent to your inbox!

Ultimate Guide to the Arduino SIDEBAR NEW

Quick Start Guide for Setting Up a Static IP on the Raspberry Pi

Enter your name and email and I'll send it to your inbox:

Consent to store personal information: I agree to let Circuit Basics store my personal information so they can email me the file I requested, and agree to the Privacy Policy

Email me new tutorials and (very) occasional promotional stuff: Yes No

Check your email to get the PDF!

Sander Holvoet

Sander Holvoet

Roses are red, violets are blue unexpected ‘{‘ on line 32.

  • Custom Social Profile Link

Raspberry Pi change IP without rebooting

March 30, 2021 1 minute read

💡 Even though the article below is targeted specifically at Raspberry Pi OS (formerly called Raspbian) the steps below should work perfectly fine for any Debian based O/S , as well as any other Linux distros which use dhcpcd .

Configuring a static IP address in Raspberry Pi OS is pretty straight forward. To do so we’ll need to disable the default automatic configuration ( DHCP ) for the network interface in question.

Adding a static configuration

Raspberry Pi OS -like many other Linux distros- uses dhcpcd as its default DHCP client. The configuration file of dhcpcd is located at /etc/dhcpcd.conf .

Let’s say you want to use a static IP address of , simply add the following lines:

  • interface : network interface for which you want to set a static IP (usually eth0 or wlan0 ).
  • static ip_address : your desired static IP in CIDR notation. /24 refers to netmask .
  • static routers : IP of your router / gateway.
  • static domain_name_servers : your DNS server(s) of choice. As I’m running a Pi-hole instance on the same device, I’m specifying the same IP followed by Cloudflare ’s DNS servers which will serve as a backup should my Pi-hole instance be unreachable.

This is the part you would normally reboot your Raspberry Pi (by running reboot unsurprisingly 🤷‍♂️), in order to apply your changes. Thankfully there is an easier way which doesn’t require a reboot.

Apply changes without rebooting

The command below will bring down the eth0 interface, ⏸️ pause for exactly 5 seconds and automatically bring it back up afterwards:

Verify whether the network interface has been configured by running ifconfig :

You should now be able to reach your Raspberry Pi using the static IP you configured 👏.

You May Also Enjoy

Removing Microsoft Edge using PowerShell

less than 1 minute read

Upgrading your Raspberry Pi to Bullseye

4 minute read

Monitoring Linux hosts using Grafana Cloud, Prometheus and Node Exporter

Automating Azure DevOps agent updates

Raspberry Pi Documentation

Configuration, the raspi-config tool.

Edit this on GitHub

raspi-config is the Raspberry Pi configuration tool originally written by Alex Bradbury . To open the configuration tool, type the following on the command line:

The sudo is required because you will be changing files that you do not own as the pi user.

You should then see a blue screen with options in a grey box:

raspi-config main screen

Use the up and down arrow keys to move the highlighted selection between the options available. Pressing the right arrow key will jump out of the Options menu and take you to the <Select> and <Finish> buttons. Pressing left will take you back to the options. Alternatively, you can use the Tab key to switch between these.

Generally speaking, raspi-config aims to provide the functionality to make the most common configuration changes. This may result in automated edits to /boot/config.txt and various standard Linux configuration files. Some options require a reboot to take effect. If you changed any of those, raspi-config will ask if you wish to reboot now when you select the <Finish> button.

List of Options

System options.

The system options submenu allows you to make configuration changes to various parts of the boot, login and networking process, along with some other system level changes.

Wireless LAN

Allows setting of the wireless LAN SSID and passphrase.

Specify the audio output destination.

You can change the 'default' user password.

Set the visible name for this Raspberry Pi on a network.

Boot / Auto login

From this submenu you can select whether to boot to console or desktop and whether you need to log in or not. If you select automatic login, you will be logged in as the pi user.

Network at Boot

Use this option to wait for a network connection before letting boot proceed.

Splash Screen

Enable or disable the splash screen displayed at boot time

If the model of Raspberry Pi permits it, you can change the behaviour of the power LED using this option.

Display Options

Define the default HDMI/DVI video resolution to use when the system boots without a TV or monitor being connected. This can have an effect on RealVNC if the VNC option is enabled.

Old TV sets had a significant variation in the size of the picture they produced; some had cabinets that overlapped the screen. TV pictures were therefore given a black border so that none of the picture was lost; this is called overscan. Modern TVs and monitors don’t need the border, and the signal doesn’t allow for it. If the initial text shown on the screen disappears off the edge, you need to enable overscan to bring the border back.

Any changes will take effect after a reboot. You can have greater control over the settings by editing config.txt .

On some displays, particularly monitors, disabling overscan will make the picture fill the whole screen and correct the resolution. For other displays, it may be necessary to leave overscan enabled and adjust its values.

Pixel Doubling

Enable/disable 2x2 pixel mapping.

Composite Video

On the Raspberry Pi 4, enable composite video. On models prior to the Raspberry Pi 4, composite video is enabled by default so this option is not displayed.

Screen Blanking

Enable or disable screen blanking.

Interfacing Options

In this submenu there are the following options to enable/disable: Camera, SSH, VNC, SPI, I2C, Serial, 1-wire, and Remote GPIO.

Enable/disable the CSI camera interface.

Enable/disable remote command line access to your Raspberry Pi using SSH.

SSH allows you to remotely access the command line of the Raspberry Pi from another computer. SSH is disabled by default. Read more about using SSH on the SSH documentation page . If connecting your Raspberry Pi directly to a public network, you should not enable SSH unless you have set up secure passwords for all users.

Enable/disable the RealVNC virtual network computing server.

Enable/disable SPI interfaces and automatic loading of the SPI kernel module, needed for products such as PiFace.

Enable/disable I2C interfaces and automatic loading of the I2C kernel module.

Enable/disable shell and kernel messages on the serial connection.

Enable/disable the Dallas 1-wire interface. This is usually used for DS18B20 temperature sensors.

Remote GPIO

Enable or disable remote access to the GPIO pins.

Performance Options

On some models it is possible to overclock your Raspberry Pi’s CPU using this tool. The overclocking you can achieve will vary; overclocking too high may result in instability. Selecting this option shows the following warning:

Be aware that overclocking may reduce the lifetime of your Raspberry Pi. If overclocking at a certain level causes system instability, try a more modest overclock. Hold down the Shift key during boot to temporarily disable overclocking.

Change the amount of memory made available to the GPU.

Overlay File System

Enable or disable a read-only filesystem

Set the behaviour of a GPIO connected fan

Localisation Options

The localisation submenu gives you these options to choose from: keyboard layout, time zone, locale, and wireless LAN country code.

Select a locale, for example en_GB.UTF-8 UTF-8 .

Select your local time zone, starting with the region, e.g. Europe, then selecting a city, e.g. London. Type a letter to skip down the list to that point in the alphabet.

This option opens another menu which allows you to select your keyboard layout. It will take a long time to display while it reads all the keyboard types. Changes usually take effect immediately, but may require a reboot.

WLAN Country

This option sets the country code for your wireless network.

Advanced Options

Expand filesystem.

This option will expand your installation to fill the whole SD card, giving you more space to use for files. You will need to reboot the Raspberry Pi to make this available.

Enable/disable the experimental GL desktop graphics drivers.

GL (Full KMS)

Enable/disable the experimental OpenGL Full KMS (kernel mode setting) desktop graphics driver.

GL (Fake KMS)

Enable/disable the experimental OpenGL Fake KMS desktop graphics driver.

Enable/disable the original legacy non-GL VideoCore desktop graphics driver.

Enable/Display the xcompmgr composition manager

Network Interface Names

Enable or disable predictable network interface names.

Network Proxy Settings

Configure the network’s proxy settings.

On the Raspberry Pi 4, you can specify whether to boot from USB or network if the SD card isn’t inserted. See this page for more information.

Bootloader Version

On the Raspberry Pi 4, you can tell the system to use the very latest boot ROM software, or revert to the factory default if the latest version causes problems.

Update this tool to the latest version.

About raspi-config

Selecting this option shows the following text:

Use this button when you have completed your changes. You will be asked whether you want to reboot or not. When used for the first time, it’s best to reboot. There will be a delay in rebooting if you have chosen to resize your SD card.

The raspi-config Command Line Interface

The raspi-config tool can also be run in a non-interactive mode, which is useful for setting up a Raspberry Pi image for distribution.

Hidden: 0 = visible, 1 = hidden. Defaults to visible. Plain: If plain is 1 , the default, passphrase is quoted

Raspberry Pi 4B+

0 - bcm2835 Headphones

1 - vc4-hdmi-0

2 - vc4-hdmi-1

0 - Boot without waiting for network connection 1 - Boot after waiting for network connection

0 - Enable splash screen 1 - Disable splash screen

0 - Flash for disk activity 1 - Be on constantly

Group: 2 = DMT, otherwise = CEA Mode: 0 = Default Automatic

0 - Enable overscan 1 - Disable overscan

0 - Enable pixel doubling 1 - Disable pixel doubling

0 - Enable composite video 1 - Disable composite video

0 - Enable screen blanking 1 - Disable screen blanking

0 - Enable camera 1 - Disable camera

0 - Enable SSH 1 - Disable SSH

0 - Enable VNC 1 - Disable VNC

0 - Enable SPI 1 - Disable SPI

0 - Enable I2C 1 - Disable I2C

0 - Enable console over serial port 1 - Disable serial port 2 - Enable serial port

0 - Enable 1-wire 1 - Disable 1-wire

0 - Enable remote GPIO 1 - Disable remote GPIO

Setting is one of: - None - The default - Modest - Overclock to 50% of the maximum - Medium - Overclock to 75% of the maximum - High - Overclock to 100% of the maximum - Turbo - Overclock to 125% of the maximum

0 - Enable overlay filesystem 1 - Disable overlay filesystem

0 - Enable fan 1 - Disable fan

GPIO defaults to 14 .

onTemp defaults to 80 °C.

0 - Enable predictable network interface names 1 - Disable predictable network interface names

B1 - SD Card Boot - Boot from SD Card if available, otherwise boot from USB

B2 - USB Boot - Boot from USB if available, otherwise boot from SD Card

B3 - Network Boot - Boot from network if SD card boot fails

Configuring Networking

A GUI is provided for setting up wireless connections in Raspberry Pi OS with desktop. However if you are using Raspberry Pi OS Lite, you can set up wireless networking from the command line.

Using the Desktop

Wireless connections can be made via the network icon at the right-hand end of the menu bar. If you are using a Raspberry Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, left-clicking this icon will bring up a list of available wireless networks, as shown below. If no networks are found, it will show the message 'No APs found - scanning…​'. Wait a few seconds without closing the menu, and it should find your network.

Note that on Raspberry Pi devices that support the 5GHz band (Pi3B+, Pi4, CM4, Pi400), wireless networking is disabled for regulatory reasons, until the country code has been set. To set the country code, open the Raspberry Pi Configuration application from the Preferences Menu, select Localisation and set the appropriate code.


The icons on the right show whether a network is secured or not, and give an indication of its signal strength. Click the network that you want to connect to. If it is secured, a dialogue box will prompt you to enter the network key:


Enter the key and click OK , then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When it is ready, the icon will stop flashing and show the signal strength.

Using the Command Line

This method is suitable if you don’t have access to the graphical user interface normally used to set up a wireless LAN on the Raspberry Pi. It is particularly suitable for use with a serial console cable if you don’t have access to a screen or wired Ethernet network. Note also that no additional software is required; everything you need is already included on the Raspberry Pi.

Using raspi-config

The quickest way to enable wireless networking is to use the command line raspi-config tool.

sudo raspi-config

Select the Localisation Options item from the menu, then the Change wireless country option. On a fresh install, for regulatory purposes, you will need to specify the country in which the device is being used. Then set the SSID of the network, and the passphrase for the network. If you do not know the SSID of the network you want to connect to, see the next section on how to list available networks prior to running raspi-config .

Note that raspi-config does not provide a complete set of options for setting up wireless networking; you may need to refer to the extra sections below for more details if raspi-config fails to connect the Raspberry Pi to your requested network.

Getting Wireless LAN Network Details

To scan for wireless networks, use the command sudo iwlist wlan0 scan . This will list all available wireless networks, along with other useful information. Look out for:

'ESSID:"testing"' is the name of the wireless network.

'IE: IEEE 802.11i/WPA2 Version 1' is the authentication used. In this case it’s WPA2, the newer and more secure wireless standard which replaces WPA. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise. You’ll also need the password for the wireless network. For most home routers, this is found on a sticker on the back of the router. The ESSID (ssid) for the examples below is testing and the password (psk) is testingPassword .

Adding the Network Details to your Raspberry Pi

Open the wpa-supplicant configuration file in nano:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Go to the bottom of the file and add the following:

The password can be configured either as the ASCII representation, in quotes as per the example above, or as a pre-encrypted 32 byte hexadecimal number. You can use the wpa_passphrase utility to generate an encrypted PSK. This takes the SSID and the password, and generates the encrypted PSK. With the example from above, you can generate the PSK with wpa_passphrase "testing" . Then you will be asked for the password of the wireless network (in this case testingPassword ). The output is as follows:

Note that the plain text version of the code is present, but commented out. You should delete this line from the final wpa_supplicant file for extra security.

The wpa_passphrase tool requires a password with between 8 and 63 characters. To use a more complex password, you can extract the content of a text file and use it as input for wpa_passphrase . Store the password in a text file and input it to wpa_passphrase by calling wpa_passphrase "testing" < file_where_password_is_stored . For extra security, you should delete the file_where_password_is_stored afterwards, so there is no plain text copy of the original password on the system.

To use the wpa_passphrase --encrypted PSK, you can either copy and paste the encrypted PSK into the wpa_supplicant.conf file, or redirect the tool’s output to the configuration file in one of two ways:

Either change to root by executing sudo su , then call wpa_passphrase "testing" >> /etc/wpa_supplicant/wpa_supplicant.conf and enter the testing password when asked

Or use wpa_passphrase "testing" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null and enter the testing password when asked; the redirection to /dev/null prevents tee from also outputting to the screen (standard output).

If you want to use one of these two options, make sure you use >> , or use -a with tee  — either will append text to an existing file. Using a single chevron > , or omitting -a when using tee , will erase all contents and then append the output to the specified file.

Now save the file by pressing Ctrl+X , then Y , then finally press Enter .

Reconfigure the interface with wpa_cli -i wlan0 reconfigure .

You can verify whether it has successfully connected using ifconfig wlan0 . If the inet addr field has an address beside it, the Raspberry Pi has connected to the network. If not, check that your password and ESSID are correct.

On the Raspberry Pi 3B+ and Raspberry Pi 4B, you will also need to set the country code, so that the 5GHz networking can choose the correct frequency bands. You can do this using the raspi-config application: select the 'Localisation Options' menu, then 'Change Wi-Fi Country'. Alternatively, you can edit the wpa_supplicant.conf file and add the following. (Note: you need to replace 'GB' with the 2 letter ISO code of your country. See Wikipedia for a list of 2 letter ISO 3166-1 country codes.)

Note that with the latest Buster Raspberry Pi OS release, you must ensure that the wpa_supplicant.conf file contains the following information at the top:

Using Unsecured Networks

If the network you are connecting to does not use a password, the wpa_supplicant entry for the network will need to include the correct key_mgmt entry. e.g.

Hidden Networks

If you are using a hidden network, an extra option in the wpa_supplicant file , scan_ssid , may help connection.

You can verify whether it has successfully connected using ifconfig wlan0 . If the inet addr field has an address beside it, the Raspberry Pi has connected to the network. If not, check your password and ESSID are correct.

Adding Multiple Wireless Network Configurations

On recent versions of Raspberry Pi OS, it is possible to set up multiple configurations for wireless networking. For example, you could set up one for home and one for school.

For example

If you have two networks in range, you can add the priority option to choose between them. The network in range, with the highest priority, will be the one that is connected.

The DHCP Daemon

The Raspberry Pi uses dhcpcd to configure TCP/IP across all of its network interfaces. The dhcpcd daemon is intended to be an all-in-one ZeroConf client for UNIX-like systems. This includes assigning each interface an IP address, setting netmasks, and configuring DNS resolution via the Name Service Switch (NSS) facility.

By default, Raspberry Pi OS attempts to automatically configure all network interfaces by DHCP, falling back to automatic private addresses in the range if DHCP fails. This is consistent with the behaviour of other Linux variants and of Microsoft Windows.

Static IP Addresses

If you want to allocate a static IP address to your Raspberry Pi, the best way to do so is to reserve an address for it on your router. That way your Raspberry Pi will continue to have its address allocated via DHCP but will receive the same address each time. A "fixed" address can be allocated by your DHCP server associating it with the MAC address of your Raspberry Pi. Management of IP addresses will remain with the DHCP server and this will avoid address conflicts and potential network problems.

However, if you wish to disable automatic configuration for an interface, and instead configure it statically, you can do so in /etc/dhcpcd.conf . For example:

Setting up a Headless Raspberry Pi

To use your Raspberry Pi without a monitor or keyboard (known as headless), you need to enable wireless networking and SSH.

If you haven’t already imaged your Raspberry Pi, you can set up wireless networking and SSH during the imaging process .

If you already have an image on the micro SD card, you can access the boot folder by inserting the card into a card reader on a Linux or Windows machine. Adding certain files to this folder will activate certain setup features on the first boot of the Raspberry Pi.

You will need to define a wpa_supplicant.conf file for your particular wireless network. Put this file onto the boot folder of the SD card. When the Raspberry Pi boots for the first time, it will copy that file into the correct location in the Linux root file system and use those settings to start up wireless networking.

The Raspberry Pi’s IP address will not be visible immediately after power on, so this step is crucial to connect to it headlessly. Depending on the OS and editor you are creating this on, the file could have incorrect newlines or the wrong file extension so make sure you use an editor that accounts for this. Linux expects the line feed (LF) newline character.

A wpa_supplicant.conf file example:

Where the country code should be set the two letter ISO/IEC alpha2 code for the country in which you are using, e.g.

GB (United Kingdom)

FR (France)

DE (Germany)

US (United States)

SE (Sweden)

Here is a more elaborate example that should work for most typical wpa2 personal networks. This template below works for 2.4ghz/5ghz hidden or not networks. The utilization of quotes around the ssid - psk can help avoid any oddities if your network ssid or password has special chars (! @ # $ etc)

Configuring a User

You will need to add a userconf.txt in the boot partition of the SD card; this is the part of the SD card which can be seen when it is mounted in a Windows or MacOS computer.

This file should contain a single line of text, consisting of username:password – so your desired username, followed immediately by a colon, followed immediately by an encrypted representation of the password you want to use.

To generate the encrypted password, the easiest way is to use OpenSSL on a Raspberry Pi that is already running – open a terminal window and enter:

This will prompt you to enter your password, and verify it. It will then produce what looks like a string of random characters, which is actually an encrypted version of the supplied password.

Setting up a Routed Wireless Access Point

A Raspberry Pi within an Ethernet network can be used as a wireless access point, creating a secondary network. The resulting new wireless network is entirely managed by the Raspberry Pi.

If you wish to extend an existing Ethernet network to wireless clients, consider instead setting up a bridged access point .

A routed wireless access point can be created using the inbuilt wireless features of the Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero W, or by using a suitable USB wireless dongle that supports access point mode. It is possible that some USB dongles may need slight changes to their settings. If you are having trouble with a USB wireless dongle, please check the forums .

This documentation was tested on a Raspberry Pi 3B running a fresh installation of Raspberry Pi OS Buster.

Before you Begin

Ensure you have administrative access to your Raspberry Pi. The network setup will be modified as part of the installation: local access, with screen and keyboard connected to your Raspberry Pi, is recommended.

Connect your Raspberry Pi to the Ethernet network and boot the Raspberry Pi OS.

Ensure the Raspberry Pi OS on your Raspberry Pi is up-to-date and reboot if packages were installed in the process.

Take note of the IP configuration of the Ethernet network the Raspberry Pi is connected to:

In this document, we assume IP network is configured on the Ethernet LAN, and the Raspberry Pi is going to manage IP network for wireless clients.

Please select another IP network for wireless, e.g. , if IP network is already in use by your Ethernet LAN.

Have a wireless client (laptop, smartphone, …​) ready to test your new access point.

Install AP and Management Software

In order to work as an access point, the Raspberry Pi needs to have the hostapd access point software package installed:

Enable the wireless access point service and set it to start when your Raspberry Pi boots:

In order to provide network management services (DNS, DHCP) to wireless clients, the Raspberry Pi needs to have the dnsmasq software package installed:

Finally, install netfilter-persistent and its plugin iptables-persistent . This utility helps by saving firewall rules and restoring them when the Raspberry Pi boots:

Software installation is complete. We will configure the software packages later on.

Set up the Network Router

The Raspberry Pi will run and manage a standalone wireless network. It will also route between the wireless and Ethernet networks, providing internet access to wireless clients. If you prefer, you can choose to skip the routing by skipping the section "Enable routing and IP masquerading" below, and run the wireless network in complete isolation.

Define the Wireless Interface IP Configuration

The Raspberry Pi runs a DHCP server for the wireless network; this requires static IP configuration for the wireless interface ( wlan0 ) in the Raspberry Pi. The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: .

To configure the static IP address, edit the configuration file for dhcpcd with:

Go to the end of the file and add the following:

Enable Routing and IP Masquerading

This section configures the Raspberry Pi to let wireless clients access computers on the main (Ethernet) network, and from there the internet.

To enable routing, i.e. to allow traffic to flow from one network to the other in the Raspberry Pi, create a file using the following command, with the contents below:

File contents:

Enabling routing will allow hosts from network to reach the LAN and the main router towards the internet. In order to allow traffic between clients on this foreign wireless network and the internet without changing the configuration of the main router, the Raspberry Pi can substitute the IP address of wireless clients with its own IP address on the LAN using a "masquerade" firewall rule.

The main router will see all outgoing traffic from wireless clients as coming from the Raspberry Pi, allowing communication with the internet.

The Raspberry Pi will receive all incoming traffic, substitute the IP addresses back, and forward traffic to the original wireless client.

This process is configured by adding a single firewall rule in the Raspberry Pi:

Now save the current firewall rules for IPv4 (including the rule above) and IPv6 to be loaded at boot by the netfilter-persistent service:

Filtering rules are saved to the directory /etc/iptables/ . If in the future you change the configuration of your firewall, make sure to save the configuration before rebooting.

Configure the DHCP and DNS services for the wireless network

The DHCP and DNS services are provided by dnsmasq . The default configuration file serves as a template for all possible configuration options, whereas we only need a few. It is easier to start from an empty file.

Rename the default configuration file and edit a new one:

Add the following to the file and save it:

The Raspberry Pi will deliver IP addresses between and , with a lease time of 24 hours, to wireless DHCP clients. You should be able to reach the Raspberry Pi under the name gw.wlan from wireless clients.

There are many more options for dnsmasq ; see the default configuration file ( /etc/dnsmasq.conf ) or the online documentation for details.

Ensure Wireless Operation

Countries around the world regulate the use of telecommunication radio frequency bands to ensure interference-free operation. The Linux OS helps users comply with these rules by allowing applications to be configured with a two-letter "WiFi country code", e.g. US for a computer used in the United States.

In the Raspberry Pi OS, 5 GHz wireless networking is disabled until a WiFi country code has been configured by the user, usually as part of the initial installation process (see wireless configuration pages in this section for details.)

To ensure WiFi radio is not blocked on your Raspberry Pi, execute the following command:

This setting will be automatically restored at boot time. We will define an appropriate country code in the access point software configuration, next.

Configure the AP Software

Create the hostapd configuration file, located at /etc/hostapd/hostapd.conf , to add the various parameters for your new wireless network.

Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of NameOfNetwork , and a password AardvarkBadgerHedgehog . Note that the name and password should not have quotes around them. The passphrase should be between 8 and 64 characters in length.

Note the line country_code=GB : it configures the computer to use the correct wireless frequencies in the United Kingdom. Adapt this line and specify the two-letter ISO code of your country. See Wikipedia for a list of two-letter ISO 3166-1 country codes.

To use the 5 GHz band, you can change the operations mode from hw_mode=g to hw_mode=a . Possible values for hw_mode are:

a = IEEE 802.11a (5 GHz) (Raspberry Pi 3B+ onwards)

b = IEEE 802.11b (2.4 GHz)

g = IEEE 802.11g (2.4 GHz)

Note that when changing the hw_mode , you may need to also change the channel - see Wikipedia for a list of allowed combinations.

Running the new Wireless AP

Now restart your Raspberry Pi and verify that the wireless access point becomes automatically available.

Once your Raspberry Pi has restarted, search for wireless networks with your wireless client. The network SSID you specified in file /etc/hostapd/hostapd.conf should now be present, and it should be accessible with the specified password.

If SSH is enabled on the Raspberry Pi, it should be possible to connect to it from your wireless client as follows, assuming the pi account is present: ssh [email protected] or ssh [email protected]

If your wireless client has access to your Raspberry Pi (and the internet, if you set up routing), congratulations on setting up your new access point!

If you encounter difficulties, contact the forums for assistance. Please refer to this page in your message.

Setting up a Bridged Wireless Access Point

The Raspberry Pi can be used as a bridged wireless access point within an existing Ethernet network. This will extend the network to wireless computers and devices.

If you wish to create a standalone wireless network, consider instead setting up a routed access point .

A bridged wireless access point can be created using the inbuilt wireless features of the Raspberry Pi 4, Raspberry Pi 3 or Raspberry Pi Zero W, or by using a suitable USB wireless dongle that supports access point mode. It is possible that some USB dongles may need slight changes to their settings. If you are having trouble with a USB wireless dongle, please check the forums .

Ensure you have administrative access to your Raspberry Pi. The network setup will be entirely reset as part of the installation: local access, with screen and keyboard connected to your Raspberry Pi, is recommended.

In order to work as a bridged access point, the Raspberry Pi needs to have the hostapd access point software package installed:

Software installation is complete. We will configure the access point software later on.

Setup the Network Bridge

A bridge network device running on the Raspberry Pi will connect the Ethernet and wireless networks using its built-in interfaces.

Create a bridge device and populate the bridge

Add a bridge network device named br0 by creating a file using the following command, with the contents below:

In order to bridge the Ethernet network with the wireless network, first add the built-in Ethernet interface ( eth0 ) as a bridge member by creating the following file:

Now enable the systemd-networkd service to create and populate the bridge when your Raspberry Pi boots:

Define the bridge device IP configuration

Network interfaces that are members of a bridge device are never assigned an IP address, since they communicate via the bridge. The bridge device itself needs an IP address, so that you can reach your Raspberry Pi on the network.

dhcpcd , the DHCP client on the Raspberry Pi, automatically requests an IP address for every active interface. So we need to block the eth0 and wlan0 interfaces from being processed, and let dhcpcd configure only br0 via DHCP.

Add the following line near the beginning of the file (above the first interface xxx line, if any):

With this line, interface br0 will be configured in accordance with the defaults via DHCP. Save the file to complete the IP configuration of the machine.

Note the lines interface=wlan0 and bridge=br0 : these direct hostapd to add the wlan0 interface as a bridge member to br0 when the access point starts, completing the bridge between Ethernet and wireless.

Run the new Wireless AP

If your wireless client has access to the local network and the internet, congratulations on setting up your new access point!

Using a Proxy Server

If you want your Raspberry Pi to access the Internet via a proxy server (perhaps from a school or other workplace), you will need to configure your Raspberry Pi to use the server before you can get online.

You will need:

The IP address or hostname and port of your proxy server

A username and password for your proxy (if required)

Configuring your Raspberry Pi

You will need to set up three environment variables ( http_proxy , https_proxy , and no_proxy ) so your Raspberry Pi knows how to access the proxy server.

Open a terminal window, and open the file /etc/environment using nano:

Add the following to the /etc/environment file to create the http_proxy variable:

Replace proxyipaddress and proxyport with the IP address and port of your proxy.

Enter the same information for the environment variable https_proxy :

Create the no_proxy environment variable, which is a comma-separated list of addresses your Raspberry Pi should not use the proxy for:

Your /etc/environment file should now look like this:

environment variables

Press Ctrl + X to save and exit.

Update the sudoers File

In order for operations that run as sudo (e.g. downloading and installing software) to use the new environment variables, you’ll need to update sudoers .

Use the following command to open sudoers :

Add the following line to the file so sudo will use the environment variables you just created:

edit sudoers

Reboot your Raspberry Pi

Reboot your Raspberry Pi for the changes to take effect. You should now be able to access the internet via your proxy server.

HDMI Configuration

In the vast majority of cases, simply plugging your HDMI-equipped monitor into the Raspberry Pi using a standard HDMI cable will automatically result in the Raspberry Pi using the best resolution the monitor supports. The Raspberry Pi Zero, Zero W and Zero 2 W use a mini HDMI port, so you will need a mini-HDMI-to-full-size-HDMI lead or adapter. On the Raspberry Pi 4 and Raspberry Pi 400 there are two micro HDMI ports, so you will need a micro-HDMI-to-full-size-HDMI lead or adapter for each display you wish to attach. You should connect any HDMI leads before turning on the Raspberry Pi.

The Raspberry Pi 4 can drive up to two displays, with a resolution up to 1080p at a 60Hz refresh rate. At 4K resolution, if you connect two displays then you are limited to a 30Hz refresh rate. You can also drive a single display at 4K with a 60Hz refresh rate: this requires that the display is attached to the HDMI port adjacent to the USB-C power input (labelled HDMI0). You must also enable 4Kp60 output by setting the hdmi_enable_4kp60=1 flag in config.txt. This flag can also be set using the 'Raspberry Pi Configuration' tool within the desktop environment.

If you are running the 3D graphics driver (also known as the FKMS driver), then in the Preferences menu you will find a graphical application for setting up standard displays, including multi-display setups.

If you are using legacy graphics drivers, or find yourself in circumstances where the Raspberry Pi may not be able to determine the best mode, or you may specifically wish to set a non-default resolution, the rest of this page may be useful.

HDMI Groups and Mode

HDMI has two common groups: CEA (Consumer Electronics Association, the standard typically used by TVs) and DMT (Display Monitor Timings, the standard typically used by monitors). Each group advertises a particular set of modes, where a mode describes the resolution, frame rate, clock rate, and aspect ratio of the output.

What Modes does my Device Support?

You can use the tvservice application on the command line to determine which modes are supported by your device, along with other useful data:

tvservice -s displays the current HDMI status, including mode and resolution

tvservice -m CEA lists all supported CEA modes

tvservice -m DMT lists all supported DMT modes

If you are using a Raspberry Pi 4 with more than one display attached, then tvservice needs to be told which device to ask for information. You can get display IDs for all attached devices by using:

tvservice -l

You can specify which display tvservice uses by adding -v <display id> to the tvservice command, e.g:

tvservice -v 7 -m CEA , lists all supported CEA modes for display ID 7

Setting a Specific HDMI Mode

Setting a specific mode is done using the hdmi_group and hdmi_mode config.txt entries. The group entry selects between CEA or DMT, and the mode selects the resolution and frame rate. You can find tables of modes on the config.txt Video Configuration page, but you should use the tvservice command described above to find out exactly which modes your device supports.

On the Raspberry Pi 4 and Raspberry Pi 400 to specify the HDMI port, add an index identifier to the hdmi_group or hdmi_mode entry in config.txt, e.g. hdmi_mode:0 or hdmi_group:1 .

Setting a Custom HDMI Mode

There are two options for setting a custom mode: hdmi_cvt and hdmi_timings .

hdmi_cvt sets a custom Coordinated Video Timing entry, which is described fully here: Video Configuration

In certain rare cases it may be necessary to define the exact clock requirements of the HDMI signal. This is a fully custom mode, and it is activated by setting hdmi_group=2 and hdmi_mode=87 . You can then use the hdmi_timings config.txt command to set the specific parameters for your display. hdmi_timings specifies all the timings that an HDMI signal needs to use. These timings are usually found in the datasheet of the display being used.

aspect_ratio should be one of the following:

For the Raspberry Pi 4 and Raspberry Pi 400 to specify the HDMI port, you can add an index identifier to the config.txt. e.g. hdmi_cvt:0=... or hdmi_timings:1=... . If no port identifier is specified, the settings are applied to port 0.

Troubleshooting your HDMI

In some rare cases you may need to increase the HDMI drive strength, for example when there is speckling on the display or when you are using very long cables. There is a config.txt item to do this, config_hdmi_boost , which is documented on the config.txt video page .

Rotating your Display

The options to rotate the display of your Raspberry Pi depend on which display driver software it is running, which may also depend on which Raspberry Pi you are using.

Fake or Full KMS Graphics Driver

If you are running the Raspberry Pi desktop then rotation is achieved by using the Screen Configuration Utility from the desktop Preferences menu. This will bring up a graphical representation of the display or displays connected to the Raspberry Pi. Right click on the display you wish to rotate and select the required option.

It is also possible to change these settings using the command line xrandr option. The following commands give 0°, -90°, +90° and 180° rotations respectively.

Note that the --output entry specifies to which device the rotation applies. You can determine the device name by simply typing xrandr on the command line which will display information, including the name, for all attached devices.

You can also use the command line to mirror the display using the --reflect option. Reflection can be one of 'normal' 'x', 'y' or 'xy'. This causes the output contents to be reflected across the specified axes. For example:

If you are using the console only (no graphical desktop) then you will need to set the appropriate kernel command line flags. Change the console settings as described on the this page .

Legacy Graphics Driver

There are config.txt options for rotating when using the legacy display drivers.

display_hdmi_rotate is used to rotate the HDMI display, display_lcd_rotate is used to rotate any attached LCD panel (using the DSI or DPI interface). These options rotate both the desktop and console. Each option takes one of the following parameters :

Note that the 90 and 270 degree rotation options require additional memory on the GPU, so these will not work with the 16MB GPU split.

You can combine the rotation settings with the flips by adding them together. You can also have both horizontal and vertical flips in the same way. E.g. A 180 degree rotation with a vertical and horizontal flip will be 0x20000 + 0x10000 + 2 = 0x30002.

Audio Configuration

The Raspberry Pi has up to three audio output modes: HDMI 1 and 2, if present, and a headphone jack. You can switch between these modes at any time.

If your HDMI monitor or TV has built-in speakers, the audio can be played over the HDMI cable, but you can switch it to a set of headphones or other speakers plugged into the headphone jack. If your display claims to have speakers, sound is output via HDMI by default; if not, it is output via the headphone jack. This may not be the desired output setup, or the auto-detection is inaccurate, in which case you can manually switch the output.

Changing the Audio Output

There are two ways of setting the audio output; using the desktop volume control, or using the raspi-config command line tool.

Right-clicking the volume icon on the desktop taskbar brings up the audio output selector; this allows you to select between the internal audio outputs. It also allows you to select any external audio devices, such as USB sound cards and Bluetooth audio devices. A green tick is shown against the currently selected audio output device — simply left-click the desired output in the pop-up menu to change this. The volume control and mute operate on the currently selected device.

Open up raspi-config by entering the following into the command line:

This will open the configuration screen:

Select System Options (Currently option 1, but yours may be different) and press Enter .

Now select the Option named, Audio (Currently option S2, but yours may be different) and press Enter :

Select your required mode, press Enter and press the right arrow key to exit the options list, then select Finish to exit the configuration tool.

After you have finished modifying your audio settings, you need to restart your Raspberry Pi in order for your changes to take effect.

In some rare cases, it is necessary to edit config.txt to force HDMI mode (as opposed to DVI mode, which does not send sound). You can do this by editing /boot/config.txt and setting hdmi_drive=2 , then rebooting for the change to take effect.

External Storage Configuration

You can connect your external hard disk, SSD, or USB stick to any of the USB ports on the Raspberry Pi, and mount the file system to access the data stored on it.

By default, your Raspberry Pi automatically mounts some of the popular file systems such as FAT, NTFS, and HFS+ at the /media/pi/<HARD-DRIVE-LABEL> location.

To set up your storage device so that it always mounts to a specific location of your choice, you must mount it manually.

Mounting a Storage Device

You can mount your storage device at a specific folder location. It is conventional to do this within the /mnt folder, for example /mnt/mydisk . Note that the folder must be empty.

Plug the storage device into a USB port on the Raspberry Pi.

List all the disk partitions on the Raspberry Pi using the following command:

The Raspberry Pi uses mount points / and /boot . Your storage device will show up in this list, along with any other connected storage.

Use the SIZE, LABEL, and MODEL columns to identify the name of the disk partition that points to your storage device. For example, sda1 .

The FSTYPE column contains the filesystem type. If your storage device uses an exFAT file system, install the exFAT driver:

If your storage device uses an NTFS file system, you will have read-only access to it. If you want to write to the device, you can install the ntfs-3g driver:

Run the following command to get the location of the disk partition:

For example, /dev/sda1 .

Create a target folder to be the mount point of the storage device. The mount point name used in this case is mydisk . You can specify a name of your choice:

Mount the storage device at the mount point you created:

Verify that the storage device is mounted successfully by listing the contents:

Setting up Automatic Mounting

You can modify the fstab file to define the location where the storage device will be automatically mounted when the Raspberry Pi starts up. In the fstab file, the disk partition is identified by the universally unique identifier (UUID).

Get the UUID of the disk partition:

Find the disk partition from the list and note the UUID. For example, 5C24-1453 .

Open the fstab file using a command line editor such as nano:

Add the following line in the fstab file:

Replace fstype with the type of your file system, which you found in step 2 of 'Mounting a storage device' above, for example: ntfs .

If the filesystem type is FAT or NTFS, add ,umask=000 immediately after nofail - this will allow all users full read/write access to every file on the storage device.

Now that you have set an entry in fstab , you can start up your Raspberry Pi with or without the storage device attached. Before you unplug the device you must either shut down the Raspberry Pi, or manually unmount it using the steps in 'Unmounting a storage device' below.

For more information on each Linux command, refer to the specific manual page using the man command. For example, man fstab .

Unmounting a Storage Device

When the Raspberry Pi shuts down, the system takes care of unmounting the storage device so that it is safe to unplug it. If you want to manually unmount a device, you can use the following command:

If you receive an error that the 'target is busy', this means that the storage device was not unmounted. If no error was displayed, you can now safely unplug the device.

Dealing with 'target is busy'

The 'target is busy' message means there are files on the storage device that are in use by a program. To close the files, use the following procedure.

Close any program which has open files on the storage device.

If you have a terminal open, make sure that you are not in the folder where the storage device is mounted, or in a sub-folder of it.

If you are still unable to unmount the storage device, you can use the lsof tool to check which program has files open on the device. You need to first install lsof using apt :

To use lsof:

Localising your Raspberry Pi

You can set your Raspberry Pi up to match your regional settings.

Changing the Language

If you want to select a different language use raspi-config .

Configuring the Keyboard

If you want to select a different keyboard use raspi-config .

Changing the Timezone

Once again, this is something you can change using the raspi-config tool.

Changing the default pin configuration

As of July 2014, the Raspberry Pi firmware supports custom default pin configurations through a user-provided Device Tree blob file. To find out whether your firmware is recent enough, please run vcgencmd version .

Device Pins During Boot Sequence

During the bootup sequence, the GPIO pins go through various actions.

Power-on — pins default to inputs with default pulls; the default pulls for each pin are described in the datasheet

Setting by the bootrom

Setting by bootcode.bin

Setting by dt-blob.bin (this page)

Setting by the GPIO command in config.txt

Additional firmware pins (e.g. UARTS)

Kernel/Device Tree

On a soft reset, the same procedure applies, except for default pulls, which are only applied on a power-on reset.

Note that it may take a few seconds to get from stage 1 to stage 4. During that time, the GPIO pins may not be in the state expected by attached peripherals (as defined in dtblob.bin or config.txt ). Since different GPIO pins have different default pulls, you should do one of the following for your peripheral:

Choose a GPIO pins that defaults to pulls as required by the peripheral on reset

Delay the peripheral’s startup until stage 4/5 has been reached

Add an appropriate pull-up/-down resistor

Providing a Custom Device Tree Blob

In order to compile a Device Tree source ( .dts ) file into a Device Tree blob ( .dtb ) file, the Device Tree compiler must be installed by running sudo apt install device-tree-compiler . The dtc command can then be used as follows:

Similarly, a .dtb file can be converted back to a .dts file, if required.

Sections of the dt-blob

The dt-blob.bin is used to configure the binary blob (VideoCore) at boot time. It is not currently used by the Linux kernel, but a kernel section will be added at a later stage, when we reconfigure the Raspberry Pi kernel to use a dt-blob for configuration. The dt-blob can configure all versions of the Raspberry Pi, including the Compute Module, to use the alternative settings. The following sections are valid in the dt-blob:

This section contains all of the VideoCore blob information. All subsequent sections must be enclosed within this section.

There are a number of separate pins_* sections, based on particular Raspberry Pi models, namely:

pins_rev1 Rev1 pin setup. There are some differences because of the moved I2C pins.

pins_rev2 Rev2 pin setup. This includes the additional codec pins on P5.

pins_bplus1 Raspberry Pi 1 Model B+ rev 1.1, including the full 40pin connector.

pins_bplus2 Raspberry Pi 1 Model B+ rev 1.2, swapping the low-power and lan-run pins.

pins_aplus Raspberry Pi 1 Model A+, lacking Ethernet.

pins_2b1 Raspberry Pi 2 Model B rev 1.0; controls the SMPS via I2C0.

pins_2b2 Raspberry Pi 2 Model B rev 1.1; controls the SMPS via software I2C on 42 and 43.

pins_3b1 Raspberry Pi 3 Model B rev 1.0

pins_3b2 Raspberry Pi 3 Model B rev 1.2

pins_3bplus Raspberry Pi 3 Model B+

pins_3aplus Raspberry Pi 3 Model A+

pins_pi0 Raspberry Pi Zero

pins_pi0w Raspberry Pi Zero W

pins_cm Raspberry Pi Compute Module 1. The default for this is the default for the chip, so it is a useful source of information about default pull ups/downs on the chip.

pins_cm3 Raspberry Pi Compute Module 3

Each pins_* section can contain pin_config and pin_defines sections.

The pin_config section is used to configure the individual pins. Each item in this section must be a named pin section, such as pin@p32 , meaning GPIO32. There is a special section pin@default , which contains the default settings for anything not specifically named in the pin_config section.


This section can contain any combination of the following items:




drive_strength_mA The drive strength is used to set a strength for the pins. Please note that you can only specify a single drive strength for the bank. <8> and <16> are valid values.


This section is used to set specific VideoCore functionality to particular pins. This enables the user to move the camera power enable pin to somewhere different, or move the HDMI hotplug position: things that Linux does not control. Please refer to the example DTS file below.

Clock Configuration

It is possible to change the configuration of the clocks through this interface, although it can be difficult to predict the results! The configuration of the clocking system is very complex. There are five separate PLLs, and each one has its own fixed (or variable, in the case of PLLC) VCO frequency. Each VCO then has a number of different channels which can be set up with a different division of the VCO frequency. Each of the clock destinations can be configured to come from one of the clock channels, although there is a restricted mapping of source to destination, so not all channels can be routed to all clock destinations.

Here are a couple of example configurations that you can use to alter specific clocks. We will add to this resource when requests for clock configurations are made.

The above will set the PLLA to a source VCO running at 1.96608GHz (the limits for this VCO are 600MHz - 2.4GHz), change the APER channel to /4, and configure GPCLK0 to be sourced from PLLA through APER. This is used to give an audio codec the 12288000Hz it needs to produce the 48000 range of frequencies.

Sample Device Tree Source File

The example file comes from the firmware repository, . This is the master Raspberry Pi blob, from which others are usually derived.

Device Trees, Overlays, and Parameters

Raspberry Pi kernels and firmware use a Device Tree (DT) to describe the hardware present in the Raspberry Pi. These Device Trees may include DT parameters that provide a degree of control over some onboard features. DT overlays allow optional external hardware to be described and configured, and they also support parameters for more control.

The firmware loader ( start.elf and its variants) is responsible for loading the DTB (Device Tree Blob - a machine readable DT file). It chooses which one to load based on the board revision number, and makes certain modifications to further tailor it (memory size, Ethernet addresses etc.). This runtime customisation avoids the need for lots of DTBs with only minor differences.

config.txt is scanned for user-provided parameters, along with any overlays and their parameters, which are then applied. The loader examines the result to learn (for example) which UART, if any, is to be used for the console. Finally it launches the kernel, passing a pointer to the merged DTB.

Device Trees

A Device Tree (DT) is a description of the hardware in a system. It should include the name of the base CPU, its memory configuration, and any peripherals (internal and external). A DT should not be used to describe the software, although by listing the hardware modules it does usually cause driver modules to be loaded. It helps to remember that DTs are supposed to be OS-neutral, so anything which is Linux-specific probably shouldn’t be there.

A Device Tree represents the hardware configuration as a hierarchy of nodes. Each node may contain properties and subnodes. Properties are named arrays of bytes, which may contain strings, numbers (big-endian), arbitrary sequences of bytes, and any combination thereof. By analogy to a filesystem, nodes are directories and properties are files. The locations of nodes and properties within the tree can be described using a path, with slashes as separators and a single slash ( / ) to indicate the root.

Basic DTS syntax

Device Trees are usually written in a textual form known as Device Tree Source (DTS) and stored in files with a .dts suffix. DTS syntax is C-like, with braces for grouping and semicolons at the end of each line. Note that DTS requires semicolons after closing braces: think of C struct s rather than functions. The compiled binary format is referred to as Flattened Device Tree (FDT) or Device Tree Blob (DTB), and is stored in .dtb files.

The following is a simple tree in the .dts format:

This tree contains:

a required header: /dts-v1/ .

The inclusion of another DTS file, conventionally named *.dtsi and analogous to a .h header file in C - see An aside about /include/ below.

a single root node: /

a couple of child nodes: node1 and node2

some children for node1: child-node1 and child-node2

a label ( cousin ) and a reference to that label ( &cousin ): see Labels and References below.

several properties scattered through the tree

a repeated node ( /node2 ) - see An aside about /include/ below.

Properties are simple key-value pairs where the value can either be empty or contain an arbitrary byte stream. While data types are not encoded in the data structure, there are a few fundamental data representations that can be expressed in a Device Tree source file.

Text strings (NUL-terminated) are indicated with double quotes:

Cells are 32-bit unsigned integers delimited by angle brackets:

Arbitrary byte data is delimited with square brackets, and entered in hex:

Data of differing representations can be concatenated using a comma:

Commas are also used to create lists of strings:

An aside about /include/

The /include/ directive results in simple textual inclusion, much like C’s #include directive, but a feature of the Device Tree compiler leads to different usage patterns. Given that nodes are named, potentially with absolute paths, it is possible for the same node to appear twice in a DTS file (and its inclusions). When this happens, the nodes and properties are combined, interleaving and overwriting properties as required (later values override earlier ones).

In the example above, the second appearance of /node2 causes a new property to be added to the original:

It is thus possible for one .dtsi to overwrite, or provide defaults for, multiple places in a tree.

Labels and references

It is often necessary for one part of the tree to refer to another, and there are four ways to do this:

Path strings

Paths should be self-explanatory, by analogy with a filesystem - /soc/i2s@7e203000 is the full path to the I2S device in BCM2835 and BCM2836. Note that although it is easy to construct a path to a property (for example, /soc/i2s@7e203000/status ), the standard APIs don’t do that; you first find a node, then choose properties of that node.

A phandle is a unique 32-bit integer assigned to a node in its phandle property. For historical reasons, you may also see a redundant, matching linux,phandle . phandles are numbered sequentially, starting from 1; 0 is not a valid phandle. They are usually allocated by the DT compiler when it encounters a reference to a node in an integer context, usually in the form of a label (see below). References to nodes using phandles are simply encoded as the corresponding integer (cell) values; there is no markup to indicate that they should be interpreted as phandles, as that is application-defined.

Just as a label in C gives a name to a place in the code, a DT label assigns a name to a node in the hierarchy. The compiler takes references to labels and converts them into paths when used in string context ( &node ) and phandles in integer context ( <&node> ); the original labels do not appear in the compiled output. Note that labels contain no structure; they are just tokens in a flat, global namespace.

Aliases are similar to labels, except that they do appear in the FDT output as a form of index. They are stored as properties of the /aliases node, with each property mapping an alias name to a path string. Although the aliases node appears in the source, the path strings usually appear as references to labels ( &node ), rather then being written out in full. DT APIs that resolve a path string to a node typically look at the first character of the path, treating paths that do not start with a slash as aliases that must first be converted to a path using the /aliases table.

Device Tree semantics

How to construct a Device Tree, and how best to use it to capture the configuration of some hardware, is a large and complex subject. There are many resources available, some of which are listed below, but several points deserve mentioning in this document:

compatible properties are the link between the hardware description and the driver software. When an OS encounters a node with a compatible property, it looks it up in its database of device drivers to find the best match. In Linux, this usually results in the driver module being automatically loaded, provided it has been appropriately labelled and not blacklisted.

The status property indicates whether a device is enabled or disabled. If the status is ok , okay or absent, then the device is enabled. Otherwise, status should be disabled , so that the device is disabled. It can be useful to place devices in a .dtsi file with the status set to disabled . A derived configuration can then include that .dtsi and set the status for the devices which are needed to okay .

Device Tree Overlays

A modern SoC (System on a Chip) is a very complicated device; a complete Device Tree could be hundreds of lines long. Taking that one step further and placing the SoC on a board with other components only makes matters worse. To keep that manageable, particularly if there are related devices that share components, it makes sense to put the common elements in .dtsi files, to be included from possibly multiple .dts files.

When a system like Raspberry Pi also supports optional plug-in accessories such as HATs, the problem grows. Ultimately, each possible configuration requires a Device Tree to describe it, but once you factor in all the different base models and the large number of available accessories, the number of combinations starts to multiply rapidly.

What is needed is a way to describe these optional components using a partial Device Tree, and then to be able to build a complete tree by taking a base DT and adding a number of optional elements. You can do this, and these optional elements are called "overlays".

Unless you want to learn how to write overlays for Raspberry Pis, you might prefer to skip on to Part 3: Using Device Trees on Raspberry Pi .

A DT overlay comprises a number of fragments, each of which targets one node and its subnodes. Although the concept sounds simple enough, the syntax seems rather strange at first:

The compatible string identifies this as being for BCM2835, which is the base architecture for the Raspberry Pi SoCs; if the overlay makes use of features of a Raspberry Pi 4 then brcm,bcm2711 is the correct value to use, otherwise brcm,bcm2835 can be used for all Raspberry Pi overlays. Then comes the first (and in this case only) fragment. Fragments should be numbered sequentially from zero. Failure to adhere to this may cause some or all of your fragments to be missed.

Each fragment consists of two parts: a target property, identifying the node to apply the overlay to; and the __overlay__ itself, the body of which is added to the target node. The example above can be interpreted as if it were written like this:

(In fact, with a sufficiently new version of dtc you can write it exactly like that and get identical output, but some homegrown tools don’t understand this format yet so any overlay that you might want to be included in the standard Raspberry Pi OS kernel should be written in the old format for now).

The effect of merging that overlay with a standard Raspberry Pi base Device Tree (e.g. bcm2708-rpi-b-plus.dtb ), provided the overlay is loaded afterwards, would be to enable the I2S interface by changing its status to okay . But if you try to compile this overlay using:

you will get an error:

This shouldn’t be too unexpected, since there is no reference to the base .dtb or .dts file to allow the compiler to find the i2s label.

Trying again, this time using the original example and adding the -@ option to allow unresolved references (and -Hepapr to remove some clutter):

If dtc returns an error about the third line, it doesn’t have the extensions required for overlay work. Run sudo apt install device-tree-compiler and try again - this time, compilation should complete successfully. Note that a suitable compiler is also available in the kernel tree as scripts/dtc/dtc , built when the dtbs make target is used:

It is interesting to dump the contents of the DTB file to see what the compiler has generated:

After the verbose description of the file structure there is our fragment. But look carefully - where we wrote &i2s it now says 0xffffffff , a clue that something strange has happened (older versions of dtc might say 0xdeadbeef instead). The compiler has also added a phandle property containing a unique (to this overlay) small integer to indicate that the node has a label, and replaced all references to the label with the same small integer.

After the fragment there are three new nodes:

__symbols__ lists the labels used in the overlay ( test_label here), and the path to the labelled node. This node is the key to how unresolved symbols are dealt with.

__fixups__ contains a list of properties mapping the names of unresolved symbols to lists of paths to cells within the fragments that need patching with the phandle of the target node, once that target has been located. In this case, the path is to the 0xffffffff value of target , but fragments can contain other unresolved references which would require additional fixes.

__local_fixups__ holds the locations of any references to labels that exist within the overlay - the test_ref property. This is required because the program performing the merge will have to ensure that phandle numbers are sequential and unique.

Back in section 1.3 it says that "the original labels do not appear in the compiled output", but this isn’t true when using the -@ switch. Instead, every label results in a property in the __symbols__ node, mapping a label to a path, exactly like the aliases node. In fact, the mechanism is so similar that when resolving symbols, the Raspberry Pi loader will search the "aliases" node in the absence of a __symbols__ node. This was useful at one time because providing sufficient aliases allowed very old versions of dtc to be used to build the base DTB files, but fortunately that is ancient history now.

Device Tree parameters

To avoid the need for lots of Device Tree overlays, and to reduce the need for users of peripherals to modify DTS files, the Raspberry Pi loader supports a new feature - Device Tree parameters. This permits small changes to the DT using named parameters, similar to the way kernel modules receive parameters from modprobe and the kernel command line. Parameters can be exposed by the base DTBs and by overlays, including HAT overlays.

Parameters are defined in the DTS by adding an __overrides__ node to the root. It contains properties whose names are the chosen parameter names, and whose values are a sequence comprising a phandle (reference to a label) for the target node, and a string indicating the target property; string, integer (cell) and boolean properties are supported.

String parameters

String parameters are declared like this:

where label and property are replaced by suitable values. String parameters can cause their target properties to grow, shrink, or be created.

Note that properties called status are treated specially; non-zero/true/yes/on values are converted to the string "okay" , while zero/false/no/off becomes "disabled" .

Integer parameters

Integer parameters are declared like this:

where label , property and offset are replaced by suitable values; the offset is specified in bytes relative to the start of the property (in decimal by default), and the preceding separator dictates the size of the parameter. In a change from earlier implementations, integer parameters may refer to non-existent properties or to offsets beyond the end of an existing property.

Boolean parameters

Device Tree encodes boolean values as zero-length properties; if present then the property is true, otherwise it is false. They are defined like this:

Note that a property is assigned the value false by not defining it. Boolean parameters are declared like this:

where label and property are replaced by suitable values.

Inverted booleans invert the input value before applying it in the same was as a regular boolean; they are declared similarly, but use ! to indicate the inversion:

Boolean parameters can cause properties to be created or deleted, but they can’t delete a property that already exists in the base DTB.

Byte string parameters

Byte string properties are arbitrary sequences of bytes, e.g. MAC addresses. They accept strings of hexadecimal bytes, with or without colons between the bytes.

The [ was chosen to match the DT syntax for declaring a byte string:

Parameters with multiple targets

There are some situations where it is convenient to be able to set the same value in multiple locations within the Device Tree. Rather than the ungainly approach of creating multiple parameters, it is possible to add multiple targets to a single parameter by concatenating them, like this:

(example taken from the w1-gpio overlay)

Literal assignments

As seen in 2.2.5 , the DT parameter mechanism allows multiple targets to be patched from the same parameter, but the utility is limited by the fact that the same value has to be written to all locations (except for format conversion and the negation available from inverted booleans). The addition of embedded literal assignments allows a parameter to write arbitrary values, regardless of the parameter value supplied by the user.

Assignments appear at the end of a declaration, and are indicated by a = :

Lines 1, 2 and 4 are fairly obvious, but line 3 is more interesting because the value appears as an integer (cell) value. The DT compiler evaluates integer expressions at compile time, which might be convenient (particularly if macro values are used), but the cell can also contain a reference to a label:

When the overlay is applied, the label will be resolved against the base DTB in the usual way. Note that it is a good idea to split multi-part parameters over multiple lines like this to make them easier to read - something that becomes more necessary with the addition of cell value assignments like this.

Bear in mind that parameters do nothing unless they are applied - a default value in a lookup table is ignored unless the parameter name is used without assigning a value.

Lookup tables

Lookup tables allow parameter input values to be transformed before they are used. They act as associative arrays, rather like switch/case statements:

A key with no =value means to use the key as the value, an = with no key before it is the default value in the case of no match, and starting or ending the list with a comma (or an empty key=value pair anywhere) indicates that the unmatched input value should be used unaltered; otherwise, not finding a match is an error.

Overlay/fragment parameters

The DT parameter mechanism as described has a number of limitations, including no easy way to create arrays of integers and the inability to create new nodes. One way to overcome some of these limitations is to conditionally include or exclude certain fragments.

A fragment can be excluded from the final merge process (disabled) by renaming the __overlay__ node to __dormant__ . The parameter declaration syntax has been extended to allow the otherwise illegal zero target phandle to indicate that the following string contains operations at fragment or overlay scope. So far, four operations have been implemented:

The i2c-rtc overlay uses this technique.

Special properties

A few property names, when targeted by a parameter, get special handling. One you may have noticed already - status - which will convert a boolean to either okay for true and disabled for false.

Assigning to the bootargs property appends to it rather than overwriting it - this is how settings can be added to the kernel command line.

The reg property is used to specify device addresses - the location of a memory-mapped hardware block, the address on an I2C bus, etc. The names of child nodes should be qualified with their addresses in hexadecimal, using @ as a separator:

When assigning to the reg property, the address portion of the parent node name will be replaced with the assigned value. This can be used to prevent a node name clash when using the same overlay multiple times - a technique used by the i2c-gpio overlay.

The name property is a pseudo-property - it shouldn’t appear in a DT, but assigning to it causes the name of its parent node to be changed to the assigned value. Like the reg property, this can be used to give nodes unique names.

The overlay map file

The introduction of the Raspberry Pi 4, built around the BCM2711 SoC, brought with it many changes; some of these changes are additional interfaces, and some are modifications to (or removals of) existing interfaces. There are new overlays intended specifically for the Raspberry Pi 4 that don’t make sense on older hardware, e.g. overlays that enable the new SPI, I2C and UART interfaces, but other overlays don’t apply correctly even though they control features that are still relevant on the new device.

There is therefore a need for a method of tailoring an overlay to multiple platforms with differing hardware. Supporting them all in a single .dtbo file would require heavy use of hidden ("dormant") fragments and a switch to an on-demand symbol resolution mechanism so that a missing symbol that isn’t needed doesn’t cause a failure. A simpler solution is to add a facility to map an overlay name to one of several implementation files depending on the current platform.

The overlay map, which is rolling out with the switch to Linux 5.4, is a file that gets loaded by the firmware at bootup. It is written in DTS source format - overlay_map.dts , compiled to overlay_map.dtb and stored in the overlays directory.

This is an edited version of the current map file (see the full version ):

Each node has the name of an overlay that requires special handling. The properties of each node are either platform names or one of a small number of special directives. The current supported platforms are bcm2835 , which includes all Raspberry Pis built around the BCM2835, BCM2836 and BCM2837 SoCs, and bcm2711 for Raspberry Pi 4B.

A platform name with no value (an empty property) indicates that the current overlay is compatible with the platform; for example, vc4-kms-v3d is compatible with the bcm2835 platform. A non-empty value for a platform is the name of an alternative overlay to use in place of the requested one; asking for vc4-kms-v3d on BCM2711 results in vc4-kms-v3d-pi4 being loaded instead. Any platform not included in an overlay’s node is not compatible with that overlay.

The second example node - vc4-kms-v3d-pi4 - could be inferred from the content of vc4-kms-v3d , but that intelligence goes into the construction of the file, not its interpretation.

In the event that a platform is not listed for an overlay, one of the special directives may apply:

The renamed directive indicates the new name of the overlay (which should be largely compatible with the original), but also logs a warning about the rename.

The deprecated directive contains a brief explanatory error message which will be logged after the common prefix overlay '...' is deprecated: .

Remember: only exceptions need to be listed - the absence of a node for an overlay means that the default file should be used for all platforms.

Accessing diagnostic messages from the firmware is covered in Debugging .

The dtoverlay and dtmerge utilities have been extended to support the map file:

dtmerge extracts the platform name from the compatible string in the base DTB.

dtoverlay reads the compatible string from the live Device Tree at /proc/device-tree , but you can use the -p option to supply an alternate platform name (useful for dry runs on a different platform).

They both send errors, warnings and any debug output to STDERR.

Here are some examples of different types of properties, with parameters to modify them:

For further examples, there is a large collection of overlay source files hosted in the Raspberry Pi Linux GitHub repository .

Exporting labels

The overlay handling in the firmware and the run-time overlay application using the dtoverlay utility treat labels defined in an overlay as being private to that overlay. This avoids the need to invent globally unique names for labels (which keeps them short), and it allows the same overlay to be used multiple times without clashing (provided some tricks are used - see Special properties ).

Sometimes, however, it is very useful to be able to create a label with one overlay and use it from another. Firmware released since 14th February 2020 has the ability to declare some labels as being global - the __exports__ node:

When this overlay is applied, the loader strips out all symbols except those that have been exported, in this case public , and rewrites the path to make it relative to the target of the fragment containing the label. Overlays loaded after this one can then refer to &public .

Overlay application order

Under most circumstances it shouldn’t matter which order the fragments are applied, but for overlays that patch themselves (where the target of a fragment is a label in the overlay, known as an intra-overlay fragment) it becomes important. In older firmware, fragments are applied strictly in order, top to bottom. With firmware released since 14th February 2020, fragments are applied in two passes:

First the fragments that target other fragments are applied and hidden.

Then the regular fragments are applied.

This split is particularly important for runtime overlays, since step (i) occurs in the dtoverlay utility, and step (ii) is performed by the kernel (which can’t handle intra-overlay fragments).

Using Device Trees on Raspberry Pi

Dtbs, overlays and config.txt.

On a Raspberry Pi it is the job of the loader (one of the start.elf images) to combine overlays with an appropriate base device tree, and then to pass a fully resolved Device Tree to the kernel. The base Device Trees are located alongside start.elf in the FAT partition (/boot from Linux), named bcm2711-rpi-4-b.dtb , bcm2710-rpi-3-b-plus.dtb , etc. Note that some models (3A+, A, A+) will use the "b" equivalents (3B+, B, B+), respectively. This selection is automatic, and allows the same SD card image to be used in a variety of devices.

[ The firmware used to look for a trailer appended to kernels by the mkknlimg utility, but support for this has been withdrawn. ]

The loader now supports builds using bcm2835_defconfig, which selects the upstreamed BCM2835 support. This configuration will cause bcm2835-rpi-b.dtb and bcm2835-rpi-b-plus.dtb to be built. If these files are copied with the kernel, then the loader will attempt to load one of those DTBs by default.

In order to manage Device Tree and overlays, the loader supports a number of config.txt directives:

This will cause the loader to look for overlays/acme-board.dtbo in the firmware partition, which Raspberry Pi OS mounts on /boot . It will then search for parameters foo and level , and assign the indicated values to them.

The loader will also search for an attached HAT with a programmed EEPROM, and load the supporting overlay from there - either directly or by name from the "overlays" directory; this happens without any user intervention.

There are several ways to tell that the kernel is using Device Tree:

The "Machine model:" kernel message during bootup has a board-specific value such as "Raspberry Pi 2 Model B", rather than "BCM2709".

/proc/device-tree exists, and contains subdirectories and files that exactly mirror the nodes and properties of the DT.

With a Device Tree, the kernel will automatically search for and load modules that support the indicated enabled devices. As a result, by creating an appropriate DT overlay for a device you save users of the device from having to edit /etc/modules ; all of the configuration goes in config.txt , and in the case of a HAT, even that step is unnecessary. Note, however, that layered modules such as i2c-dev still need to be loaded explicitly.

The flipside is that because platform devices don’t get created unless requested by the DTB, it should no longer be necessary to blacklist modules that used to be loaded as a result of platform devices defined in the board support code. In fact, current Raspberry Pi OS images ship with no blacklist files (except for some WLAN devices where multiple drivers are available).

DT parameters

As described above, DT parameters are a convenient way to make small changes to a device’s configuration. The current base DTBs support parameters for enabling and controlling the onboard audio, I2C, I2S and SPI interfaces without using dedicated overlays. In use, parameters look like this:

If you have an overlay that defines some parameters, they can be specified either on subsequent lines like this:

or appended to the overlay line like this:

Overlay parameters are only in scope until the next overlay is loaded. In the event of a parameter with the same name being exported by both the overlay and the base, the parameter in the overlay takes precedence; for clarity, it’s recommended that you avoid doing this. To expose the parameter exported by the base DTB instead, end the current overlay scope using:

Board-specific labels and parameters

Raspberry Pi boards have two I2C interfaces. These are nominally split: one for the ARM, and one for VideoCore (the "GPU"). On almost all models, i2c1 belongs to the ARM and i2c0 to VC, where it is used to control the camera and read the HAT EEPROM. However, there are two early revisions of the Model B that have those roles reversed.

To make it possible to use one set of overlays and parameters with all Raspberry Pis, the firmware creates some board-specific DT parameters. These are:

These are aliases for i2c0 , i2c1 , i2c0_baudrate , and i2c1_baudrate . It is recommended that you only use i2c_vc and i2c_vc_baudrate if you really need to - for example, if you are programming a HAT EEPROM (which is better done using a software I2C bus using the i2c-gpio overlay). Enabling i2c_vc can stop the Raspberry Pi Camera or Raspberry Pi Touch Display functioning correctly.

For people writing overlays, the same aliasing has been applied to the labels on the I2C DT nodes. Thus, you should write:

Any overlays using the numeric variants will be modified to use the new aliases.

HATs and Device Tree

A Raspberry Pi HAT is an add-on board with an embedded EEPROM designed for a Raspberry Pi with a 40-pin header. The EEPROM includes any DT overlay required to enable the board (or the name of an overlay to load from the filing system), and this overlay can also expose parameters.

The HAT overlay is automatically loaded by the firmware after the base DTB, so its parameters are accessible until any other overlays are loaded, or until the overlay scope is ended using dtoverlay= . If for some reason you want to suppress the loading of the HAT overlay, put dtoverlay= before any other dtoverlay or dtparam directive.

Dynamic Device Tree

As of Linux 4.4, Raspberry Pi kernels support the dynamic loading of overlays and parameters. Compatible kernels manage a stack of overlays that are applied on top of the base DTB. Changes are immediately reflected in /proc/device-tree and can cause modules to be loaded and platform devices to be created and destroyed.

The use of the word "stack" above is important - overlays can only be added and removed at the top of the stack; changing something further down the stack requires that anything on top of it must first be removed.

There are some new commands for managing overlays:

The dtoverlay command

dtoverlay is a command line utility that loads and removes overlays while the system is running, as well as listing the available overlays and displaying their help information. Use dtoverlay -h to get usage information:

Unlike the config.txt equivalent, all parameters to an overlay must be included in the same command line - the dtparam command is only for parameters of the base DTB.

Two points to note:

Command variants that change kernel state (adding and removing things) require root privilege, so you may need to prefix the command with sudo .

Only overlays and parameters applied at run-time can be unloaded - an overlay or parameter applied by the firmware becomes "baked in" such that it won’t be listed by dtoverlay and can’t be removed.

The dtparam command

dtparam creates and loads an overlay that has largely the same effect as using a dtparam directive in config.txt . In usage it is largely equivalent to dtoverlay with an overlay name of - , but there are a few differences:

dtparam will list the help information for all known parameters of the base DTB. Help on the dtparam command is still available using dtparam -h .

When indicating a parameter for removal, only index numbers can be used (not names).

Not all Linux subsystems respond to the addition of devices at runtime - I2C, SPI and sound devices work, but some won’t.

Guidelines for writing runtime-capable overlays

This area is poorly documented, but here are some accumulated tips:

The creation or deletion of a device object is triggered by a node being added or removed, or by the status of a node changing from disabled to enabled or vice versa. Beware - the absence of a "status" property means the node is enabled.

Don’t create a node within a fragment that will overwrite an existing node in the base DTB - the kernel will rename the new node to make it unique. If you want to change the properties of an existing node, create a fragment that targets it.

ALSA doesn’t prevent its codecs and other components from being unloaded while they are in use. Removing an overlay can cause a kernel exception if it deletes a codec that is still being used by a sound card. Experimentation found that devices are deleted in the reverse of fragment order in the overlay, so placing the node for the card after the nodes for the components allows an orderly shutdown.

The loading of overlays at runtime is a recent addition to the kernel, and so far there is no accepted way to do this from userspace. By hiding the details of this mechanism behind commands the aim is to insulate users from changes in the event that a different kernel interface becomes standardised.

Some overlays work better at run-time than others. Parts of the Device Tree are only used at boot time - changing them using an overlay will not have any effect.

Applying or removing some overlays may cause unexpected behaviour, so it should be done with caution. This is one of the reasons it requires sudo .

Unloading the overlay for an ALSA card can stall if something is actively using ALSA - the LXPanel volume slider plugin demonstrates this effect. To enable overlays for sound cards to be removed, the lxpanelctl utility has been given two new options - alsastop and alsastart - and these are called from the auxiliary scripts dtoverlay-pre and dtoverlay-post before and after overlays are loaded or unloaded, respectively.

Removing an overlay will not cause a loaded module to be unloaded, but it may cause the reference count of some modules to drop to zero. Running rmmod -a twice will cause unused modules to be unloaded.

Overlays have to be removed in reverse order. The commands will allow you to remove an earlier one, but all the intermediate ones will be removed and re-applied, which may have unintended consequences.

Only Device Tree nodes at the top level of the tree and children of a bus node will be probed. For nodes added at run-time there is the further limitation that the bus must register for notifications of the addition and removal of children. However, there are exceptions that break this rule and cause confusion: the kernel explicitly scans the entire tree for some device types - clocks and interrupt controller being the two main ones - in order to (for clocks) initialise them early and/or (for interrupt controllers) in a particular order. This search mechanism only happens during booting and so doesn’t work for nodes added by an overlay at run-time. It is therefore recommended for overlays to place fixed-clock nodes in the root of the tree unless it is guaranteed that the overlay will not be used at run-time.

Supported overlays and parameters

As it is too time-consuming to document the individual overlays here, please refer to the README file found alongside the overlay .dtbo files in /boot/overlays . It is kept up-to-date with additions and changes.

Firmware parameters

The firmware uses the special /chosen node to pass parameters between the bootloader and/or firmware and the operating system.

overlay_prefix - string

The overlay_prefix string selected by config.txt .

os_prefix - string

The os_prefix string selected by config.txt .

rpi-boardrev-ext - 32-bit integer

The extended board revision code from OTP row 33 .

rpi-country-code - 32-bit integer

The country code used used by PiWiz - Pi400 only.

Common bootloader properties /chosen/bootloader

boot-mode - 32-bit integer

The boot-mode used to load the kernel. See BOOT_ORDER .

partition - 32-bit integer

The partition number used during boot. If a boot.img ramdisk is loaded then this refers to partition that the ramdisk was loaded from rather than the partition number within the ramdisk.

pm_rsts - 32-bit integer

The value of the PM_RSTS register during boot.

tryboot - 32-bit integer

Set to 1 if the tryboot flag was set at boot.

BCM2711 specific bootloader properties /chosen/bootloader

The following properties are specific to BCM2711 SPI EEPROM bootloader.

build_timestamp - 32-bit integer

The UTC build time for the EEPROM bootloader.

capabilities - 32-bit integer

This bit-field describes the features supported by the current bootloader. This may be used to check whether a feature (e.g. USB boot) is supported before enabling it in the bootloader EEPROM config.

update_timestamp - 32-bit integer

The UTC update timestamp set by rpi-eeprom-update .

signed_boot - 32-bit integer

If secure-boot is enabled then this bit-field will be non-zero. The individual bits indicate the current secure-boot configuration.

version - string

The Git version string for the bootloader.

BCM2711 USB boot properties /chosen/bootloader/usb

The following properties are defined if the system was booted from USB. These may be used to uniquely identify the USB boot device.

usb-version - 32-bit integer

The USB major protocol version (2 or 3).

route-string - 32-bit integer The USB route-string identifier for the device as defined by the USB 3.0 specification.

root-hub-port-number - 32-bit integer

The root hub port number that the boot device is connected to - possibly via other USB hubs.

lun - 32-bit integer

The Logical Unit Number for the mass-storage device.

NVMEM nodes

The firmware provides read-only, in-memory copies of portions of the bootloader EEPROM via the NVMEM Subsystem.

Each region appears as an NVMEM device under /sys/bus/nvmem/devices/ with a named alias under /sys/firmware/devicetree/base/aliases .

Example shell script code for reading an NVMEM mode from rpi-eeprom-update

The blconfig alias refers to an NVMEM device that stores a copy of the bootloader EEPROM config file.

The blpubkey alias points to an NVMEM device that stores a copy of the bootloader EEPROM public key (if defined) in binary format. The rpi-bootloader-key-convert utility can be used to convert the data into PEM format for use with OpenSSL.

See also: secure-boot


The loader will skip over missing overlays and bad parameters, but if there are serious errors, such as a missing or corrupt base DTB or a failed overlay merge, then the loader will fall back to a non-DT boot. If this happens, or if your settings don’t behave as you expect, it is worth checking for warnings or errors from the loader:

Extra debugging can be enabled by adding dtdebug=1 to config.txt .

You can create a human-readable representation of the current state of DT like this:

This can be useful to see the effect of merging overlays onto the underlying tree.

If kernel modules don’t load as expected, check that they aren’t blacklisted in /etc/modprobe.d/raspi-blacklist.conf ; blacklisting shouldn’t be necessary when using Device Tree. If that shows nothing untoward, you can also check that the module is exporting the correct aliases by searching /lib/modules/<version>/modules.alias for the compatible value. Otherwise, your driver is probably missing either:

Failing that, depmod has failed or the updated modules haven’t been installed on the target filesystem.

Testing overlays using dtmerge, dtdiff and ovmerge

Alongside the dtoverlay and dtparam commands is a utility for applying an overlay to a DTB - dtmerge . To use it you first need to obtain your base DTB, which can be obtained in one of two ways:

a) generate it from the live DT state in /proc/device-tree :

This will include any overlays and parameters you have applied so far, either in config.txt or by loading them at runtime, which may or may not be what you want. Alternatively…​

b) copy it from the source DTBs in /boot. This won’t include overlays and parameters, but it also won’t include any other modifications by the firmware. To allow testing of all overlays, the dtmerge utility will create some of the board-specific aliases ("i2c_arm", etc.), but this means that the result of a merge will include more differences from the original DTB than you might expect. The solution to this is to use dtmerge to make the copy:

(the - indicates an absent overlay name).

You can now try applying an overlay or parameter:

which will return:

You can also compare different overlays or parameters.

The Utils repo includes another DT utility - ovmerge . Unlike dtmerge , ovmerge combines file and applies overlays in source form. Because the overlay is never compiled, labels are preserved and the result is usually more readable. It also has a number of other tricks, such as the ability to list the order of file inclusion.

Forcing a specific Device Tree

If you have very specific needs that aren’t supported by the default DTBs, or if you just want to experiment with writing your own DTs, you can tell the loader to load an alternate DTB file like this:

Disabling Device Tree usage

Since the switch to the 4.4 kernel and the use of more upstream drivers, Device Tree usage is required in Raspberry Pi Linux kernels. However, for bare metal and other OSs, the method of disabling DT usage is to add:

to config.txt .

Shortcuts and syntax variants

The loader understands a few shortcuts:

can be shortened to:

( i2c is an alias of i2c_arm , and the =on is assumed). It also still accepts the long-form versions: device_tree_overlay and device_tree_param .

Other DT commands available in config.txt

device_tree_address This is used to override the address where the firmware loads the device tree (not dt-blob). By default the firmware will choose a suitable place.

device_tree_end This sets an (exclusive) limit to the loaded device tree. By default the device tree can grow to the end of usable memory, which is almost certainly what is required.

dtdebug If non-zero, turn on some extra logging for the firmware’s device tree processing.

enable_uart Enable the primary/console UART (ttyS0 on a Raspberry Pi 3, 4, 400, Zero W and Zero 2 W, ttyAMA0 otherwise - unless swapped with an overlay such as miniuart-bt). If the primary UART is ttyAMA0 then enable_uart defaults to 1 (enabled), otherwise it defaults to 0 (disabled). This is because it is necessary to stop the core frequency from changing which would make ttyS0 unusable, so enable_uart=1 implies core_freq=250 (unless force_turbo=1 ). In some cases this is a performance hit, so it is off by default.

overlay_prefix Specifies a subdirectory/prefix from which to load overlays - defaults to "overlays/". Note the trailing "/". If desired you can add something after the final "/" to add a prefix to each file, although this is not likely to be needed.

Further ports can be controlled by the DT, for more details see section 3 .

Further help

If you’ve read through this document and not found the answer to a Device Tree problem, there is help available. The author can usually be found on Raspberry Pi forums, particularly the Device Tree forum.

The Kernel Command Line

The Linux kernel accepts a command line of parameters during boot. On the Raspberry Pi, this command line is defined in a file in the boot partition, called cmdline.txt. This is a simple text file that can be edited using any text editor, e.g. Nano.

The command line that was passed to the kernel at boot time can be displayed using cat /proc/cmdline . It will not be exactly the same as that in cmdline.txt as the firmware can make changes to it prior to launching the kernel.

Command Line Options

There are many kernel command line parameters, some of which are defined by the kernel. Others are defined by code that the kernel may be using, such as the Plymouth splash screen system.

Standard Entries

console: defines the serial console. There are usually two entries:



root: defines the location of the root filesystem, e.g. root=/dev/mmcblk0p2 means multimedia card block 0 partition 2.

rootfstype: defines what type of filesystem the rootfs uses, e.g. rootfstype=ext4

quiet: sets the default kernel log level to KERN_WARNING , which suppresses all but very serious log messages during boot.

Display Entries in FKMS and KMS modes

The firmware automatically adds a preferred resolution and overscan settings via an entry such as:

This default entry can be modified by duplicating the entry above manually in /boot/cmdline.txt and making required changes to the margin parameters. In addition, it is possible to add rotation and reflect parameters as documented in the standard Linux framebuffer documentation . By default the margin_* options are set from the overscan entries in config.txt, if present. The firmware can be prevented from making any KMS specific changes to the command line by adding disable_fw_kms_setup=1 to config.txt

An example entry may be as follows:

Possible options for the display type, the first part of the video= entry, are as follows:

Other Entries (not exhaustive)

splash: tells the boot to use a splash screen via the Plymouth module.

plymouth.ignore-serial-consoles: normally if the Plymouth module is enabled it will prevent boot messages from appearing on any serial console which may be present. This flag tells Plymouth to ignore all serial consoles, making boot messages visible again, as they would be if Plymouth was not running.

dwc_otg.lpm_enable=0: turns off Link Power Management (LPM) in the dwc_otg driver; the dwc_otg driver is the driver for the USB controller built into the processor used on Raspberry Pi computers.

dwc_otg.speed: sets the speed of the USB controller built into the processor on Raspberry Pi computers. dwc_otg.speed=1 will set it to full speed (USB 1.0), which is slower than high speed (USB 2.0). This option should not be set except during troubleshooting of problems with USB devices.

smsc95xx.turbo_mode: enables/disables the wired networking driver turbo mode. smsc95xx.turbo_mode=N turns turbo mode off.

usbhid.mousepoll: specifies the mouse polling interval. If you have problems with a slow or erratic wireless mouse, setting this to 0 might help: usbhid.mousepoll=0 .

Configuring UARTs

There are two types of UART available on the Raspberry Pi - PL011 and mini UART. The PL011 is a capable, broadly 16550-compatible UART, while the mini UART has a reduced feature set.

All UARTs on the Raspberry Pi are 3.3V only - damage will occur if they are connected to 5V systems. An adaptor can be used to connect to 5V systems. Alternatively, low-cost USB to 3.3V serial adaptors are available from various third parties.

Raspberry Pi Zero, 1, 2 and 3

The Raspberry Pi Zero, 1, 2, and 3 each contain two UARTs as follows:

Raspberry Pi 4 and 400

The Raspberry Pi 4B and 400 have an additional four PL011s, which are disabled by default:

CM1, CM3, CM3+ and CM4

The first generation Compute Module, together with Compute Module 3 and Compute Module 3+ each have two UARTs, while Compute Module 4 has six UARTs as described above.

On all models of Compute Module, the UARTs are disabled by default and can be explicitly enabled using a device tree overlay. You may also specify which GPIO pins to use, for example:

Primary UART

On the Raspberry Pi, one UART is selected to be present on GPIO 14 (transmit) and 15 (receive) - this is the primary UART. By default, this will also be the UART on which a Linux console may be present. Note that GPIO 14 is pin 8 on the GPIO header, while GPIO 15 is pin 10.

Secondary UART

The secondary UART is not normally present on the GPIO connector. By default, the secondary UART is connected to the Bluetooth side of the combined wireless LAN/Bluetooth controller, on models which contain this controller.

Primary and Secondary UART

The following table summarises the assignment of the first two UARTs:

Linux devices on Raspberry Pi OS:

Mini-UART and CPU Core Frequency

In order to use the mini UART, you need to configure the Raspberry Pi to use a fixed VPU core clock frequency. This is because the mini UART clock is linked to the VPU core clock, so that when the core clock frequency changes, the UART baud rate will also change. The enable_uart and core_freq settings can be added to config.txt to change the behaviour of the mini UART. The following table summarises the possible combinations:

The default state of the enable_uart flag depends on which UART is the primary UART:

Disabling the Linux Serial Console

By default, the primary UART is assigned to the Linux console. If you wish to use the primary UART for other purposes, you must reconfigure Raspberry Pi OS. This can be done by using raspi-config :

Start raspi-config: sudo raspi-config .

Select option 3 - Interface Options.

Select option P6 - Serial Port.

At the prompt Would you like a login shell to be accessible over serial? answer 'No'

At the prompt Would you like the serial port hardware to be enabled? answer 'Yes'

Exit raspi-config and reboot the Raspberry Pi for changes to take effect.

Enabling Early Console for Linux

Although the Linux kernel starts the UARTs relatively early in the boot process, it is still long after some critical bits of infrastructure have been set up. A failure in those early stages can be hard to diagnose without access to the kernel log messages from that time. To enable earlycon support for one of the UARTs, add one of the following options to cmdline.txt , depending on which UART is the primary:

For Raspberry Pi 4, 400 and Compute Module 4:

For Raspberry Pi 2, Pi 3 and Compute Module 3:

For Raspberry Pi 1, Pi Zero and Compute Module 1:

The baudrate defaults to 115200bps.

UARTs and Device Tree

Various UART Device Tree overlay definitions can be found in the kernel GitHub tree . The two most useful overlays are disable-bt and miniuart-bt .

disable-bt disables the Bluetooth device and makes the first PL011 (UART0) the primary UART. You must also disable the system service that initialises the modem, so it does not connect to the UART, using sudo systemctl disable hciuart .

miniuart-bt switches the Bluetooth function to use the mini UART, and makes the first PL011 (UART0) the primary UART. Note that this may reduce the maximum usable baud rate (see mini UART limitations below). You must also set the VPU core clock to a fixed frequency using either force_turbo=1 or core_freq=250 .

The overlays uart2 , uart3 , uart4 , and uart5 are used to enable the four additional UARTs on the Raspberry Pi 4. There are other UART-specific overlays in the folder. Refer to /boot/overlays/README for details on Device Tree overlays, or run dtoverlay -h overlay-name for descriptions and usage information.

You add a line to the config.txt file to apply a Device Tree overlay . Note that the -overlay.dts part of the filename is removed. For example:

PL011 and mini-UART

There are some differences between PL011 UARTs and mini-UART.

The mini-UART has smaller FIFOs. Combined with the lack of flow control, this makes it more prone to losing characters at higher baudrates. It is also generally less capable than a PL011, mainly due to its baud rate link to the VPU clock speed.

The particular deficiencies of the mini UART compared to a PL011 are :

No break detection

No framing errors detection

No parity bit

No receive timeout interrupt

Neither the mini UART nor the BCM2835 implementation of the PL011 have DCD, DSR, DTR or RI signals.

Further documentation on the mini UART can be found in the SoC peripherals document .

LED Warning Flash Codes

If a Raspberry Pi fails to boot for some reason, or has to shut down, in many cases an LED will be flashed a specific number of times to indicate what happened. The LED will blink for a number of long flashes (0 or more), then short flashes, to indicate the exact status. In most cases, the pattern will repeat after a 2 second gap.

Securing your Raspberry Pi

The security of your Raspberry Pi is important. Gaps in security leave your Raspberry Pi open to hackers who can then use it without your permission.

What level of security you need depends on how you wish to use your Raspberry Pi. For example, if you are simply using your Raspberry Pi on your home network, behind a router with a firewall, then it is already quite secure by default.

However, if you wish to expose your Raspberry Pi directly to the internet, either with a direct connection (unlikely) or by letting certain protocols through your router firewall (e.g. SSH), then you need to make some basic security changes.

Even if you are hidden behind a firewall, it is sensible to take security seriously. This documentation will describe some ways of improving the security of your Raspberry Pi. Please note, though, that it is not exhaustive.

Change the Default Password

The default username and password is used for every single Raspberry Pi running Raspberry Pi OS. So, if you can get access to a Raspberry Pi, and these settings have not been changed, you have root access to that Raspberry Pi.

So the first thing to do is change the password. This can be done via the raspi-config application, or from the command line.

Select option 2, and follow the instructions to change the password.

However, all raspi-config does is start up the command line passwd application, which you can do from the command line. So instead you can type in your new password and confirm it.

Changing your Username

You can, of course, make your Raspberry Pi even more secure by also changing your username. All Raspberry Pis come with the default username pi , so changing this will immediately make your Raspberry Pi more secure.

To add a new user, enter:

You will be prompted to create a password for the new user.

The new user will have a home directory at /home/alice/ .

To add them to the sudo group to give them sudo permissions as well as all of the other necessary permissions:

You can check your permissions are in place (i.e. you can use sudo ) by trying the following:

If it runs successfully, then you can be sure that the new account is in the sudo group.

Once you have confirmed that the new account is working, you can delete the pi user. In order to do this, you’ll need to first change the autologin user to your new user alice , with the following:

Select option 1, S5 Boot / Auto login , and say yes to reboot. Please note that with the current Raspberry Pi OS distribution, there are some aspects that require the pi user to be present. If you are unsure whether you will be affected by this, then leave the pi user in place. Work is being done to reduce the dependency on the pi user.

To delete the pi user, type the following:

This command will delete the pi user but will leave the /home/pi folder. If necessary, you can use the command below to remove the home folder for the pi user at the same time. Note the data in this folder will be permanently deleted, so make sure any required data is stored elsewhere.

This command will result in a warning that the group pi has no more members. The deluser command removes both the pi user and the pi group though, so the warning can be safely ignored.

Make sudo Require a Password

Placing sudo in front of a command runs it as a superuser, and by default, that does not need a password. In general, this is not a problem. However, if your Raspberry Pi is exposed to the internet and somehow becomes exploited (perhaps via a webpage exploit for example), the attacker will be able to change things that require superuser credentials, unless you have set sudo to require a password.

To force sudo to require a password, enter:

and change the pi entry (or whichever usernames have superuser rights) to:

Then save the file: it will be checked for any syntax errors. If no errors were detected, the file will be saved and you will be returned to the shell prompt. If errors were detected, you will be asked 'what now?' Press the 'enter' key on your keyboard: this will bring up a list of options. You will probably want to use 'e' for '(e)dit sudoers file again', so you can edit the file and fix the problem.

Updating Raspberry Pi OS

An up-to-date distribution contains all the latest security fixes, so you should go ahead and update your version of Raspberry Pi OS to the latest version.

If you are using SSH to connect to your Raspberry Pi, it can be worthwhile to add a cron job that specifically updates the ssh-server. The following command, perhaps as a daily cron job, will ensure you have the latest SSH security fixes promptly, independent of your normal update process.

Improving SSH Security

SSH is a common way of accessing a Raspberry Pi remotely. By default, logging in with SSH requires a username/password pair, and there are ways to make this more secure. An even more secure method is to use key based authentication.

Improving username/password security

The most important thing to do is ensure you have a very robust password. If your Raspberry Pi is exposed to the internet, the password needs to be very secure. This will help to avoid dictionary attacks or the like.

You can also allow or deny specific users by altering the sshd configuration.

Add, edit, or append to the end of the file the following line, which contains the usernames you wish to allow to log in:

You can also use DenyUsers to specifically stop some usernames from logging in:

After the change you will need to restart the sshd service using sudo systemctl restart ssh or reboot so the changes take effect.

Using key-based authentication.

Key pairs are two cryptographically secure keys. One is private, and one is public. They can be used to authenticate a client to an SSH server (in this case the Raspberry Pi).

The client generates two keys, which are cryptographically linked to each other. The private key should never be released, but the public key can be freely shared. The SSH server takes a copy of the public key, and, when a link is requested, uses this key to send the client a challenge message, which the client will encrypt using the private key. If the server can use the public key to decrypt this message back to the original challenge message, then the identity of the client can be confirmed.

Generating a key pair in Linux is done using the ssh-keygen command on the client ; the keys are stored by default in the .ssh folder in the user’s home directory. The private key will be called id_rsa and the associated public key will be called . The key will be 2048 bits long: breaking the encryption on a key of that length would take an extremely long time, so it is very secure. You can make longer keys if the situation demands it. Note that you should only do the generation process once: if repeated, it will overwrite any previous generated keys. Anything relying on those old keys will need to be updated to the new keys.

You will be prompted for a passphrase during key generation: this is an extra level of security. For the moment, leave this blank.

The public key now needs to be moved on to the server: see Copy your public key to your Raspberry Pi .

Finally, we need to disable password logins, so that all authentication is done by the key pairs.

There are three lines that need to be changed to no , if they are not set that way already:

Save the file and either restart the ssh system with sudo service ssh reload or reboot.

Install a Firewall

There are many firewall solutions available for Linux. Most use the underlying iptables project to provide packet filtering. This project sits over the Linux netfiltering system. iptables is installed by default on Raspberry Pi OS, but is not set up. Setting it up can be a complicated task, and one project that provides a simpler interface than iptables is ufw , which stands for 'Uncomplicated Fire Wall'. This is the default firewall tool in Ubuntu, and can be easily installed on your Raspberry Pi:

ufw is a fairly straightforward command line tool, although there are some GUIs available for it. This document will describe a few of the basic command line options. Note that ufw needs to be run with superuser privileges, so all commands are preceded with sudo . It is also possible to use the option --dry-run any ufw commands, which indicates the results of the command without actually making any changes.

To enable the firewall, which will also ensure it starts up on boot, use:

To disable the firewall, and disable start up on boot, use:

Allow a particular port to have access (we have used port 22 in our example):

Denying access on a port is also very simple (again, we have used port 22 as an example):

You can also specify which service you are allowing or denying on a port. In this example, we are denying tcp on port 22:

You can specify the service even if you do not know which port it uses. This example allows the ssh service access through the firewall:

The status command lists all current settings for the firewall:

The rules can be quite complicated, allowing specific IP addresses to be blocked, specifying in which direction traffic is allowed, or limiting the number of attempts to connect, for example to help defeat a Denial of Service (DoS) attack. You can also specify the device rules are to be applied to (e.g. eth0, wlan0). Please refer to the ufw man page ( man ufw ) for full details, but here are some examples of more sophisticated commands.

Limit login attempts on ssh port using tcp: this denies connection if an IP address has attempted to connect six or more times in the last 30 seconds:

Deny access to port 30 from IP address

Installing fail2ban

If you are using your Raspberry Pi as some sort of server, for example an ssh or a webserver, your firewall will have deliberate 'holes' in it to let the server traffic through. In these cases, Fail2ban can be useful. Fail2ban, written in Python, is a scanner that examines the log files produced by the Raspberry Pi, and checks them for suspicious activity. It catches things like multiple brute-force attempts to log in, and can inform any installed firewall to stop further login attempts from suspicious IP addresses. It saves you having to manually check log files for intrusion attempts and then update the firewall (via iptables ) to prevent them.

Install fail2ban using the following command:

On installation, Fail2ban creates a folder /etc/fail2ban in which there is a configuration file called jail.conf . This needs to be copied to jail.local to enable it. Inside this configuration file are a set of default options, together with options for checking specific services for abnormalities. Do the following to examine/change the rules that are used for ssh :

Add the following section to the jail.local file. On some versions of fail2ban this section may already exist, so update this pre-existing section if it is there.

As you can see, this section is named ssh, is enabled, examines the ssh port, filters using the sshd parameters, parses the /var/log/auth.log for malicious activity, and allows six retries before the detection threshold is reached. Checking the default section, we can see that the default banning action is:

iptables-multiport means that the Fail2ban system will run the /etc/fail2ban/action.d/iptables-multiport.conf file when the detection threshold is reached. There are a number of different action configuration files that can be used. Multiport bans all access on all ports.

If you want to permanently ban an IP address after three failed attempts, you can change the maxretry value in the [ssh] section, and set the bantime to a negative number:

Configuring Screen Blanking

You can configure your Raspberry Pi to use a screen saver or to blank the screen.

When running without a graphical desktop, Raspberry Pi OS will blank the screen after 10 minutes without user input, e.g. mouse movement or key presses.

The current setting, in seconds, can be displayed using:

To change the consoleblank setting, edit the kernel command line:

The file /boot/cmdline.txt contains a single line of text. Add consoleblank=n to have the console blank after n seconds of inactivity. For example consoleblank=300 will cause the console to blank after 300 seconds, 5 minutes, of inactivity. Make sure that you add your consoleblank option to the single line of text already in the cmdline.txt file. To disable screen blanking, set consoleblank=0 .

You can also use the raspi-config tool to disable screen blanking. Note that the screen blanking setting in raspi-config also controls screen blanking when the graphical desktop is running.

On the Desktop

Raspberry Pi OS will blank the graphical desktop after 10 minutes without user input. You can disable this by changing the 'Screen Blanking' option in the Raspberry Pi Configuration tool, which is available on the Preferences menu. Note that the 'Screen Blanking' option also controls screen blanking when the graphical desktop is not running.

There is also a graphical screensaver available, which can be installed as follows:

This may take a few minutes.

Once this has been installed, you can find the Screensaver application on the Preferences menu: it provides many options for setting up the screensaver, including disabling it completely.

Switching off HDMI

If you want to switch off the video display entirely, you can use the vcgencmd command,

Video will not come back on until you reboot or switch it back on:

The boot Folder

In a basic Raspberry Pi OS install, the boot files are stored on the first partition of the SD card, which is formatted with the FAT file system. This means that it can be read on Windows, macOS, and Linux devices.

When the Raspberry Pi is powered on, it loads various files from the boot partition/folder in order to start up the various processors, then it boots the Linux kernel.

Once Linux has booted, the boot partition is mounted as /boot .

Boot Folder Contents


This is the bootloader, which is loaded by the SoC on boot, does some very basic setup, and then loads one of the start*.elf files. bootcode.bin is not used on the Raspberry Pi 4, because it has been replaced by boot code in the onboard EEPROM .

start.elf, start_x.elf, start_db.elf, start_cd.elf, start4.elf, start4x.elf, start4db.elf, start4cd.elf

These are binary blobs (firmware) that are loaded on to the VideoCore GPU in the SoC, which then take over the boot process. start.elf is the basic firmware, start_x.elf also includes camera drivers and codecs, start_db.elf can be used for debugging purposes and start_cd.elf is a cut-down version of the firmware. start_cd.elf removes support for hardware blocks such as cameras, codecs and 3D as well as having initial framebuffer limitations. The cut-down firmware is automatically used when gpu_mem=16 is specified in config.txt .

start4.elf , start4x.elf , start4db.elf and start4cd.elf are equivalent firmware files specific to the Raspberry Pi 4-series (Model 4B, Pi 400, Compute Module 4 and Compute Module 4S).

More information on how to use these files can be found in the config.txt section .

These are linker files and are matched pairs with the start*.elf files listed in the previous section.


The kernel command line passed in to the kernel when it boots.

Contains many configuration parameters for setting up the Raspberry Pi. See the config.txt section .

Some text-based housekeeping information containing the date and git commit ID of the distribution.

ssh or ssh.txt

When this file is present, SSH will be enabled on boot. The contents don’t matter, it can be empty. SSH is otherwise disabled by default.


This is the file to configure wireless network settings (if the hardware is capable of it). Edit the country code and the network part to fit your case. More information on how to use this file can be found in the wireless/headless section .

Device Tree files

There are various Device Tree blob files, which have the extension .dtb . These contain the hardware definitions of the various models of Raspberry Pi, and are used on boot to set up the kernel according to which Raspberry Pi model is detected .

Kernel Files

The boot folder will contain various kernel image files, used for the different Raspberry Pi models:

The Overlays Folder

The overlays sub-folder contains Device Tree overlays. These are used to configure various hardware devices that may be attached to the system, for example the Raspberry Pi Touch Display or third-party sound boards. These overlays are selected using entries in config.txt  — see 'Device Trees, overlays and parameters, part 2' for more info .

Raspberry Pi documentation is copyright © 2012-2023 Raspberry Pi Ltd and is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA) licence.

Some content originates from the eLinux wiki , and is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported licence.

The terms HDMI, HDMI High-Definition Multimedia Interface, HDMI trade dress and the HDMI Logos are trademarks or registered trademarks of HDMI Licensing Administrator, Inc

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Raspberry Pi 3 can't update IP address

I can't update an IP address from DHCP to static. I changed the /etc/network/interfaces file and I rebooted the system but IP still is the same as the one that DHCP gave me before.

I changed /etc/network/interfaces to:

I got this error in syslog when I executed /etc/init.d/networking restart :

uname -a gives:

And /etc/os-release contains:

I tried to execute the script /sbin/ifup , result:

techraf's user avatar

  • 1 I think you mean "downgrade", but if you are determined to use a static address anyway see How do I set up networking/WiFi/Static IP –  Milliways Aug 30, 2016 at 9:51

4 Answers 4

If you are really determined to do it this way you need to disable the DHCP client daemon and switch to standard Debian networking:

  • root@raspberrypi:/home/pi# sudo systemctl disable dhcpcd Synchronizing state for dhcpcd.service with sysvinit using update-rc.d... Executing /usr/sbin/update-rc.d dhcpcd defaults insserv: warning: current start runlevel(s) (empty) of script dhcpcd' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script dhcpcd' overrides LSB defaults (0 1 6). –  Miren Aug 31, 2016 at 8:54
  • insserv: script iptables.klm: service Iptables already provided! insserv: script iptables.klm: service Initial already provided! insserv: script iptables.klm: service Config already provided! –  Miren Aug 31, 2016 at 8:54
  • 1 @Miren the comments are illegible. Paste any code into your question. From the look of it you are running as root . This is not normal for Raspbian, and requires system changes. Most advice will assume you are running as a normal user on an unmodified system. If you are not you need to clarify exactly what you have done. –  Milliways Sep 1, 2016 at 0:22

The best soluition that I have come across is this one. Solved my requirement for static addresses for both eth0 and wlan0 on my Rpi3

dhcpcd vs /etc/network/interfaces

good luck, ianm

Community's user avatar

Looks like the way we set the static ip has changed. There is a post here in the link which talks about static ip. Please look at the answer from steve(Answer 2).

Raspberry seems to ignore static ip setting

Refer the post: Connecting Raspberry Pi (running Raspbian) to open WiFi using only the command line for more details.

Varad A G's user avatar

  • I still have the same problem. IP address doesnt update. –  Miren Aug 30, 2016 at 9:38
  • Have you actually tried this before giving others advice. Unless you disable dhcpcd it will still attempt to allocate addresses. –  Milliways Aug 30, 2016 at 9:59
  • @Milliways Yeah I have tried it on my debian system but not on my raspberry pi. I have a Ubuntu 12.04 in which I have set static ip for some testing purpose. I will be accessing my Rpi once I reach home and I don't have access now. I will give detailed steps once I set it up on my Raspberry pi. I will delete the answer if this is not allowing to set it up in my raspberry pi. Also what you mentioned is a striking point we have to disable the dhcpd service to pick up the static ip. –  Varad A G Aug 30, 2016 at 12:34
  • It probably works on Ubuntu (although I have not tried on 16.04 - but then I spend most of my time trying to convince people NOT to use static) and does work on Wheezy and you can configure Jessie to use the traditional Debian networking. For better or worse (I see improved performance) the Foundation uses dhcpcd by default. Ubuntu (at least current releases) uses Network Manager . Either works, but they are not the only way. See How do I set up networking/WiFi/Static IP for the Raspbian approach. –  Milliways Aug 30, 2016 at 12:43
  • @Milliways I tried this out in my Raspberry pi and this configuration works for me. I am pasting my "interfaces" file by editing the answer. –  Varad A G Aug 30, 2016 at 16:28

You can edit the dhcpd.conf file to set a static ip in Raspbian Jessie . This is how I changed mine.

sudo nano /etc/dhcpcd.conf

Go to the end of the file and edit the following based on your needs.

screenslaver's user avatar

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct .

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

  • The Overflow Blog
  • If you want to address tech debt, quantify it first
  • Fighting comment spam at Facebook scale (Ep. 602)
  • Featured on Meta
  • Moderation strike: Results of negotiations
  • Our Design Vision for Stack Overflow and the Stack Exchange network

Hot Network Questions

  • How can I make Manipulate faster?
  • RAID configuration on new server
  • Is quadrature still considered part of numerical analysis?
  • When in Rome... or perhaps Ankh-Morpork?
  • LaTeX macro for summing numbers
  • The complexity of checking for short cycles in a graph
  • Probability approximation and computation given Compound Poisson random variable
  • What are all the possible codes for {{A\\B}}?
  • Enthalpy change of a solution of of 1-pentanol in 1-butanol
  • Do interspecies couples exist in Zootopia?
  • Is saturday considered weekday or weekend, or something else?
  • how early can people build a giant clock?
  • What type of security measure/contingent conditions could make jumping into a portal impossible inside a laboratory?
  • Note to African American colleague - targeted crime
  • Why do programming languages use delimiters (quotes) for strings?
  • Is the 'a nice' in 'a nice to have' grammatical?
  • Is there a (proposed) name for Coatlicue's progenitor?
  • Does the Axiom of Choice imply the existence of all the choice functions of a set?
  • Meaning of a joke in the Big Bang Theory: "when your locus coeruleus sits around the house, it sits around the house"
  • What does в сложн. сл. mean in Russian dictionary?
  • Why are stars made from hydrogen and helium and not other elements?
  • Is there any clear evidence that private universities tend to be better than public ones?
  • Which airline is liable for compensation in case of missed connection?
  • I am looking for the action verb in "…he having more plenteous ideas of the same order…"

change ip raspberry pi

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

the pi hut logo

  • Compute Module 4
  • Kits & Bundles
  • Flash Drives
  • Card Readers
  • Accessories
  • Power Supplies
  • Power over Ethernet (PoE)
  • Breakout Garden
  • GPS, GSM & LoRa
  • Motor & Servo Control
  • Port Expanders
  • Power Management
  • Prototyping
  • Real Time Clock
  • Serial & I2C
  • Raspberry Pi 4
  • Raspberry Pi 3
  • Raspberry Pi 3A+
  • Raspberry Pi Zero
  • Retro Gaming
  • Media Centre
  • Display/Screen
  • DIN & Rack
  • Case Accessories
  • Heatsinks & Fans
  • Cooling Cases
  • Camera Modules
  • USB Cameras
  • Mini Displays
  • Medium Displays
  • Large Displays
  • Touchscreen Displays
  • ePaper Displays
  • GPIO Connection
  • HDMI Connection
  • Display Accessories
  • Adapters & Accessories
  • Game Controllers
  • Keyboards & Mice
  • Remote Controls
  • WiFi & Ethernet
  • Buttons & Joysticks
  • HATs & Control Boards
  • Merch & Accessories
  • Wires & Connectors
  • Merch & Clothing
  • Notepads & Pens
  • Peripherals
  • Stickers & Badges
  • Amplifiers & Modules
  • Cables & Connectors
  • Microphones
  • Speakers & Headphones
  • ADC & DAC
  • Flat Cable (FFC/FPC)
  • GPIO Expanders
  • GPS & GSM
  • Logic Level
  • DIY Cables & Connectors
  • Buttons & Switches
  • Component Kits
  • Integrated Circuits
  • Oscillators
  • Transistors
  • Circuit Playground
  • QT Py & XIAO
  • Trinkey & Trinket
  • Kits & Projects
  • DotStar & APA102
  • NeoPixels & WS2812
  • Standard LEDs
  • Strips & Sticks
  • Battery Holders
  • Boost Converters
  • Power over Ethernet
  • Regulators & Buck Converters
  • Breadboards
  • Crocodile Clips
  • Jumper Wires
  • PCBs & Perfboard
  • SMT Breakouts
  • Wire & Heat Shrink
  • Motor Drivers
  • Mounting Hubs
  • Stepper Motors
  • Wheels & Tracks
  • Accelerometers
  • Body & Muscle
  • Environment & Air Quality
  • Fingerprint
  • Force & Weight
  • Hall, Reed & Magnet
  • IMU & Gyro
  • Light & Colour
  • Line Following
  • Liquid & Moisture
  • NFC & RFID
  • Temperature
  • Tilt & Vibration
  • Voltage & Current
  • Filament & Resin
  • The micro:bit
  • Add-ons & Extensions
  • Cables & Accessories
  • Official Arduino Boards
  • Compatible Boards
  • GPS & GSM Shields
  • Input & Button Shields
  • LED Shields
  • Prototyping Shields
  • Relay Shields
  • Robotics Shields
  • Sensor Shields
  • Serial Shields
  • Other Shields
  • Raspberry Pi Gifts
  • Maker Gifts
  • Micro:bit Gifts
  • Arduino Gifts
  • Gifts Under £10
  • Gifts Under £20
  • Gifts Under £50

Login / Signup

from just £2.99

134,000+ reviews

support portal

order by 2pm*

Your cart is empty

How to give your Raspberry Pi a Static IP Address

How to give your Raspberry Pi a Static IP Address - UPDATE

This tutorial will show you how to set a static IP address on your Raspberry Pi with the release of Raspbian Jessie. At the time of writing, the latest release date of Raspbian Jessie is 18-03-2016 with Kernal version 4.1 (but this should work on most versions).

We recommend doing this on a fresh install, however if you have attempted to set a static IP address already, you may have found yourself editing the interfaces file (/etc/network/interfaces). I hope you made a backup, because you’ll need to remove any edits you have made, and revert it back to its original state!

The following is done over SSH, but you could just as well plug your Pi into a monitor, hook up a keyboard and mouse, and use the Terminal instead.

Start by editing the dhcpcd.conf file

sudo nano /etc/dhcpcd.conf

change ip raspberry pi

Scroll all the way to the bottom of the file and add one, or both of the following snippets. Depending on whether you want to set a static IP address for a wired connection or a wireless connection eth0 = wired, wlan0 = wireless.

You’ll need to edit the numbers in the snippet so they match your network configuration.

interface = This defines which network interface you are setting the configuration for. static ip_address = This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end) static routers = This is the IP address of your gateway (probably the IP address or your router) static domain_name_servers = This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.

To exit the editor, press ctrl+x To save your changes press the letter “Y” then hit enter

Now all you need to do is reboot, and everything should be set!

You can double check by typing

And checking the interfaces IP address

change ip raspberry pi

Featured Products

Raspberry Pi 4 Model B - The Pi Hut

Ulrich Kneidl

in a special use case i need two different addresses over the ethernet/lan port. for example and at the same time is this easy to realize? somewhere i read about a command eth0 add, but i don’t know how to use it.

Leave a comment

All comments are moderated before being published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

change ip raspberry pi

Keep Your Cupboard Contents Fresh With Grocy on Raspberry Pi

By hosting Grocy on your Raspberry Pi, you can catalog and organize your groceries, meals, and a whole lot more.

A well-stocked fridge is essential to the efficient running of a well-ordered home, and no-one wants to open the larder to find shelves dripping with expired and moldy produce.

Grocy is a self-hosted stock-management app you can host on a Raspberry Pi, to help you keep track of your consumables, plan meals, and efficiently manage housework.

Why Manage Your Groceries With Grocy on Raspberry Pi?

Everybody hates waste. Whether it's because foodstuffs go past their use-by dates because you didn't check them in time, or making unnecessary trips to the store because you didn't plan your meals ahead of time, waste is bad for the environment and bad for your mental health.

Grocy is open-source software that'll help you keep an accurate inventory of your consumables, so you can plan ahead of time, minimize wastage, and save money.

How to Install Grocy on Raspberry Pi

Before you begin, you should follow our guide to set up your Raspberry Pi as a web server . While you won't need MariaDB or PHP for this project, you may find them useful for other awesome Raspberry Pi self-hosting projects. Make sure you also have the latest version of Docker Compose installed .

Once that's completed, connect to your Pi using Secure Shell (SSH):

Use Apt to update and upgrade all installed packages:

Now create new directories for Grocy and Grocy data, and use the cd command to move into the new Grocy directory:

Use the nano text editor to create a new file:

Add the following lines to it:

Save and exit nano with Ctrl + O then Ctrl + X , then bring up Docker Compose in detached mode with:

Visit http://your-pi-local-IP-address:9283 in a web browser, and enter admin as the username and admin as the password.

You'll land in the Grocy main screen, and should immediately click admin > Change password , to change your username and password, as well as set a suitable profile picture.

With the admin credentials secured, it's time to connect your Grocy instancy to the outside world. In a browser, visit your domain registrar and create a new A record. Set the host to @ , and the value to your domestic IP address. Set the Time To Lease (TTL) to the minimum value, then save.

Back on the command line, create a new config file for Apache:

In the new file, paste:

Save and exit nano with Ctrl + O then Ctrl + X .

Enable the site and restart Apache2:

You can use Certbot to fetch and deploy SSL certificates and keys :

If it's the first time you've run Certbot, you'll be asked to enter your email address, and to support the Electronic Frontier Foundation. Don't feel obliged to do either. Select your domain name from a list, and hit Enter .

You can access Grocy by entering your domain name in your browser, and your connection will be upgraded to HTTPS .

Connect Grocy to Your Phone

While you can enter information directly in your browser, it's much easier to start with Grocy if you use the mobile apps available for Android and iOS.

Download: Grocy for Android | iOS (Free)

Once you've installed the mobile app, click on Own Server in it —a QR scanner window will appear. From your computer web browser, click the spanner icon then Manage API Keys > Add . A QR code will appear on your screen; scan it with the Grocy app, to connect to your instance and log into your account.

Use Grocy to Manage Your Kitchen Stock!

With the server, the web interface, and the mobile app up and running, it's time to inventory your goods!

From the Stock Overview section of the app, click on the checkerboard icon to launch the barcode scanner. Use this to scan barcodes on your items, and enter the necessary details. You'll need to add a name for the item, the expiry date, and location.

Click Save when done, and the item will appear on your server. You can optionally add information such as price, which makes it easier to generated priced shopping lists for when you need to restock. This step is incredibly time-consuming, but worth it if you usually buy the same brands.

When you consume a product, you simply need to scan the barcode again to have it disappear from your inventory. And when you unload your shopping after a trip to the store, just scan the items as you store them and add the expiry date. Because Grocy already associates the barcode with a product, you won't need to re-enter the name, price, or location.

Grocy also features a basic recipe manager that helps you to create meals using the stock you have. It assists you in documenting the process, and you can even add the completed product as an item in your inventory.

To create a new recipe, click Recipes > Add , Give your recipe a name, then fill in the servings count, recipe steps and ingredients. Grocy will provide you with a barcode you can print out and slap on your jar of homebrewed chicken stock.

If you're especially organized, you can use Grocy's meal planner to plan your meals weeks in advance. Click Meal Planner , then for each day, click + (plus) and select your chosen recipe from a list. Grocy will check that you have the necessary ingredients in stock.

Grocy Manages More Than Just Food

Running a household is about more than the fresh ingredients in your fridge, and Grocy can help you with an unimaginable range of tasks.

Under Manage Master Data , you can define every chore that should take place in your home, along with a description. If you have other people living with you, you can add them as users on Grocy, and assign them to do chores from the app or from the web interface. This simplifies and tracks who's responsible for the dishes, vacuuming, or walking the dogs. Your family will appreciate the reduction in friction through misunderstanding.

You'll also find sections for batteries, levels of charge, purchase, and charge dates.

Get Organized With Grocy!

Grocy is squarely aimed at people who feel the need to be super-organized, and have control over every aspect of their lives, without having to consciously think about it.

Once you have Grocy set up, you can integrate it into your daily routine and know at a glance what options are available to you.

If planning ahead is important to you, why not try a day planner app to help you achieve consistent daily productivity?


  1. Setting Up a Static IP on the Raspberry Pi

    change ip raspberry pi


    change ip raspberry pi

  3. How to change the IP address of my Raspberry Pi without errors like an

    change ip raspberry pi

  4. How to Assign Static IP Address to Raspberry Pi!

    change ip raspberry pi

  5. Setting Static IP on RPi

    change ip raspberry pi

  6. networking

    change ip raspberry pi


  1. Setting Up Your Raspberry Pi Hardware

  2. How to Setup a Raspberry Pi and Access it Remotely! (Headless setup)

  3. EDITED Easily Image Raspberry Pi and Install Docker

  4. Easiest way to Find ip address of Raspberry Pi

  5. Java Swing Programming: Rasberry Pi 3 Modbus TCP Communication With S7-1200

  6. Unity Raspberry Pi C# TCP-IP [ Demo ]


  1. How to Set a Static IP Address on Raspberry Pi

    1. Determine your Raspberry PI's current IP v4 address if you don't already know it. The easiest way to do this is by using the hostname -I command at the command prompt. If you know its...

  2. How Do I Set a Static IP Address on Raspberry Pi?

    1. DHCP Configuration Raspberry Pi OS (formerly known as Raspbian) uses DHCP (Dynamic Host Configuration Protocol) to assign an IP address to the Raspberry Pi automatically whenever it is rebooted. You can find out more in our guide to DHCP.

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

    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.

  4. How to Configure a Static IP Address on the Raspberry Pi

    How to Configure a Static IP Address on the Raspberry Pi Making things a little less dynamic. Ash ( 362) Apr 5, 2021 5 minutes Discuss 1 You'll Need 1 The network capabilities on the Raspberry Pi make it possible to create some really fun projects. Once in a while, you'll come across a project that could benefit from a static IP address.

  5. Set up a static IP-address

    Simply right-click on the Wi-Fi icon in the menu bar (top-right on the left of the speaker icon) and select the Wireless & Wired Network Settings. Now click the empty dropdown menu and select the network interface you want to configure. Now for IPv4 Address enter your chosen ip address, for Router the IP address of the router.

  6. How to Setup a Raspberry Pi Static IP Address

    Guides In this Raspberry Pi static IP tutorial, we will show you how to configure your Raspberry Pi's network so that it utilizes a static IP address. We will force the Pi to use a static IP by making modifications to the Raspberry Pi's DHCP client daemon. This software controls the way the operating system handles IP addresses.

  7. Raspberry Pi Documentation

    Introduction Updating and Upgrading Raspberry Pi OS Using APT Using rpi-update Playing Audio and Video The OMXPlayer Application How to Play Audio How to Play Video Options During Playback Playing in the Background Using a USB webcam Basic Usage

  8. How to configure an IP address on Raspberry Pi

    If you want to set up an IP address for wired or wireless networks on a Raspbian system, there are several ways to do it, either in the text (manual) mode or via GUI tools. In this tutorial, I will explain several ways to configure an IP address on Raspbian-powered Raspberry Pi. IPv4 will be used in this tutorial.

  9. Setting a static eth0 ip

    That line means that every packet from the local network will go to outside through and eth0 interface. Without this line device can't know where to go. If there is no route line which has destination, you can test with adding by manually with "route command" ; route add default gw netmask 255.255.255. eth0.

  10. How to set a static IP address on a Raspberry Pi

    The final step is to set the static IP address for your Raspberry Pi. It involves appending some details to the end of a configuration file. You must make sure you either use the IP address ...

  11. How to Set a Static IP Address on Raspberry Pi

    4. Click on "Add" and enter the IP address of Raspberry Pi in the "Reserved IP Address" field. You can find the IP address of your RPi board by entering hostname -I in the Terminal. To find the MAC address of your RPi, scroll down and look for the client list mentioned on the same admin page.Next, give a name in the "Description" field and turn on the "Enable This Entry" checkbox.

  12. Provide Raspberry Pi with a static IP address

    11/29/2022 Configuration How to set a Raspberry Pi with a static ip address? A static IP address, as opposed to a dynamic IP address, doesn't change. The single-board computer Raspberry Pi always needs a static IP address if you want to access it with other devices over a long period of time.

  13. How To Configure Static IP Addresses on a Raspberry Pi

    You can change just one of these, or you ‎can change both. Either way, fill in the static IP address for the Pi, the router's IP address, and ‎the DNS server address. Make sure to check the option to fill in the missing values automatically: Using the GUI, enter the previously obtained values. Configure a Static IP on a Headless Raspberry Pi

  14. How to Set Up Static IP Address for Raspberry Pi

    You can also set the static private IP address for your system through the Raspberry Pi OS GUI. The steps below demonstrate the GUI procedure. 1. Right-click the network adapter icon on the right side of the top panel. 2. Select the Wireless & Wired Network Settings item to open Network Preferences. 3.

  15. Configure Network Settings of Raspberry Pi Hardware

    You can configure the network settings of your Raspberry Pi ® hardware by inspecting and editing the IP configuration of the Ethernet port. You may need to reconfigure the IP settings if your Raspberry Pi board: Has unknown IP settings Is unreachable using a network connection

  16. Changing the Raspberry Pi's IP address

    How do I change the Raspberry Pi's IP address? pidd Posts: 4766 Joined: Fri May 29, 2020 8:29 pm Location: Wirral, UK Re: Changing the Raspberry Pi's IP address Mon Jun 22, 2020 11:49 pm

  17. How to Set Up a Static IP on the Raspberry Pi

    By default the Pi is configured with a dynamic IP address. To assign it a static IP address, you need to add your static IP, default gateway IP, and domain name servers to the dhcpcd.conf file. At the command prompt, enter sudo nano /etc/dhcpcd.conf to edit the dhcpcd.conf file: Now, without changing anything else in the file, add this code at ...

  18. Raspberry Pi change IP without rebooting

    Raspberry Pi change IP without rebooting March 30, 2021 1 minute read . 💡 Even though the article below is targeted specifically at Raspberry Pi OS (formerly called Raspbian) the steps below should work perfectly fine for any Debian based O/S, as well as any other Linux distros which use dhcpcd.. Configuring a static IP address in Raspberry Pi OS is pretty straight forward.

  19. Raspberry Pi Documentation

    The Raspberry Pi also acts as the router on the wireless network, and as is customary, we will give it the first IP address in the network: To configure the static IP address, edit the configuration file for dhcpcd with: sudo nano /etc/dhcpcd.conf. Go to the end of the file and add the following:

  20. Raspberry Pi 3 can't update IP address

    1 I can't update an IP address from DHCP to static. I changed the /etc/network/interfaces file and I rebooted the system but IP still is the same as the one that DHCP gave me before. I changed /etc/network/interfaces to: # This file describes the network interfaces available on your system # and how to activate them.

  21. How to give your Raspberry Pi a Static IP Address

    CODE interface eth0 static ip_address=192.168..10/24 static routers=192.168..1 static domain_name_servers=192.168..1 interface wlan0 static ip_address=192.168..200/24 static routers=192.168..1 static domain_name_servers=192.168..1 interface = This defines which network interface you are setting the configuration for.

  22. How to Monitor Network Traffic on Raspberry Pi

    If you use a different network interface, replace the wlan0 with the interface name you want to monitor.. 5. Save and exit the file. Step 5: Edit Network Interface and IP Range. Specify the IP range and the network interface that the Ntopng service will monitor.

  23. How to check open ports on Raspberry Pi

    Raspberry Pi devices are commonly used to host a variety of lightweight services as they can do so very affordably. A simple example would be a web server, which handles user requests whenever someone navigates to a website. In order to make sure these services are accessible either on the local network or over the internet, we must make sure that the corresponding ports are open.

  24. Keep Your Cupboard Contents Fresh With Grocy on Raspberry Pi

    Once that's completed, connect to your Pi using Secure Shell (SSH): ssh pi @your-pi-local-ip-address. Use Apt to update and upgrade all installed packages:. sudo apt update && sudo apt upgrade-y. Now create new directories for Grocy and Grocy data, and use the cd command to move into the new Grocy directory:. mkdir grocy grocy/config && cd grocy Use the nano text editor to create a new file:

  25. ThousandEyes Pi4 Wireless Deployment at Black Hat USA

    ThousandEyes (TE) Black Hat 2023 Deployment Guide. This guide documents the setup and installation procedures used to deploy ThousandEyes at Black Hat 2023. This document covers configuration of the TE agent on Raspberry Pi 4, including both wired and wireless configurations. Needed hardware for the various setup functions are also listed.