If you’ve spent more than five minutes working on a Raspberry Pi project, you’ve probably been hit by this classic problem. One day you SSH in just fine, and the next day your Pi has completely ghosted you. You try ping raspberrypi.local and it’s like shouting into the void.
The culprit? Your router decided, “Eh, here’s a new IP address for you, buddy,” and now you’re hunting through your network like it’s a game of hide-and-seek you didn’t sign up for.
I’ve been there too many times. It’s especially annoying when you’re in the middle of an IoT build, running MQTT, or keeping some home automation script alive. The fix is simple: give your Pi a static IP so it stays put like a stubborn cat on a sunny windowsill.
This guide shows you how to do it two ways. First with NetworkManager’s nmcli (my favorite now), and then with the Raspberry Pi desktop GUI.
Like most people, I started with the old /etc/dhcpcd.conf trick. Every tutorial says to do that. I edited the file, double-checked the lines, rebooted… and nothing. The Pi still grabbed some random IP like a toddler grabbing candy.
Turns out, newer Raspberry Pi OS versions use NetworkManager by default, which completely ignores dhcpcd.conf. So if your settings aren’t sticking, this is probably why.
Why I’m Team nmcli Now
nmcli just feels cleaner. No silent overrides, no guesswork. It works for both Wi-Fi and Ethernet, and it’s great for headless setups. If you’re running Pi OS Bookworm or anything recent, just use this method and skip the old file edits.
Why Even Bother With a Static IP?
Here’s when you’ll thank yourself for setting one:
- Remote SSH or VNC access
- Hosting a web dashboard or local server
- Running Home Assistant or other smart home setups
- Port forwarding from outside your network
- MQTT broker, NAS, or file server duty
Basically, if your Pi needs to be at a known “address” all the time, this is the way.
Set a Static IP Using NetworkManager (nmcli)
This works for both Wi-Fi and Ethernet, and it’s great for headless setups.
- Let us find your Pi’s current IP
- Run hostname -I in the terminal. Note it down - you’ll need it to pick a fixed address that won’t clash with other devices.
- Now your router’s IP (gateway)
- Run ip r | grep default and note the address (usually something like 192.168.1.1).
- Check your connection name
- Run nmcli connection show and find your active profile. For Wi-Fi, it’s usually your SSID; for Ethernet, it might be “Wired connection 1”.
- Assign the static IP
- Replace "MyNetwork" with your connection name, and adjust the addresses for your network:
sudo nmcli connection modify "MyNetwork" ipv4.addresses 192.168.1.155/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1 ipv4.method manual
- Restart the connection
- sudo nmcli connection down "MyNetwork"
- sudo nmcli connection up "MyNetwork"
- Verify it worked
- Run hostname -I again. You should see your new static IP.
That’s it. Your Pi is now staying put on the network.
The GUI Route
If you’re using Raspberry Pi OS with the Desktop GUI, you can set a static IP address through the network settings without needing to use the terminal. I’ve covered that method here: Set Static IP on Raspberry Pi
Once you’ve got a static IP, you can do things like port forwarding, external access, and multi-device IoT setups.