In this tutorial, we’ll discuss how to set a Raspberry Pi static IP address on Raspberry Pi OS Trixie. You’ll learn how to give your Raspberry Pi a fixed address with a DHCP reservation on your router, with nmcli on the Wi-Fi and Ethernet connections, and with nmtui, and how to go back to DHCP when you no longer need it.
We’ll answer the question: how is a static IP on Raspberry Pi OS Trixie different from the older releases that used dhcpcd.conf, and where does NetworkManager save the setting so it survives a reboot? Every command in this guide ran on my Raspberry Pi 5, and you’ll see its real output, including how to apply the change over SSH without locking yourself out. Without further ado, let’s get right into it!
Note: All steps in this tutorial are tested with: Raspberry Pi 5 (8GB) with Raspberry Pi OS (64-bit) Trixie, over Wi-Fi and Ethernet.
This tutorial assumes your Raspberry Pi is set up with Raspberry Pi OS and reachable over SSH. If it isn’t, follow the Raspberry Pi Setup Guide first.
Raspberry Pi Static IP Command (nmcli)
On Raspberry Pi OS Trixie (and Bookworm), NetworkManager manages the network, so a static IP is set with nmcli. Find your connection name, set the address, gateway, and DNS on it, then apply it. On an image made with Raspberry Pi Imager, the Wi-Fi connection is named netplan-wlan0- followed by your Wi-Fi name, and the Ethernet one is netplan-eth0.
Wi-Fi static IP (Raspberry Pi OS Trixie)
|
1 2 3 |
nmcli connection show sudo nmcli connection modify netplan-wlan0-YourWiFiName ipv4.method manual ipv4.addresses 192.168.1.61/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" sudo nmcli device reapply wlan0 |
Ethernet static IP (Raspberry Pi OS Trixie)
|
1 2 |
sudo nmcli connection modify netplan-eth0 ipv4.method manual ipv4.addresses 192.168.1.60/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" sudo nmcli connection up netplan-eth0 |
Replace the address with a free one from outside your router’s DHCP pool, and the gateway with your router’s address. The change applies at once, with no reboot, and it is saved, so it survives a reboot. The rest of this tutorial explains how to pick the address, the router method, how to apply it safely over SSH, where the setting is stored, nmtui, and the errors you may meet.
Raspberry Pi Static IP vs DHCP Reservation Explained
A static IP is an address you set on the Raspberry Pi itself, so it stops asking the router for one. A DHCP reservation (also called a static lease) is set on the router: the Pi still uses DHCP, but the router always hands its MAC address the same IP. Both give you a fixed address for SSH, a web server, Home Assistant integrations, or port forwarding. The difference is where the address lives.

My router hands out 192.168.1.100 to 192.168.1.199 (its DHCP pool). A static address must sit outside that pool, like 192.168.1.60. If you pick one inside the pool, the router doesn’t know about it and can lease the same address to your phone or laptop later, and then both devices drop off the network at random. A reservation can be any address the router allows, because the router itself keeps it away from other devices.
| DHCP Reservation (Router) | Static IP (nmcli / nmtui) | |
|---|---|---|
| Set on | The router (MAC → IP) | The Raspberry Pi |
| Survives an SD card re-flash | Yes | No (set it again) |
| Works on any network | No, only on that router | Yes, but only if the subnet matches |
| Risk of an address conflict | None | Yes, if the address is inside the DHCP pool |
| Needs router access | Yes | No |
I recommend the DHCP reservation when you can log in to your router, which is also what the Raspberry Pi documentation recommends. Use a static IP on the Pi when you can’t change the router, or when the Pi sits on a network without DHCP (a direct cable to a PC, a lab switch). The ESP32 has the same choice, covered in my ESP32 static IP tutorial.
Find Your Raspberry Pi IP Address, Gateway, and DNS
Before setting anything, read four facts from the Pi: its current address and prefix, the gateway (your router), the DNS servers, and the exact NetworkManager connection name. None of these commands need sudo.
|
1 2 3 4 5 6 |
hostname -I ip -br addr ip route nmcli device status nmcli connection show nmcli -f IP4.DNS device show wlan0 |
- Address and prefix: 192.168.1.106/24 on wlan0. The /24 is the subnet mask 255.255.255.0 in short form.
- Gateway: the default via 192.168.1.1 line of ip route.
- DNS: 8.8.8.8 and 8.8.4.4, handed out by my router. Your router’s own address is a valid DNS server too.
- Connection name: netplan-wlan0-YourWiFiName for Wi-Fi and netplan-eth0 for Ethernet. Raspberry Pi Imager’s Wi-Fi settings are written through cloud-init and netplan, which is where the netplan- prefix comes from. Older guides use preconfigured or Wired connection 1; use the name your own Pi shows.
The fifth fact is on the router: the DHCP pool. Open the router’s admin page (usually 192.168.1.1) and find the DHCP server settings, often under LAN settings. On my TP-Link router it is under Advanced > Network > LAN Settings:

