How ToIoT HardwaresRaspberry PiTutorials/DIY

How To Setup Static IP Address on Raspberry Pi

Setting up a static IP address on your Raspberry Pi ensures that it always has the same IP address on your local network. This is useful for remote access, SSH connections, or running network services such as a web server. By default, Raspberry Pi gets a dynamic IP assigned by your router’s DHCP server, which may change after a reboot. In this guide, we will configure a static IP address for your Raspberry Pi using different methods.

Prerequisites

  • A Raspberry Pi with Raspberry Pi OS installed
  • A monitor and keyboard (or SSH access)
  • A stable network connection (Ethernet or Wi-Fi)
  • Basic knowledge of Linux commands

Method 1: Setting a Static IP via DHCP Reservation

One of the easiest ways to set a static IP is by configuring your router to assign the same IP to your Raspberry Pi every time it connects. This method ensures that the Raspberry Pi gets a fixed IP without changing any settings on the device itself.

Steps:

  1. Find the Raspberry Pi’s MAC address using the following command:
    ip link show eth0  # For Ethernet
    ip link show wlan0  # For Wi-Fi
    

    Look for the link/ether entry, which is the MAC address.

  2. Log in to your router’s web interface (usually accessible at 192.168.1.1 or 192.168.0.1).
  3. Locate the DHCP reservation settings (may be called “Static DHCP” or “IP reservation”).
  4. Enter the MAC address and assign a desired IP address.
  5. Save the changes and reboot the router.

Method 2: Manually Configuring a Static IP on Raspberry Pi

If you cannot set a DHCP reservation, you can manually configure a static IP on the Raspberry Pi itself.

Steps:

  1. Open the terminal and edit the dhcpcd.conf file:
    sudo nano /etc/dhcpcd.conf
    
  2. Scroll down and add the following lines at the end of the file (modify the values according to your network setup):
    interface eth0  # Use wlan0 if configuring for Wi-Fi
    static ip_address=192.168.1.100/24  # Set your desired IP
    static routers=192.168.1.1  # Router IP
    static domain_name_servers=8.8.8.8 8.8.4.4  # Google DNS or your preferred DNS
    
  3. Save the file by pressing CTRL+X, then Y, and Enter.
  4. Restart the networking service:
    sudo systemctl restart dhcpcd
    
  5. Verify the IP address:
    ip a
    

    Ensure the assigned static IP appears in the output.

Method 3: Using NetworkManager (For Raspberry Pi OS Bullseye and Later)

Newer versions of Raspberry Pi OS use NetworkManager to manage network settings.

Steps:

  1. Open the terminal and edit the NetworkManager configuration file:
    sudo nano /etc/NetworkManager/system-connections/<your-connection>.nmconnection
    
  2. Locate the [ipv4] section and modify it as follows:
    [ipv4]
    method=manual
    address1=192.168.1.100/24,192.168.1.1
    dns=8.8.8.8;8.8.4.4;
    
  3. Save and close the file, then restart NetworkManager:
    sudo systemctl restart NetworkManager
    
  4. Confirm the new IP using:
    ip a
    

Troubleshooting

  • If you lose connection after setting a static IP, ensure that the assigned IP is within your router’s subnet range.
  • Check if another device is already using the chosen static IP by running:
    ping 192.168.1.100
    

    If you get a response, choose a different IP.

  • Restart the Raspberry Pi and router if necessary.

Conclusion

Setting a static IP address on your Raspberry Pi ensures stability in network-related tasks such as SSH access and hosting services. Whether you use DHCP reservation or manual configuration, make sure your assigned IP does not conflict with other devices on the network. By following this guide, you can easily configure a static IP and improve the reliability of your Raspberry Pi’s network connectivity.


You may like also:

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin