Assigning Raspberry Pi Static IP Guide
Assigning a Static IP Address to Raspberry Pi: A Technical Investigation
Step-by-step guide to configuring a persistent static IP on Raspberry Pi OS using NetworkManager, nmcli, and nmtui for reliable network access.
The Disappearing Act: Why Your Raspberry Pi Won't Stay Put
A Raspberry Pi that changes its network address without warning represents more than a minor inconvenience—it undermines the foundation of any headless deployment, IoT cluster, or home server configuration. When SSH connections fail and web dashboards vanish, the culprit is rarely hardware failure. More often, it is the dynamic address assignment protocol doing exactly what it was designed to do: recycle addresses. For users requiring predictable network behavior, assigning a static IP address remains essential. Yet the path to achieving this has shifted dramatically in recent Raspberry Pi OS releases, leaving many practitioners stranded with outdated instructions.
This investigation examines the current, reliable methods for assigning a persistent IP address to a Raspberry Pi, accounting for the transition from legacy configuration files to the NetworkManager framework introduced in Raspberry Pi OS 12 "Bookworm."
The Architectural Shift: From dhcpcd to NetworkManager
Why Legacy Tutorials Fail on Modern Systems
For years, the standard approach involved editing /etc/dhcpcd.conf, appending interface-specific directives to reserve an address. This method functioned reliably through Raspberry Pi OS 11 "Bullseye." However, beginning with version 12, the operating system deprecated dhcpcd as the primary network daemon in favor of NetworkManager—a more comprehensive network management stack adopted across many Linux distributions.
The consequence is straightforward: modifications to dhcpcd.conf on Bookworm or later are silently ignored. NetworkManager assumes exclusive control over interface configuration, rendering previous documentation obsolete for users running current software. Recognizing which network management system your installation employs is the critical first step before attempting any configuration changes.
Verifying Your Network Management Stack
Execute the following command to determine which service manages your network interfaces:
systemctl status NetworkManager
An active status confirms NetworkManager is operational. Alternatively, check for the presence of dhcpcd:
systemctl status dhcpcd
If NetworkManager is active, proceed with the methods outlined below. If dhcpcd remains in use (typical only on older installations or minimal custom builds), legacy configuration methods may still apply.
Method One: Command-Line Configuration via nmcli
Gathering Prerequisite Network Information
Before assigning a static address, collect three essential values from your current network environment:
- Current IP address:
hostname -I - Default gateway:
ip r | grep default - Active connection name:
nmcli connection show
Record these values. The static address you select must reside within your subnet's usable range and avoid conflicts with other devices or your router's DHCP pool.
Applying the Static Configuration
With connection details in hand, modify the active profile using nmcli. Replace placeholder values with your network-specific parameters:
sudo nmcli connection modify "Wired connection 1" \
ipv4.addresses 192.168.1.150/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "192.168.1.1 8.8.8.8" \
ipv4.method manual
Key parameters explained:
ipv4.addresses: The desired static IP with CIDR notation (e.g.,/24for a 255.255.255.0 subnet mask)ipv4.gateway: Your router's IP addressipv4.dns: One or more DNS server addresses, space-separatedipv4.method manual: Disables DHCP for this connection
Activating and Verifying Changes
Apply the new configuration by restarting the connection:
sudo nmcli connection down "Wired connection 1"
sudo nmcli connection up "Wired connection 1"
Confirm the assignment with:
nmcli device show eth0 | grep IP4.ADDRESS
The output should display your newly assigned static address. Note that residual DHCP-assigned addresses may persist temporarily until a full system reboot.
Method Two: Terminal UI Configuration via nmtui
Navigating the Text-Based Interface
For users preferring interactive menus over command syntax, NetworkManager provides nmtui, a curses-based terminal user interface. Launch the editor with elevated privileges:
sudo nmtui edit "Wired connection 1"
Configuring IPv4 Parameters
Within the interface:
- Navigate to IPv4 CONFIGURATION and change from
<Automatic>to<Manual> - Select
<Show>to expand advanced fields - Enter your static address, gateway, and DNS servers
- Ensure "Automatically connect" remains enabled
- Select
<OK>to save changes
Applying the Configuration
Unlike direct file edits, nmtui saves but does not immediately apply changes. Restart NetworkManager to activate the new settings:
sudo systemctl restart NetworkManager
Verify connectivity with ping or hostname -I. The static assignment should persist across reboots.
Desktop Environment Configuration (GUI Method)
Accessing Network Settings
On Raspberry Pi OS installations with the desktop environment, static IP configuration is accessible through the graphical interface:
- Click the network icon in the system tray
- Select Advanced Options → Edit Connections
- Choose your active connection and click Edit
- Navigate to the IPv4 Settings tab
- Change Method from "Automatic (DHCP)" to "Manual"
- Add your address, netmask, gateway, and DNS servers
- Save and reboot
This method provides visual confirmation of entered values and reduces syntax errors, though it requires physical or VNC access to the desktop environment.
Troubleshooting Persistent Assignment Issues
Address Conflicts and DHCP Overlap
Selecting a static address within your router's DHCP allocation range risks conflicts when other devices request addresses. Mitigate this by:
- Reserving addresses outside the DHCP pool (e.g., use
.200–.250if DHCP assigns.100–.199) - Configuring DHCP reservations on your router as a complementary strategy
- Using
arp-scanor router admin interfaces to identify occupied addresses before assignment
NetworkManager Service Timing
On headless systems, services like SSH may attempt to start before NetworkManager initializes network interfaces. If connection failures occur immediately post-reboot, consider:
- Adding a brief delay to service startup dependencies
- Using
nmcli connection up --waitin startup scripts - Verifying interface state with
nmcli device statusbefore initiating dependent services
Verifying Configuration Persistence
After rebooting, confirm the static assignment remains active:
ip addr show eth0
nmcli connection show "Wired connection 1" | grep ipv4.addresses
If the address reverts to DHCP-assigned, re-examine the connection profile name and ensure modifications targeted the correct interface.
Frequently Asked Questions
Q: Can I assign static IPs to both Ethernet and Wi-Fi interfaces simultaneously?
A: Yes. Each interface maintains an independent connection profile in NetworkManager. Apply the nmcli or nmtui configuration steps separately to eth0 and wlan0, using distinct static addresses within your subnet to avoid conflicts.
Q: What happens if my chosen static IP is already in use by another device?
A: NetworkManager will apply the configuration, but network communication may fail due to address collision. Use ping or arp-scan before assignment to verify address availability. If a conflict occurs, change the static address and reapply the configuration.
Q: Is it possible to use both a static IP and DHCP on the same interface?
A: NetworkManager does not support simultaneous static and dynamic addressing on a single interface. However, you can configure multiple connection profiles for the same physical interface and switch between them as needed using nmcli connection up [profile-name].
Q: How do I revert to DHCP after setting a static IP?
A: Modify the connection profile to restore automatic addressing:sudo nmcli connection modify "Wired connection 1" ipv4.method auto
Then restart the connection or NetworkManager service to apply the change.
Q: Will these static IP settings survive a Raspberry Pi OS upgrade?
A: NetworkManager connection profiles are stored in /etc/NetworkManager/system-connections/ and persist across OS updates. However, major version upgrades may reset network configuration defaults; verify settings post-upgrade and reapply if necessary.