To set up a Raspberry Pi with Wi-Fi and a static IP, you need to configure the network interface manually in the operating system—typically Raspberry Pi OS. This ensures the device always uses the same local IP address, which is essential for remote access, hosting services, or consistent device discovery on your network. You’ll need a Raspberry Pi (any model with Wi-Fi, like Pi 3, 4, or Zero W), a microSD card with Raspberry Pi OS installed (desktop or Lite), power supply, and access to your router’s IP address and subnet mask (usually found in router labels or admin settings).

What You'll Need

  • Raspberry Pi (Model 3, 4, 400, or Zero W with built-in Wi-Fi)
  • microSD card (16 GB minimum) preloaded with Raspberry Pi OS (2023 or newer)
  • Power adapter compatible with your Pi model
  • Computer to initially configure the Pi (for headless setup) or monitor/keyboard (for direct setup)
  • Wi-Fi network name (SSID) and password
  • Access to your router’s admin page (to find gateway IP, subnet mask, and DNS server)

Step-by-Step

  1. Boot your Raspberry Pi and log in: If using desktop, log in with your credentials. If using SSH (headless), connect via Terminal (macOS/Linux) or PuTTY (Windows) using the default hostname raspberrypi.local and user pi (password raspberry, unless changed). Ensure Wi-Fi is already connected—either via GUI (desktop) or pre-configured in wpa_supplicant.conf during initial setup.
  2. Identify your current network details: Run ip route show to find your default gateway (e.g., 192.168.1.1). Run ip addr show wlan0 to confirm your current IP address (e.g., 192.168.1.45) and note the subnet mask (e.g., 255.255.255.0, which corresponds to /24). Also run cat /etc/resolv.conf to see your DNS server (often the same as the gateway).
  3. Open the dhcpcd configuration file: Run sudo nano /etc/dhcpcd.conf. Scroll to the bottom of the file (press Ctrl+V repeatedly if needed).
  4. Add static IP configuration: Append the following lines, replacing placeholders with your network values (use your actual gateway, IP, and DNS—do *not* use the example values):
    interface wlan0
    static ip_address=192.168.1.50/24
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1 8.8.8.8
    Replace 192.168.1.50 with an IP *outside* your router’s DHCP range (e.g., if DHCP assigns 100–200, pick 50 or 210). The /24 matches a 255.255.255.0 subnet; use /16 for 255.255.0.0 if your network uses that.
  5. Save and exit: Press Ctrl+O, then Enter to write the file, then Ctrl+X to exit nano.
  6. Restart the networking service: Run sudo systemctl restart dhcpcd. Alternatively, reboot the Pi with sudo reboot for a clean reload—this is recommended.
  7. Verify the static IP: After reboot, run ip addr show wlan0 again. Confirm the IP matches your configured static address. Run ip route show to verify the gateway is set correctly.
  8. Test connectivity: Run ping -c 4 8.8.8.8 to test internet access via IP, then ping -c 4 google.com to confirm DNS resolution works. If both succeed, your static IP is active.

Common Mistakes

Avoid these frequent errors when setting a static IP:

  • Duplicate IP conflict: Picking an IP already assigned by the router’s DHCP pool causes intermittent connectivity loss. Always check your router’s DHCP range (e.g., via 192.168.1.1 admin page) and choose an address outside it.
  • Incorrect subnet mask: Using /24 when your network uses /16 (e.g., 10.0.0.0/16) breaks routing. Match the mask to your network—ip addr show wlan0 shows your current mask before editing.
  • Missing or wrong gateway: Omitting static routers= prevents internet access beyond your local network. Include it even if your DNS seems to work.
  • Editing the wrong file: Raspberry Pi OS uses dhcpcd.conf, *not* /etc/network/interfaces or wpa_supplicant.conf for static IPs. Confusing these causes the Pi to ignore your settings.
  • Forgetting to restart networking: Changes don’t apply until systemctl restart dhcpcd or a reboot. A simple ifdown/ifup is unreliable on newer OS versions.

