Static IP Configuration on Raspberry Pi OS¶
Setting a static IP address ensures your Raspberry Pi always uses the same network address, which is essential for servers, remote access, and IoT deployments. This guide covers all methods for configuring static IPs on Raspberry Pi OS Bookworm and later.
Why Use a Static IP?¶
By default, your Raspberry Pi gets a dynamic IP via DHCP from your router. This IP can change after reboots or lease expirations, which causes problems when:
- SSH / VNC access — You need a consistent address to connect to
- Running servers — Web servers, Pi-hole, Home Assistant need a fixed address
- Port forwarding — Router rules point to a specific IP
- IoT devices — Other devices on your network need to find your Pi reliably
- DNS records — Internal DNS entries need a stable target
Prerequisites¶
Before configuring a static IP, gather your network information:
Note these values:
| Parameter | Example | How to Find |
|---|---|---|
| Current IP | 192.168.1.50 | ip addr show eth0 |
| Subnet Mask | /24 (255.255.255.0) | Same as above |
| Gateway | 192.168.1.1 | ip route show default |
| DNS Servers | 8.8.8.8, 1.1.1.1 | cat /etc/resolv.conf |
| Connection Name | "Wired connection 1" | nmcli connection show |
Avoid IP conflicts
Choose an IP address outside your router's DHCP range. Most routers use DHCP range 192.168.1.100–200, so picking an address like 192.168.1.10–50 is usually safe. Check your router's admin page to confirm.
Method 1: NetworkManager (nmcli) — Recommended¶
Raspberry Pi OS Bookworm (and later) uses NetworkManager as the default network manager. This is the recommended method.
Configuring Ethernet (Wired)¶
You'll see output like:
Configuring Wi-Fi (Wireless)¶
Reverting to DHCP¶
If you need to go back to automatic IP assignment:
Method 2: nmtui — Interactive Text UI¶
If you prefer a visual interface in the terminal:
- Select Edit a connection
- Choose your connection (e.g., "Wired connection 1")
- Change IPv4 CONFIGURATION from
AutomatictoManual - Click Add next to Addresses and enter your static IP (e.g.,
192.168.1.100/24) - Set the Gateway (e.g.,
192.168.1.1) - Add DNS servers (e.g.,
8.8.8.8, 1.1.1.1) - Click OK → Back → Quit
- Restart the connection:
Method 3: dhcpcd.conf — Legacy Method¶
For older Raspberry Pi OS versions only
This method works on Raspberry Pi OS Bullseye and earlier, which use dhcpcd instead of NetworkManager. If you're on Bookworm or later, use Method 1.
Edit /etc/dhcpcd.conf:
Add at the end of the file:
Apply changes:
Configuring IPv6 Static Address¶
To set a static IPv6 address alongside your IPv4 configuration:
To disable IPv6 entirely (useful for reducing attack surface on IoT devices):
Verifying Your Configuration¶
After applying changes, verify everything works:
Advanced: DHCP Reservation (Alternative Approach)¶
Instead of configuring a static IP on the Pi itself, you can reserve an IP in your router's DHCP settings. This way, the Pi still uses DHCP but always gets the same IP.
Advantages:
- No configuration changes on the Pi
- Centralized IP management on the router
- Works even after OS reinstall
How to set up:
- Log into your router's admin page (usually
192.168.1.1) - Find DHCP Reservation or Address Reservation (varies by router)
- Add your Pi's MAC address and desired IP
- Save and restart the Pi
Find your Pi's MAC address:
Troubleshooting¶
"No internet after setting static IP"¶
Cause: Incorrect gateway or DNS settings.
"IP address conflict detected"¶
Cause: Another device on your network already uses the same IP.
Choose a different IP that's not in use.
"Static IP works but reverts after reboot"¶
Cause: Multiple network managers are conflicting.
"Cannot SSH after changing IP"¶
Cause: You're trying to connect to the old IP.
Best Practices¶
- Document your IP assignments — Keep a spreadsheet or document listing all static IPs on your network
- Use IPs outside the DHCP range — Prevents conflicts with automatically assigned addresses
- Always set a DNS server — Without DNS, you can reach IPs but not domain names
- Test connectivity after changes — Always verify with
pingbefore closing your SSH session - Have physical access as backup — If you lose network access, you'll need a keyboard and monitor
- Consider DHCP reservation — Often easier and more maintainable than static configuration
Related Guides¶
- Networking Setup and Management — Complete networking guide
- Headless Setup Guide — Set up your Pi without a monitor
- Security Hardening Guide — Secure your network-connected Pi
- Tailscale Remote Access — Access your Pi from anywhere without port forwarding