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:
- 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. - Log in to your router’s web interface (usually accessible at
192.168.1.1
or192.168.0.1
). - Locate the DHCP reservation settings (may be called “Static DHCP” or “IP reservation”).
- Enter the MAC address and assign a desired IP address.
- 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:
- Open the terminal and edit the
dhcpcd.conf
file:sudo nano /etc/dhcpcd.conf
- 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
- Save the file by pressing
CTRL+X
, thenY
, andEnter
. - Restart the networking service:
sudo systemctl restart dhcpcd
- 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:
- Open the terminal and edit the NetworkManager configuration file:
sudo nano /etc/NetworkManager/system-connections/<your-connection>.nmconnection
- 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;
- Save and close the file, then restart NetworkManager:
sudo systemctl restart NetworkManager
- 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:
Pingback: Raspberry Pi - Introduction | Overview | Setup and Management | Tutorials
Pingback: MEAN STACKS ? | Introducing the MEAN and MERN Stacks
Pingback: Rock Pi 4 GPIO Description - IoTbyHVM - Bits & Bytes of IoT
Pingback: RedConnect - Flow Based Programming - IoTbyHVM - Bits & Bytes of IoT
Pingback: Arduino SPI Tutorial - IoTbyHVM - Bits & Bytes of IoT
Pingback: Zigbee Introduction | Zigbee vs WiFi | What is Zigbee
Pingback: Control LED using Raspberry Pi with Telegram Bot
Pingback: Paytm will launch SIM-card enabled ‘Soundbox’ to allow app-less transactions
Pingback: NIO Visual Programming Language IDE - IoTbyHVM - Bits & Bytes of IoT
Pingback: Raspberry Pi — Introduction | Overview | Setup and Management | Tutorials - CompileIoT
Pingback: Raspberry Pi Introduction and Tutorials — OnionLinux