Then check that the address you picked is free. arping asks the network who owns an address. It needs sudo, and the -D (duplicate detection) mode exits with 0 when nobody answers:
|
1 |
sudo arping -D -c 3 -I eth0 192.168.1.60 |
192.168.1.60 gets 0 responses, so it’s free. The router’s 192.168.1.1 answers at once (exit code 1), which is what an address already in use looks like. A plain ping works as a quick check too, but some devices don’t answer pings, so arping is the safer test.
Method 1: Raspberry Pi DHCP Reservation on the Router
A DHCP reservation changes nothing on the Raspberry Pi. You tell the router to always give the Pi’s MAC address the same IP. The menu names differ between routers (Address Reservation, DHCP Reservation, Static Lease, Fixed IP), but the steps are the same.
#1
Log in to your router’s admin page and open the DHCP server or LAN settings page.
#2
Find the Raspberry Pi in the client list (hostname pi5 on my network) and note its MAC address. On the Pi, nmcli -f GENERAL.HWADDR device show wlan0 prints the same MAC.

Note: Wi-Fi and Ethernet have different MAC addresses. Reserve the MAC of the interface the Pi really uses. If you use both, add a reservation for each.
#3
Add a reservation: the Pi’s MAC address and the IP you want (here its current address, 192.168.1.106). Most routers have a Scan or pick-from-list button that fills in the MAC.

