Your Raspberry Pi Keeps Changing IP? Here’s How to Lock It Down for Good

Table of contents

If you’ve been playing with a Raspberry Pi for more than five minutes, you’ve probably had this happen. You go to SSH in, or pull up a dashboard, and… poof. The Pi’s gone. You ping raspberrypi.local
and get nothing. Turns out your router handed it a shiny new IP, and now you’re hunting it down like it owes you money.
This used to drive me nuts, especially when running IoT projects, MQTT brokers, or home automation scripts that need the Pi to always be there. The fix is simple: give it a static IP.
The “Oh, That Doesn’t Work Anymore” Moment
Like many folks, I started with the classic /etc/dhcpcd.conf
edit. Added the lines, rebooted, nothing changed. Then I learned newer Raspberry Pi OS versions use NetworkManager by default, which ignores dhcpcd.conf
.
Why I’m Team nmcli Now
NetworkManager’s CLI works for both Wi-Fi and Ethernet, doesn’t get ignored, and feels more future-proof. If you’re on Raspberry Pi OS Bookworm or newer, this is the way to go.
Method 1: Using nmcli
Check your current IP:
hostname -I
Find your router’s IP:
ip r | grep default
See your connection name:
nmcli connection show
(Optional) Check IPv4 settings:
nmcli connection show "YourConnection" | grep ipv4
Set the static IP:
sudo nmcli connection modify "YourConnection" ipv4.addresses 192.168.29.155/24 pv4.gateway 192.168.29.1 ipv4.dns 192.168.29.1 ipv4.method manual
Restart connection:
sudo nmcli connection down "YourConnection"
sudo nmcli connection up "YourConnection"
Verify new IP:
hostname -I
Method 2: Desktop GUI
Click the network icon (top-right).
Go to Advanced Options → Edit Connections.
Pick your network from the list.
Change IPv4 method to “Manual.”
Enter your desired IP, netmask, gateway, and DNS.
Click Apply, then reboot.
Now your Pi has a permanent desk in your network’s office. No more IP hide-and-seek. Perfect for SSH, web servers, port forwarding, and all the nerdy stuff we love.
There’s a highly detailed version of this tutorial available here: How to Set Static IP on Raspberry Pi
Subscribe to my newsletter
Read articles from Electroscope Archive directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
