Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

Knowledge Base

Set a static IP Address on Raspberry Pi OS Bookworm

How to use a static network IP Address on the Raspberry Pi

This tutorial details how to set up a static network IP address on the Ethernet or WiFi connection on the Raspberry Pi OS Bookworm image, released October 2023, from https://www.raspberrypi.org/software/operating-systems/.

With the release of Raspberry Pi OS Bookworm, networking on the Raspberry Pi was changed to use NetworkManager as the standard controller for networking, replacing the previous dhcpcd system. NetworkManager includes a command line tool called "nmcli," which can control NetworkManager and report on the network status. 

This tutorial will use "nmcli" to configure the network to use a static IP address.  

We will give the Raspberry Pi a static IP address of 10.0.0.220. The gateway address will be set at 10.0.0.1, and the DNS server will also be set to 10.0.0.1

 

Step 1:

The first step is to find the name of the network interface you want to set as static. Run the following command in a terminal to display a list of available network interfaces.

sudo nmcli -p connection show

You should see a listing like the one below.

======================================
  NetworkManager connection profiles
======================================
NAME                UUID                                  TYPE      DEVICE
----------------------------------------------------------------------------
Wired connection 1  bd220d18-7d6a-36a5-9820-4f67de2c01fc  ethernet  eth0
mywifi              2359440b-8991-4c86-a905-b011dced4587  wifi      wlan0
lo                  c29ba7c5-98ff-4fa0-8d8e-06b30b8ec384  loopback  lo

The default name for the wired ethernet connection for English locales is "Wired connection 1". This name may be different if you use another language; for example, the German name will be "Kabelgebundene Verbindung 1". To find the correct connection name, look for the row with a Type of "ethernet".

The WiFi connection will typically have the name of your WiFis SSID. If your Raspberry Pi uses different names for the network connections or you would like to change your WiFi IP address, replace "Wired connection 1" with the correct name in the following commands. 

 

Step 2:

Now we know the name of the network connection we want to update, we can send three commands to set the new IP address, Gateway and DNS server.

sudo nmcli c mod "Wired connection 1" ipv4.addresses 10.0.0.220/24 ipv4.method manual

sudo nmcli con mod "Wired connection 1" ipv4.gateway 10.0.0.1

sudo nmcli con mod "Wired connection 1" ipv4.dns 10.0.0.1

 

If you want to use multiple DNS servers, you can add them separated by commas; for example, to use Google's DNS servers, use the following.

sudo nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8,8.8.4.4"

 

The same method can be used for adding multiple IP addresses to the same network connection; for example, the following command would assign IP addresses 10.0.0.220, 10.0.0.221 and 10.0.0.222.

sudo nmcli c mod "Wired connection 1" ipv4.addresses "10.0.0.220/24, 10.0.0.221/24, 10.0.0.222/24" ipv4.method manual

 

Step 3:

When you have finished updating the network settings on your Raspberry Pi, you can restart the network connection with the following command.

sudo nmcli c down "Wired connection 1" && sudo nmcli c up "Wired connection 1"

 

Note: If you are using SSH to connect to your Raspberry Pi, running the above command will cause the SSH session to end if the IP address changes.

You can find all of the configuration settings for a network connection with the following command:

nmcli -p connection show "Wired connection 1"

To change the network connection from static to automatic, run the following commands:

sudo nmcli con modify "Wired connection 1" ipv4.method auto
sudo nmcli c down "Wired connection 1" && sudo nmcli c up "Wired connection 1"

Was this article helpful? Yes No

Please tell us how we can improve this article:

Submit
Created 28/11/2015 | Last Updated: 28/02/2024

Related Expansion Boards

Order a ADC Pi Photo of ADC Pi
ADC Pi

8 Channel 17-bit Single-Ended Analogue to Digital converter for the Raspberry Pi

£19.19 Ex VAT: £15.99
Add to Cart
Order a Breakout Pi Plus Photo of Breakout Pi Plus
Breakout Pi Plus

Prototyping board for Raspberry Pi

£4.79 Ex VAT: £3.99
Add to Cart
Order a Expander Pi Photo of Expander Pi
Expander Pi

Analogue, Digital and RTC Expansion Interface for the Raspberry Pi

£27.59 Ex VAT: £22.99
Add to Cart
Order a IO Pi Plus Photo of IO Pi Plus
IO Pi Plus

32 channel MCP23017 digital I/O expander for the Raspberry Pi

£14.39 Ex VAT: £11.99
Add to Cart
Order a RTC Pi Photo of RTC Pi
RTC Pi

Real-time clock for the Raspberry Pi

£11.39 Ex VAT: £9.49
Add to Cart

Related Articles

Raspberry Pi GPIO Pin Usage
Raspberry Pi GPIO Pin mapping and connections
PCB Header Assembly Jig
Using the PCB Header Assembly Jig
Samba Setup on Raspberry Pi
How to install and setup Samba on the Raspberry Pi
Set a static IP Address on Raspberry Pi OS Bookworm
How to use a static network IP Address on the Raspberry Pi
Set a static IP Address on Raspberry Pi OS Buster
How to use a static network IP Address on the Raspberry Pi
Set a static IP Address on Raspberry Pi OS Wheezy
Static Network IP Address Setup on the Raspberry Pi
I2C Part 1 - Introducing I2C
An introduction to the I²C protocol
I2C Part 2 - Enabling I2C on the Raspberry Pi
How to enable I2C on the Raspberry Pi
I2C Part 3 - I2C tools in Linux
An introduction to I²C tools in Linux
I2C Part 4 - Programming I2C with Python
How to get started with Programming I²C with Python
SPI and Python on Raspberry Pi OS
Enabling SPI on the Raspberry Pi and installing python py-spidev
Using Pythonpath with the Python Libraries
Adding the library path to startup
Connecting Expansion Boards to the Raspberry Pi 400
Expanding the Potential of Your Raspberry Pi 400