Skip to content

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:

1
2
3
4
# Check your current IP, gateway, and DNS
ip addr show
ip route show default
cat /etc/resolv.conf

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.

Raspberry Pi OS Bookworm (and later) uses NetworkManager as the default network manager. This is the recommended method.

Configuring Ethernet (Wired)

# Step 1: Check your connection name
nmcli connection show

You'll see output like:

1
2
3
NAME                UUID                                  TYPE      DEVICE
Wired connection 1  a1b2c3d4-e5f6-7890-abcd-ef1234567890  ethernet  eth0
preconfigured       f1e2d3c4-b5a6-7890-abcd-ef1234567890  wifi      wlan0
1
2
3
4
5
6
7
8
9
# Step 2: Set static IP, gateway, and DNS
sudo nmcli connection modify "Wired connection 1" \
  ipv4.addresses 192.168.1.100/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns "8.8.8.8 1.1.1.1" \
  ipv4.method manual

# Step 3: Apply changes
sudo nmcli connection up "Wired connection 1"

Configuring Wi-Fi (Wireless)

# Step 1: Find your Wi-Fi connection name
nmcli connection show

# Step 2: Set static IP for Wi-Fi
sudo nmcli connection modify "preconfigured" \
  ipv4.addresses 192.168.1.101/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns "8.8.8.8 1.1.1.1" \
  ipv4.method manual

# Step 3: Apply changes
sudo nmcli connection up "preconfigured"

Reverting to DHCP

If you need to go back to automatic IP assignment:

1
2
3
4
5
6
7
sudo nmcli connection modify "Wired connection 1" \
  ipv4.addresses "" \
  ipv4.gateway "" \
  ipv4.dns "" \
  ipv4.method auto

sudo nmcli connection up "Wired connection 1"

Method 2: nmtui — Interactive Text UI

If you prefer a visual interface in the terminal:

sudo nmtui
  1. Select Edit a connection
  2. Choose your connection (e.g., "Wired connection 1")
  3. Change IPv4 CONFIGURATION from Automatic to Manual
  4. Click Add next to Addresses and enter your static IP (e.g., 192.168.1.100/24)
  5. Set the Gateway (e.g., 192.168.1.1)
  6. Add DNS servers (e.g., 8.8.8.8, 1.1.1.1)
  7. Click OKBackQuit
  8. Restart the connection:
sudo nmcli connection up "Wired connection 1"

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:

sudo nano /etc/dhcpcd.conf

Add at the end of the file:

# Static IP for Ethernet
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 1.1.1.1

# Static IP for Wi-Fi
interface wlan0
static ip_address=192.168.1.101/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 1.1.1.1

Apply changes:

sudo systemctl restart dhcpcd

Configuring IPv6 Static Address

To set a static IPv6 address alongside your IPv4 configuration:

1
2
3
4
5
6
7
8
# Set static IPv6 address
sudo nmcli connection modify "Wired connection 1" \
  ipv6.addresses "fd00::100/64" \
  ipv6.gateway "fd00::1" \
  ipv6.method manual

# Apply
sudo nmcli connection up "Wired connection 1"

To disable IPv6 entirely (useful for reducing attack surface on IoT devices):

1
2
3
4
sudo nmcli connection modify "Wired connection 1" \
  ipv6.method disabled

sudo nmcli connection up "Wired connection 1"

Verifying Your Configuration

After applying changes, verify everything works:

# Check IP address
ip addr show eth0

# Check gateway/routing
ip route show default

# Check DNS resolution
nslookup google.com

# Test internet connectivity
ping -c 4 8.8.8.8
ping -c 4 google.com

# Check NetworkManager connection details
nmcli connection show "Wired connection 1" | grep ipv4

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:

  1. Log into your router's admin page (usually 192.168.1.1)
  2. Find DHCP Reservation or Address Reservation (varies by router)
  3. Add your Pi's MAC address and desired IP
  4. Save and restart the Pi

Find your Pi's MAC address:

ip link show eth0 | grep ether
# Example output: link/ether dc:a6:32:xx:xx:xx

Troubleshooting

"No internet after setting static IP"

Cause: Incorrect gateway or DNS settings.

# Check if gateway is reachable
ping -c 2 192.168.1.1

# If gateway works but DNS doesn't:
ping -c 2 8.8.8.8        # Works → DNS problem
nslookup google.com       # Fails → Confirm DNS issue

# Fix DNS
sudo nmcli connection modify "Wired connection 1" \
  ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli connection up "Wired connection 1"

"IP address conflict detected"

Cause: Another device on your network already uses the same IP.

1
2
3
# Scan for IP conflicts
sudo apt install arp-scan
sudo arp-scan --localnet | grep 192.168.1.100

Choose a different IP that's not in use.

"Static IP works but reverts after reboot"

Cause: Multiple network managers are conflicting.

1
2
3
4
5
6
7
# Check which network manager is active
systemctl status NetworkManager
systemctl status dhcpcd

# On Bookworm, ensure dhcpcd is disabled
sudo systemctl disable dhcpcd
sudo systemctl stop dhcpcd

"Cannot SSH after changing IP"

Cause: You're trying to connect to the old IP.

1
2
3
4
5
6
# From another machine, find the Pi's new IP:
# Option 1: Check your router's connected devices list
# Option 2: Scan the network
nmap -sn 192.168.1.0/24 | grep -B 2 "Raspberry"
# Option 3: If you have mDNS working
ping raspberrypi.local

Best Practices

  1. Document your IP assignments — Keep a spreadsheet or document listing all static IPs on your network
  2. Use IPs outside the DHCP range — Prevents conflicts with automatically assigned addresses
  3. Always set a DNS server — Without DNS, you can reach IPs but not domain names
  4. Test connectivity after changes — Always verify with ping before closing your SSH session
  5. Have physical access as backup — If you lose network access, you'll need a keyboard and monitor
  6. Consider DHCP reservation — Often easier and more maintainable than static configuration