How to Set a Static IP Address on Raspberry Pi

Assigning a static IP address to a Raspberry Pi ensures it maintains the same network location every time it boots, which is essential for hosting servers, SSH access, or running home automation. This guide covers the two most reliable methods for locking in your Pi’s IP address: configuring your local router’s DHCP reservation settings or directly editing the configuration files within the Raspberry Pi OS.

Why You Need a Static IP

By default, routers assign dynamic IP addresses to devices using DHCP (Dynamic Host Configuration Protocol). This means your Raspberry Pi’s IP address can change whenever the router reboots or the lease expires. If you are running a headless setup, a media server like Plex, or a Pi-hole, a shifting IP address will break your connections and require you to hunt for the new address every time.

The cleanest way to assign a static IP is through your router. This prevents IP conflicts by telling the router to always reserve a specific IP address for your Raspberry Pi’s unique MAC address.

  1. Log into your router’s web admin portal by typing its IP address (usually 192.168.1.1 or 192.168.0.1) into a web browser.
  2. Locate the DHCP Server, Static Lease, or IP Reservation settings page.
  3. Find your Raspberry Pi in the list of connected devices.
  4. Note its MAC address (a 12-character alphanumeric code like aa:bb:cc:dd:ee:ff).
  5. Add a new reservation rule linking that MAC address to your desired static IP address. Ensure the chosen IP is outside the main pool of dynamically assigned addresses to avoid future overlaps.

Method 2: Configuring Raspberry Pi OS (Bookworm and Newer)

If you are using the latest Raspberry Pi OS (Bookworm), the operating system handles networking via NetworkManager. You can easily set a static IP using the built-in terminal tool.

  1. Open a terminal window on your Raspberry Pi or connect via SSH.
  2. Run the NetworkManager text user interface tool: sudo nmtui
  3. Use the arrow keys to select Edit a connection and press Enter.
  4. Select your active connection (usually Wired connection 1 for Ethernet or your Wi-Fi network name) and choose Edit.
  5. Scroll down to IPv4 CONFIGURATION, change it from <Automatic> to <Manual>, and select <Show>.
  6. Next to Addresses, select <Add> and type your desired static IP followed by the network prefix (for example, 192.168.1.100/24).
  7. Enter your router’s IP address in the Gateway field and your preferred DNS servers (such as 8.8.8.8 for Google DNS).
  8. Scroll down, select <OK>, and exit the utility.
  9. Restart the network connection to apply changes: sudo nmcli connection up [Connection Name]

Method 3: Configuring Older Raspberry Pi OS (Bullseye and Earlier)

Legacy versions of Raspberry Pi OS rely on dhcpcd to manage network interfaces. If you are running an older operating system version, you must modify the configuration file manually.

  1. Open the configuration file in the nano text editor: sudo nano /etc/dhcpcd.conf
  2. Scroll to the bottom of the file and append the following lines, substituting eth0 for Ethernet or wlan0 for Wi-Fi depending on your connection type:
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
  1. Save and close the file by pressing Ctrl+O, Enter, and then Ctrl+X.
  2. Reboot your Raspberry Pi to finalize the network adjustment: sudo reboot

Verifying the Setup

Once your Raspberry Pi reboots, you can confirm that the network settings applied successfully. Open the terminal and type hostname -I. The output should display the exact static IP address you configured, confirming your Raspberry Pi is now permanently reachable at that destination.