Tips

  • Reserve IPs in your router: For extra reliability, reserve your Pi’s static IP in the router’s DHCP settings. This prevents other devices from claiming it, even if you misconfigure later.
  • Use a consistent naming scheme: Assign IPs like 192.168.1.100 for servers, 192.168.1.101 for NAS, etc. This avoids confusion and simplifies future management.
  • Test before rebooting: Run sudo dhcpcd -k wlan0 && sudo dhcpcd wlan0 to restart only the Wi-Fi interface without rebooting—saves time during testing.
  • Keep a backup: Before editing, copy the original config: sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.bak. Restore with sudo mv /etc/dhcpcd.conf.bak /etc/dhcpcd.conf if needed.
  • Headless setup trick: If setting up headless, add Wi-Fi credentials *and* static IP settings to /boot/dhcpcd.conf on the microSD card *before first boot* (on Windows/macOS). This allows automatic connection with a static IP on first power-up.

Troubleshooting

If your Pi loses network access after setting a static IP:

  1. Check physical Wi-Fi status: Run nmcli device status or look for wlan0 in ip addr. If it shows NO-CARRIER, the Wi-Fi adapter isn’t connected—re-enter your SSID/password in /etc/wpa_supplicant/wpa_supplicant.conf and restart wpa_supplicant.
  2. Verify the static configuration: Re-run cat /etc/dhcpcd.conf and confirm your interface wlan0 block has no typos (e.g., static ip_address not static ipaddress).
  3. Confirm router reachability: From the Pi, run ping -c 4 192.168.1.1 (replace with your gateway). No response means local network issues—check Wi-Fi password, router status, or try a wired connection to isolate the problem.
  4. Test DNS resolution: If IP ping works but domain ping fails, edit /etc/resolv.conf temporarily to add nameserver 8.8.8.8 and retry. If DNS then works, your router’s DNS is misconfigured; use public DNS like Google (8.8.8.8) or Cloudflare (1.1.1.1).
  5. Roll back changes: If stuck, restore the backup config: sudo mv /etc/dhcpcd.conf.bak /etc/dhcpcd.conf, then reboot. Or remove your static block manually in sudo nano /etc/dhcpcd.conf.
  6. Check for conflicting services: Ensure systemd-networkd isn’t enabled—it conflicts with dhcpcd. Run sudo systemctl is-enabled systemd-networkd; if active, disable with sudo systemctl disable systemd-networkd and reboot.

Frequently Asked Questions

Can I use a static IP over Ethernet instead of Wi-Fi?

Yes—simply replace interface wlan0 with interface eth0 in the /etc/dhcpcd.conf block. The rest of the configuration (IP, gateway, DNS) remains the same.

What if my router uses IPv6?

Raspberry Pi’s default dhcpcd handles IPv4 static IPs. For IPv6, you’d need additional configuration (e.g., static ip6_address=), but most home networks rely on IPv4 for local devices. Stick to IPv4 unless you specifically need IPv6.

Does setting a static IP affect my internet speed?

No—static IPs only fix the address assignment; they don’t alter bandwidth, latency, or throughput. Performance depends on your router, Wi-Fi signal strength, and ISP.

Can I assign different static IPs for different networks?

Not directly with static settings—you’d need to manually edit /etc/dhcpcd.conf each time you move the Pi. For dynamic switching (e.g., home vs. office), use DHCP reservations in each network or consider tools like connman.

Why does my Pi show two IP addresses for wlan0?

This usually means both static and DHCP addresses are assigned. Check /etc/dhcpcd.conf for duplicate entries (e.g., leftover inform lines) or if nohook resolv.conf is missing. Remove duplicates and restart dhcpcd.

Is it safe to use the router’s own IP as the static IP for the Pi?

Absolutely not—assigning the Pi the same IP as the router (192.168.1.1) will cause a conflict and break your entire network. Always pick an unused address outside the DHCP range.