How to Set a Static IP on Raspberry Pi (The Right Way With Nmcli)
by ElectroScope Archive in Circuits > Raspberry Pi
368 Views, 6 Favorites, 0 Comments
How to Set a Static IP on Raspberry Pi (The Right Way With Nmcli)

So here's the deal. If you're doing any kind of Raspberry Pi project where the Pi needs to stay connected (like, reliably connected), you’ve probably had that moment. You try to SSH into it or open your fancy web dashboard, and... poof. It’s gone. You ping raspberrypi.local, and the terminal just stares back at you.
Turns out your router gave it a new IP again, because DHCP felt like being spicy today. Awesome.
This happened to me more times than I care to admit. Especially during those IoT setups where the Pi needs to be up 24/7, like MQTT, Home Assistant, remote access, the usual suspects. Eventually, I snapped and said, “Alright, that’s it. We’re giving this thing a static IP.”
Spoiler: The Old Method Doesn’t Work Anymore (Thanks, NetworkManager)
Like any sane person, I started by editing /etc/dhcpcd.conf. Because every tutorial out there says that’s the way. I followed the instructions, rebooted… and nothing changed. The Pi still got a random IP. Classic.
After some head-scratching and a bit of Googling, I discovered that newer Raspberry Pi OS versions now use NetworkManager. Which means dhcpcd.conf is basically just decorative at this point. If you’re using Raspberry Pi OS Bookworm or anything new, that file is getting ignored.
Why I Switched to nmcli (and You Probably Should Too)
Once I accepted that dhcpcd.conf was useless, I dove into NetworkManager. Turns out it has this command-line tool called nmcli. Once you get used to it, it’s actually kind of great. It lets you set static IPs the right way, for both Wi-Fi and Ethernet. It’s super reliable even in headless mode.
Let’s walk through how I set it up.
Supplies
Raspberry Pi (any model with Wi-Fi or Ethernet would do)
microSD card with Raspberry Pi OS installed
Power supply for Raspberry Pi
Wi-Fi connection or Ethernet cable
Monitor, keyboard, and mouse or SSH access for a headless setup
Find Out What IP Your Pi Has Now

Open a terminal and type:
This gives you the current dynamic IP. Remember that, so you can avoid conflicts when you pick your static IP.
Get Your Router’s IP Address

Run this:
It should fetch something like 192.168.1.1 or 192.168.29.1. That’s your default gateway.
Check Your Network Connection Name

Every connection managed by NetworkManager has a name. To see yours:
Look for your active connection. Mine was "Circuit Digest" because that’s my Wi-Fi SSID. If you’re on Ethernet, it'll say something like “Wired connection 1”.
See Your Current IP Config

This one’s not necessary but useful:
This shows how IP addresses are being assigned (probably set to auto if DHCP is still in play).
Actually Set the Static IP

Now we get to the good part. Use the command below to assign a fixed IP. Swap in your own values if your network's different:
Breakdown:
- addresses - is the IP you want to set.
- gateway - is your router.
- dns - can usually be your gateway too.
- method manual - tells it to stop using DHCP.
Restart the Connection

Apply the changes by bouncing the connection:
That's it. Your Pi should now reconnect using the static IP you just set.
Confirm It Worked

One more hostname -I and it should now show your shiny new IP (like 192.168.29.155). You can now ping, SSH, VNC, or do whatever else without your Pi ghosting you.
Prefer the Desktop Way? There’s a GUI Option Too

If you're running the full Raspberry Pi OS with desktop, you can do all of this without touching the terminal:
- Click the network icon up top.
- Go to Advanced Options > Edit Connections.
- Pick your network, click Edit.
- Under IPv4, change Method to Manual.
- Enter your IP, netmask (usually 24), and gateway.
- Set DNS (same as gateway or use 8.8.8.8).
- Save and reboot.
That’s it. Your Pi should now have a permanent seat on your local network.
Wrap
Whether you’re working on IoT projects, hosting a web dashboard, or just want SSH to work without detective work, setting a static IP is a must. And with nmcli, it’s actually kind of painless.
The above is the simplified version of a comprehensive tutorial available here: How to Set a Static IP Address on Raspberry Pi