Your Raspberry Pi Keeps Changing IP? Here’s How to Make It Stay Put
Technology

Your Raspberry Pi Keeps Changing IP? Here’s How to Make It Stay Put

Give Your Raspberry Pi a Static IP

Circuit Digest
Circuit Digest
5 min read

If you’ve been using a Raspberry Pi for more than five minutes, you’ve probably had this happen: you go to SSH in, check a dashboard, or hit a local web server… and poof, your Pi has vanished from the network. You type ping raspberrypi.local and get nothing. Turns out your router decided to hand out a different IP this time, so now you’re playing digital hide-and-seek.

Happened to me more times than I’d like to admit, especially during IoT builds, MQTT setups, or smart home scripts that need the Pi to always be reachable. The fix? Give your Pi a static IP. I’ll show you two ways: the nmcli (command-line) way, and the desktop GUI way.

Wait… isn’t it just /etc/dhcpcd.conf?

That’s what all the old tutorials say. I tried it. Added the right lines, rebooted, and… nothing. Still a random IP.

Turns out, newer Raspberry Pi OS versions use NetworkManager by default, which happily ignores your dhcpcd.conf edits. If your Pi’s running Bookworm or anything recent, you’ll need to speak NetworkManager’s language.

Why bother with a static IP?

If your Pi’s IP changes, anything that talks to it breaks until you find it again. Painful if you’re doing:

  • Remote SSH or VNC
  • Hosting a local web server or dashboard
  • Running Home Assistant or other smart device hubs
  • Port forwarding from your router
  • Using it as an MQTT broker, NAS, or file server

A static IP is like giving your Pi a permanent desk in the office; everyone knows where to find it.

Method 1: Using nmcli (NetworkManager CLI)

Honestly, I prefer this now. Works for both Wi-Fi and Ethernet, headless or not, and NetworkManager won’t silently override it.

  • Step 1 - Check your current IP
hostname -I

Mine was 192.168.29.71 - a temporary DHCP address.

  • Step 2 - Find your router’s IP (gateway)
ip r | grep default

I got 192.168.29.1.

  • Step 3 - Get your connection name
nmcli connection show

For me, Wi-Fi was "Circuit Digest". Ethernet might be "Wired connection 1".

  • Step 4 - (Optional) See current IPv4 settings
nmcli connection show "Circuit Digest" | grep ipv4
  • Step 5 - Set your static IP

Here’s what I ran:

sudo nmcli connection modify "Circuit Digest" \
ipv4.addresses 192.168.29.155/24 \
ipv4.gateway 192.168.29.1 \
ipv4.dns 192.168.29.1 \
ipv4.method manual
  • Step 6 - Restart the connection
sudo nmcli connection down "Circuit Digest"
sudo nmcli connection up "Circuit Digest"
  • Step 7 - Verify
hostname -I

Now it displayed 192.168.29.155. Done.

Method 2: Using the Raspberry Pi Desktop GUI

This only works if you’re running the full desktop version. If you’re headless, stick with nmcli.

  • Click the network icon (Wi-Fi or arrows) on the top-right.
  • Go to Advanced Options > Edit Connections.
  • Select your active network and hit Edit.
  • Change Method from Automatic (DHCP) to Manual.
  • Under IPv4 Settings, enter:
  • Address: 192.168.29.175
  • Netmask: 24
  • Gateway: 192.168.29.1
  • Add a DNS server (same as gateway or 8.8.8.8).
  • Click Apply, then reboot.

Wrap-up

If you’re on modern Raspberry Pi OS, forget about editing dhcpcd.conf. Use NetworkManager. Whether you go CLI or GUI, your Pi will finally stop playing hide-and-seek every reboot.

Once you’ve got a static IP, you can set up SSH, web servers, MQTT brokers, or port forwarding without worrying about sudden address changes. And trust me, your future self will thank you.

Here's a more elaborate step by step guide: How to Set Static IP on Raspberry Pi

Discussion (0 comments)

0 comments

No comments yet. Be the first!