AI & Agents

How to Set a Static IP on Raspberry Pi for Always-On OpenClaw Agents

Raspberry Pi OS Bookworm replaced dhcpcd with NetworkManager in late 2023, but most static IP tutorials still reference the old configuration file. This guide covers the correct nmcli commands for assigning a fixed address on current Raspberry Pi hardware, then walks through the systemd and networking setup that keeps an OpenClaw agent reachable around the clock.

Fast.io Editorial Team 9 min read
A static IP gives your headless Pi agent a permanent address on the network.

Why DHCP Fails Headless Agents

Raspberry Pi OS Bookworm, released in October 2023, switched the default network stack from dhcpcd to NetworkManager. The Raspberry Pi Foundation described NetworkManager as a strict upgrade that "does everything dhcpcd did, but adds a bunch of extra functionality." But the change also broke every static IP tutorial that tells you to edit /etc/dhcpcd.conf. That file does not exist on a fresh Bookworm install.

For a desktop Pi, DHCP works fine. The router hands out an address, renews it on a standard 24-hour lease cycle, and the Pi stays connected. The problem shows up when you run a headless service like an OpenClaw agent gateway that other machines need to reach at a predictable address.

Three scenarios where a shifting IP breaks your setup:

  • SSH access. You configure your laptop to connect to 192.168.1.50, but after a router restart the Pi picks up 192.168.1.73. Your connection fails silently.
  • Webhook delivery. If an external service POSTs events to your Pi's IP, a lease change means missed callbacks until you update the endpoint.
  • Port forwarding. Router port-forwarding rules target a specific LAN IP. When DHCP reassigns it, the forwarding rule points at nothing.

A static IP address assigns a fixed network address to your Raspberry Pi so it always appears at the same location on your local network. That is essential for reliable SSH access and webhook delivery to headless agents.

How to Find Your Connection Name and Current Settings

Before changing anything, you need the exact name NetworkManager uses for your active connection. Open an SSH session or terminal and run:

nmcli connection show

This prints a table of connections. On a typical Pi connected via Ethernet, the name is "Wired connection 1". If you configured WiFi during the Raspberry Pi Imager setup, the WiFi connection is often named "preconfigured".

Note the NAME column for the connection you want to make static. You will use this exact string, including spaces and capitalization, in every nmcli command that follows. The name is case-sensitive.

To inspect your current IP address, gateway, and DNS:

nmcli device show eth0

Replace eth0 with wlan0 if you are on WiFi. Write down the current gateway address. It is usually something like 192.168.1.1 or 192.168.0.1, and you will need it when setting the static configuration.

Check which IP addresses are already taken on your network before picking a static one. If your router's admin interface has a DHCP client list, review it. Most consumer routers assign addresses in the .100 to .200 range by default. Choosing something in the .10 to .50 range reduces the chance of a conflict with dynamically assigned devices.

Network configuration overview showing connected devices

Assign a Static IP with nmcli

The full configuration takes three commands. Replace the example values with your own network details.

Set the IP address and switch to manual mode:

sudo nmcli connection modify "Wired connection 1" \
  ipv4.addresses 192.168.1.50/24 \
  ipv4.method manual

The /24 suffix is CIDR notation for a 255.255.255.0 subnet mask, which is standard for home and small office networks.

Set the default gateway:

sudo nmcli connection modify "Wired connection 1" \
  ipv4.gateway 192.168.1.1

Set DNS servers:

sudo nmcli connection modify "Wired connection 1" \
  ipv4.dns "8.8.8.8,1.1.1.1"

You can use your router's IP as the DNS server instead, or any public DNS provider. Google (8.8.8.8) and Cloudflare (1.1.1.1) are reliable defaults.

Apply the changes by cycling the connection:

sudo nmcli connection down "Wired connection 1" && \
  sudo nmcli connection up "Wired connection 1"

If you are connected via SSH, this command will drop your session. Reconnect using the new static IP.

WiFi Configuration

For a WiFi connection, swap the connection name. If the Raspberry Pi Imager created your WiFi profile, it is typically called "preconfigured":

sudo nmcli connection modify "preconfigured" \
  ipv4.addresses 192.168.1.50/24 \
  ipv4.method manual
sudo nmcli connection modify "preconfigured" \
  ipv4.gateway 192.168.1.1
sudo nmcli connection modify "preconfigured" \
  ipv4.dns "8.8.8.8,1.1.1.1"
sudo nmcli connection down "preconfigured" && \
  sudo nmcli connection up "preconfigured"

Everything else works identically. NetworkManager stores the configuration in /etc/NetworkManager/system-connections/, and the settings persist across reboots automatically.

Reverting to DHCP

If something goes wrong and you need to undo the change:

sudo nmcli connection modify "Wired connection 1" \
  ipv4.method auto
sudo nmcli connection down "Wired connection 1" && \
  sudo nmcli connection up "Wired connection 1"

This switches back to automatic DHCP assignment immediately.

Fastio features

Give your OpenClaw agent persistent cloud storage

Free 50 GB workspace with MCP access for your Pi-based agents. Store output, share with clients, transfer ownership when the job is done. No credit card, no expiration.

How to Verify the Static IP Survives a Reboot

Reboot the Pi to confirm the static IP persists:

sudo reboot

Wait about 30 seconds, then connect from another machine:

ssh pi@192.168.1.50

Once connected, verify the address:

ip addr show eth0

You should see your chosen IP in the inet line. Confirm the gateway and DNS are correct:

nmcli device show eth0 | grep -E "IP4\.(ADDRESS|GATEWAY|DNS)"

If the address did not stick, the most common cause is a typo in the connection name. "Wired Connection 1" (capital C) is different from "Wired connection 1" (lowercase c). Run nmcli connection show again to verify.