#4
Save. The Pi gets the reserved address the next time it renews its lease or reconnects ( sudo nmcli device reapply wlan0, a reboot, or a Wi-Fi reconnect).
To undo it, delete the entry from the router’s reservation list. The Pi keeps DHCP and gets a normal pool address at its next renewal.
Method 2: Set a Raspberry Pi Static IP With nmcli
nmcli is NetworkManager’s command-line tool, and it is installed on every Raspberry Pi OS image, Lite included. One connection modify line sets the method, address, gateway, and DNS together. Keep ipv4.method manual and ipv4.addresses in the same command, as below.
Raspberry Pi Static IP on Ethernet (eth0)
Ethernet is the easiest place to start over SSH, because your session can stay on Wi-Fi while the cable connection changes. I plugged my Pi into the switch; eth0 got 192.168.1.107 by DHCP on the netplan-eth0 connection. Then:
|
1 2 3 4 |
sudo nmcli connection modify netplan-eth0 ipv4.method manual ipv4.addresses 192.168.1.60/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" sudo nmcli connection up netplan-eth0 ip -br addr; ip route ping -c 2 -I eth0 8.8.8.8 |
eth0 now has 192.168.1.60/24, its default route reads proto static instead of proto dhcp, and the ping through eth0 reaches the internet. I then connected from my PC to pi@192.168.1.60 to confirm SSH works on the new address.
Raspberry Pi Static IP on Wi-Fi (wlan0)
On Wi-Fi the connection name carries your network name. The command is the same; only the name and the interface change:
|
1 2 |
sudo nmcli connection modify netplan-wlan0-YourWiFiName ipv4.method manual ipv4.addresses 192.168.1.61/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" sudo nmcli device reapply wlan0 |
If your network name has spaces, put the whole connection name in quotes. When you’re logged in over that same Wi-Fi, the next section shows how to apply this without getting stuck if something is wrong.
Apply a Raspberry Pi Static IP Over SSH Without Losing Access
Changing the address of the connection you are logged in on ends your SSH session: the old address disappears. Many guides tell you to run nmcli connection down and then up. Over SSH that is a trap, because the session dies after down and up never runs. Two things make it safe:
- nmcli device reapply applies the changed settings to the running interface without taking it down first (nmcli manual). Your session drops only because the old address is gone, and the Pi is already on the new one.
- A NetworkManager checkpoint with a rollback timer. NetworkManager saves the current state and restores it automatically when the timer runs out, unless you confirm the change first (CheckpointCreate). If the new address doesn’t work, you wait two minutes and the Pi comes back on the old one.
nmcli has no checkpoint command, but busctl, which comes with systemd, calls NetworkManager’s D-Bus method directly. Before trusting it on Wi-Fi, I tested the rollback on Ethernet: a 40-second checkpoint, a deliberately different address (192.168.1.63), and no confirmation:
After 40 seconds NetworkManager put 192.168.1.60 back on eth0, and the saved connection went back too: the netplan file shown in the next section held .60 again. Here is the full safe sequence I used for the Wi-Fi change, with a 120-second timer:
Step 1: create the checkpoint (all devices, 120 s), then change and reapply
|
1 2 3 |
sudo busctl call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager CheckpointCreate aouu 0 120 0 sudo nmcli connection modify netplan-wlan0-YourWiFiName ipv4.method manual ipv4.addresses 192.168.1.61/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 8.8.4.4" sudo nmcli device reapply wlan0 |
Step 2: from your PC, log in at the new address and confirm (destroy the checkpoint) within the 120 seconds
|
1 2 |
ssh pi@192.168.1.61 sudo busctl call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager CheckpointDestroy o /org/freedesktop/NetworkManager/Checkpoint/1 |
Use the checkpoint path that CheckpointCreate printed ( Checkpoint/1, /2, and so on). My Wi-Fi change went through with no reconnect: wlan0 moved from .106 to .61 within seconds, and the old address stopped answering pings. If you can’t log in at the new address, do nothing: after 120 seconds the Pi is back on its old address and its old settings.
Note: Run the checkpoint and the change from one SSH session, and the confirmation from a new one. If you confirm by mistake before you’ve tested the new address, the rollback is gone.
Does a Raspberry Pi Static IP Survive a Reboot?
Yes. On Raspberry Pi OS Trixie, an nmcli or nmtui change to a netplan- connection is written to /etc/netplan/, and that file is read again at every boot. I checked the files before the change, after it, and after a reboot.
Raspberry Pi Imager puts your network settings in a network-config file on the boot partition. On the first boot, cloud-init turns it into a netplan file, and netplan generates the NetworkManager connections at every boot (Raspberry Pi: cloud-init on Raspberry Pi OS). On my Pi the netplan files are named 90-NM-<connection UUID>.yaml, and /etc/NetworkManager/system-connections/ is empty. The connections NetworkManager uses live in /run/NetworkManager/system-connections/, which is rebuilt at every boot. Before the change, the Ethernet file says DHCP:
After nmcli connection modify, the same file has the static address, the DNS servers, and the gateway. NetworkManager wrote them back into netplan itself, which the netplan documentation describes for desktop systems:
Then I rebooted. After the reboot, both static addresses were still there, the routes read proto static, and the Pi reached the internet:
The Wi-Fi file holds the static address next to the network name and password. Keep that in mind before you copy a netplan file anywhere: it’s readable by root only, and it contains your Wi-Fi password in plain text.
cloud-init doesn’t overwrite these files on later boots: its log on my Pi shows the network stage skipped (“No network config applied”) on every boot after the first one. Editing the network-config file on the boot partition after the first boot has no effect either, for the same reason.
Note: If your Pi shows a connection named Wired connection 1, that is a profile NetworkManager creates in memory when no saved connection matches the cable. Users on the Raspberry Pi forums report that edits to it don’t survive a reboot. Create your own connection instead: sudo nmcli connection add type ethernet ifname eth0 con-name eth0-static, set the static values on it, and bring it up.
Method 3: Raspberry Pi Static IP With nmtui
nmtui is a text menu for the same NetworkManager settings, handy when you don’t want to type the whole nmcli line. Run it with sudo over SSH, or it can’t save (shown in the troubleshooting section). I set the Ethernet connection back to the same 192.168.1.60 with it.
|
1 |
sudo nmtui |
#1
Select Edit a connection and press Enter.
#2
Select the connection ( netplan-eth0 or your netplan-wlan0-...) and press Enter.
#3
Move to IPv4 CONFIGURATION <Automatic> with Tab, press Enter, and choose Manual. Then select <Show>.
#4
Under Addresses select <Add…> and type the address with its prefix (192.168.1.60/24). Fill in the Gateway, and add each DNS server with its own <Add…>.
#5
Tab down to <OK> and press Enter, then <Back> and Quit. Apply it with sudo nmcli connection up netplan-eth0 (or nmtui’s Activate a connection), or with sudo nmcli device reapply for Wi-Fi.
nmtui saved exactly what nmcli would have: nmcli -g ipv4.method,ipv4.addresses,ipv4.gateway,ipv4.dns connection show netplan-eth0 returned manual, 192.168.1.60/24, 192.168.1.1, 8.8.8.8,8.8.4.4, and the netplan file was updated the same way.
On the Raspberry Pi desktop, the same settings are in the network icon’s menu under Advanced Options > Edit Connections, the window the Raspberry Pi documentation uses for network settings.
Do You Need sudo for nmcli on Raspberry Pi?
Over SSH, yes. Reading settings works for any user, but changing a connection needs sudo. Without it, nmcli and nmtui fail with “Insufficient privileges”:
The reason is NetworkManager’s polkit rule on Raspberry Pi OS ( /usr/share/polkit-1/rules.d/org.freedesktop.NetworkManager.rules). It lets members of the sudo and netdev groups change system connections without a password, but only from a local, active session, which means the desktop in front of the Pi. An SSH login isn’t one, so nmcli general permissions over SSH lists settings.modify.system as auth, and the change needs sudo.
Why dhcpcd.conf Doesn’t Work on Raspberry Pi OS Trixie
Most static IP guides still say to add static ip_address= lines to /etc/dhcpcd.conf. That was right up to Raspberry Pi OS Bullseye. Since Bookworm, NetworkManager handles the network and the dhcpcd service isn’t installed. The file is still there, and that’s what confuses people: it comes with the dhcpcd-base package, but nothing reads it.
I added a static block for wlan0 (192.168.1.62) to /etc/dhcpcd.conf. Restarting dhcpcd fails with “Unit dhcpcd.service not found”, wlan0 kept its address, and after a reboot it still wasn’t .62. The same goes for /etc/network/interfaces (the file doesn’t exist, and ifupdown isn’t installed) and for static IP lines in wpa_supplicant.conf: use nmcli, nmtui, or the router.
Raspberry Pi Static IP and IPv6
Setting a static IPv4 address leaves IPv6 alone: ipv6.method stays as it was. On my Pi the Ethernet connection keeps auto (its fe80:: link-local address and any address from the router), while Imager’s Wi-Fi connection is set to ignore, so Wi-Fi only gets the kernel’s own link-local address. One side effect I saw: after nmcli device reapply wlan0, wlan0 had no fe80:: address until the next reboot. That matters if your PC reaches pi5.local over IPv6 link-local, as Windows often does. The IPv4 address answered normally, and a reboot brought the link-local address back.
Change a Raspberry Pi Static IP Back to DHCP
Set the method back to auto and clear the static fields in the same command, then apply it, so no old static values stay stored in the connection.
|
1 2 |
sudo nmcli connection modify netplan-wlan0-YourWiFiName ipv4.method auto ipv4.addresses "" ipv4.gateway "" ipv4.dns "" sudo nmcli device reapply wlan0 |
My Wi-Fi got 192.168.1.106 back from the router within a few seconds, and the routes read proto dhcp again. The netplan file returned to dhcp4: true. For Ethernet, use netplan-eth0 and sudo nmcli connection up netplan-eth0. To undo a router reservation, delete it from the router’s list.
Raspberry Pi Hostname and pi5.local
A hostname is often a simpler answer than a fixed address: ssh pi@pi5.local works whatever IP the Pi has, because the avahi-daemon service announces the name on the local network (mDNS). Read it with:
|
1 2 3 |
hostnamectl hostname cat /etc/hostname grep -v "^#" /etc/hosts |
The Raspberry Pi documentation changes the hostname in Control Centre > System > Change Hostname on the desktop, or with sudo raspi-config under 1 System Options > S4 Hostname. On a Trixie image customised in Imager there’s a catch: the hostname comes from /boot/firmware/user-data ( hostname: "pi5" and manage_etc_hosts: true on my Pi), and cloud-init’s Update Hostname and Update Etc Hosts modules run at every boot (cloud-init modules). To keep a new name, also change the hostname: line in user-data (or set preserve_hostname: true). The .local name follows the hostname after avahi restarts or the Pi reboots. I didn’t rename my bench Pi, because other tutorials in this series reach it as pi5.local.
Raspberry Pi Static IP Troubleshooting
Error: Failed to modify connection: Insufficient privileges
Run the command with sudo. Over SSH, NetworkManager’s polkit rule only allows changes from the local desktop session. nmtui shows the same problem as “Unable to save connection: Insufficient privileges” when you press OK:
Error: unknown connection
The connection name is wrong. Copy it exactly from nmcli connection show: Imager names it netplan-wlan0- plus your full network name, upper and lower case included. Quote it if it has spaces, or press Tab to let bash complete it.
arping: socket: Operation not permitted
arping needs raw network access: run it with sudo.
LAN works but no internet (Destination Host Unreachable)
The gateway is wrong. I set eth0’s gateway to 192.168.1.254, an address no device uses on my network, inside a 30-second checkpoint. The Pi still reached the router on the LAN, but every packet to the internet failed:
Set ipv4.gateway to the default via address that ip route showed before the change (your router).
Names don’t resolve, but ping 8.8.8.8 works
DNS is missing or wrong. Check nmcli -g ipv4.dns connection show <name> and cat /etc/resolv.conf, then set ipv4.dns "8.8.8.8 8.8.4.4" or your router’s address and reapply.
The Pi drops off the network at random after a static IP
The address is probably inside the router’s DHCP pool, and the router leased it to another device. Pick an address outside the pool, or use a DHCP reservation. Check with sudo arping -D before you assign it.
Failed to restart dhcpcd.service: Unit dhcpcd.service not found
You’re following a pre-Bookworm guide. dhcpcd doesn’t run on Raspberry Pi OS Trixie or Bookworm; use nmcli, nmtui, or the router.
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Your PC remembers a different device’s SSH key for that address, typically because another device used the IP before the Pi. If you’re sure the Pi is the device at that address, remove the old entry on your PC and connect again:
|
1 |
ssh-keygen -R 192.168.1.61 |
Raspberry Pi Static IP FAQ
How do I set a static IP on Raspberry Pi OS Bookworm?
The same way as on Trixie. Bookworm also uses NetworkManager, so the nmcli and nmtui steps above apply; only the connection names may differ. Run nmcli connection show to see yours.
Do I need to reboot after setting a static IP?
No. sudo nmcli device reapply or sudo nmcli connection up applies it at once. A reboot is only a test that the setting is saved.
Can the Raspberry Pi have a static IP on Wi-Fi and Ethernet at the same time?
Yes. Each connection has its own settings. I ran 192.168.1.60 on Ethernet and 192.168.1.61 on Wi-Fi together, and both survived a reboot. Use different addresses, and expect Ethernet to carry the internet traffic, because its default route has the lower metric (100 vs 600).
Should I use 255.255.255.0 or /24?
They’re the same subnet. nmcli and nmtui take the prefix form, so 192.168.1.60 with mask 255.255.255.0 is written 192.168.1.60/24.
Wrap Up
To conclude this tutorial, we’ve set a Raspberry Pi static IP address on Raspberry Pi OS Trixie in three ways: a DHCP reservation on the router, nmcli on the Wi-Fi and Ethernet connections, and nmtui. We picked the address outside the router’s DHCP pool, applied it over SSH with a rollback timer, and proved that NetworkManager saves it in /etc/netplan/ so it survives a reboot, while dhcpcd.conf no longer does anything.
If you’re starting with a fresh card, the Raspberry Pi Setup Guide covers flashing, Wi-Fi, and SSH. The next tutorials in this Raspberry Pi series build on a Pi you can always reach at the same address.
Home Assistant OS is different: it has no Raspberry Pi OS shell, so you set its fixed address in Settings > System > Network instead. The Home Assistant Raspberry Pi 5 Setup guide shows that screen.