Test outbound connectivity and DNS resolution:

ping -c 3 google.com

If ping resolves the hostname and returns replies, your static IP, gateway, and DNS are all working. If ping resolves but SSH fails from your laptop, make sure both machines are on the same subnet. A /24 mask means the first three octets of the Pi's IP and your laptop's IP must match.

Keep OpenClaw Running on the Fixed Address

With a static IP in place, external services can reach your Pi at a predictable address. The next step is making the OpenClaw gateway survive reboots, crashes, and SSH disconnections.

Install OpenClaw

OpenClaw requires 64-bit Raspberry Pi OS and at least 2 GB of RAM (4 GB recommended). The Pi 4 and Pi 5 both work. The official install script handles Node.js and other dependencies:

sudo apt update && sudo apt upgrade -y
curl -fsSL https://openclaw.ai/install.sh | bash

Run the onboarding wizard to configure API keys and register the gateway as a systemd service:

openclaw onboard --install-daemon

The static IP ensures that any webhook URLs pointing to your Pi remain valid after every reboot, so you can configure them once and forget about them.

Harden the Service for Always-On Operation

The default systemd unit works, but adding a restart policy handles transient failures automatically. Create a drop-in override:

mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d
cat > ~/.config/systemd/user/openclaw-gateway.service.d/restart.conf << 'EOF'
[Service]
Restart=always
RestartSec=2
TimeoutStartSec=90
Environment=OPENCLAW_NO_RESPAWN=1
EOF
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service

Enable Lingering for Headless Operation By default, systemd kills user services when the user logs out. On a headless Pi where you connect and disconnect via SSH, this is a problem. Enable lingering so the gateway stays alive:

sudo loginctl enable-linger "$(whoami)"

Verify the service is running:

systemctl --user status openclaw-gateway.service

Your OpenClaw agent now starts on boot, restarts on crash, and listens at the same IP address every time. Since the Pi 5 draws only 5 to 7 watts under load, running the gateway 24/7 costs roughly $0.50 per month in electricity at typical US residential rates.

Agent audit trail showing automated operations

Persist Agent Output in a Cloud Workspace

An OpenClaw agent on a Raspberry Pi generates files: research reports, code artifacts, downloaded datasets, processed documents. Storing everything on the Pi's SD card creates two problems. SD cards wear out from repeated writes, and a card failure means losing all agent output. The data also stays trapped on the Pi, invisible to anyone who does not have SSH access.

Local alternatives like an external USB SSD solve durability but not collaboration. Cloud object stores like S3 require managing credentials, bucket policies, and a separate sharing tool for non-technical teammates.

Fast.io provides cloud workspaces where agents store, organize, and share files, and where humans pick up the output without needing terminal access. The free agent plan includes 50 GB of storage, 5,000 monthly credits, and 5 workspaces with no credit card or expiration.

Agents connect through the Fast.io MCP server, which exposes workspace, storage, AI, and workflow operations over Streamable HTTP at /mcp. Enable Intelligence Mode on a workspace, and uploaded files are automatically indexed for semantic search and citation-backed chat. No separate vector database required.

When the agent's work is done, ownership transfer lets you hand the entire workspace to a client or teammate. The agent keeps admin access for ongoing updates while the recipient gets full control of files and shares.

For teams running multiple Pi-based agents, Fast.io workspaces give each agent its own storage scope while keeping everything accessible from a single dashboard. File locks prevent conflicts when two agents write to the same workspace, and audit trails log every operation for debugging.

Frequently Asked Questions

How do I set a static IP on Raspberry Pi?

On Raspberry Pi OS Bookworm and later, use nmcli. Run three commands: set ipv4.addresses and ipv4.method to manual, set ipv4.gateway to your router's address, and set ipv4.dns to your preferred DNS servers. Then cycle the connection with nmcli connection down followed by nmcli connection up. The old dhcpcd.conf method no longer works on Bookworm.

What is the difference between DHCP and a static IP on Raspberry Pi?

DHCP lets your router assign an IP address automatically, which can change after a lease expires or a router restart. A static IP is a fixed address you configure manually so the Pi always appears at the same location on your network. Static IPs are necessary for headless servers, SSH access, webhook endpoints, and port forwarding rules that need a stable target.

How do I find my Raspberry Pi IP address?

Run 'ip addr show eth0' for Ethernet or 'ip addr show wlan0' for WiFi. The address appears on the inet line. You can also run 'nmcli device show' for a detailed view that includes gateway and DNS information alongside the IP address.

Does Raspberry Pi keep its IP address after reboot?

With DHCP, the Pi usually gets the same address back if the lease has not expired, but this is not guaranteed. With a static IP configured through nmcli, the address is stored in NetworkManager's connection profile and applied on every boot. The configuration persists in /etc/NetworkManager/system-connections/.

Why did Raspberry Pi switch from dhcpcd to NetworkManager?

The Raspberry Pi Foundation adopted NetworkManager as the default in Bookworm (October 2023) because it supports features dhcpcd lacked: hidden wireless networks, VPN connections, hotspot mode, and a richer command-line interface through nmcli and nmtui. The change aligns Raspberry Pi OS with the direction most Linux distributions have taken.

Can I set a static IP before first boot on Raspberry Pi?

Yes. NetworkManager's nmcli supports an --offline flag that lets you create or modify connection profiles before the Pi boots for the first time. This is useful for headless setups where you flash the SD card, configure networking, and deploy the Pi without ever connecting a monitor.

Related Resources

Fastio features

Give your OpenClaw agent persistent cloud storage

Free 50 GB workspace with MCP access for your Pi-based agents. Store output, share with clients, transfer ownership when the job is done. No credit card, no expiration.