Complete Guide to Setting a Static IP on Raspberry Pi: Enhance Network Stability and Access
April 22, 2024

When you set a static IP address for your Raspberry Pi, you're essentially assigning it a fixed address that doesn't change, unlike a dynamic IP that can change each time the device connects to the network.
Setting a static IP address on a Raspberry Pi can be beneficial for several reasons:
Consistent Access
With a static IP, you always know the IP address of your Raspberry Pi. This makes it easier to access services running on the Pi (like a web server, SSH or VNC) because the address doesn't change.

Network Stability
Dynamic IPs can change each time a device reconnects to the network, which can cause interruptions in services. A static IP ensures that the Raspberry Pi maintains a stable connection with a fixed address.
Port Forwarding
If you want to access your Raspberry Pi from outside your local network (for example, over the internet), you'll likely need to set up port forwarding on your router. Having a static IP simplifies this process because you don't have to update the forwarding rule whenever the IP changes.
Example with remote access to a Raspberry Pi with static ip: 192.168.1.124 via VNC from internet.

Server Hosting
If you're hosting services or applications on your Raspberry Pi (like a media server or a web server), a static IP ensures that clients can always reach your Pi using the same address.
Networked Device
If you have multiple devices on your network that need to communicate with the Raspberry Pi (such as IoT devices or other computers), a static IP makes it easier to configure network settings and establish reliable connections.
Network Monitoring and Management
For network administrators or enthusiasts who want more control over their network infrastructure, assigning static IPs allows for better organization, monitoring, and management of devices.
To set a static IP address on a Raspberry Pi running Raspberry Pi OS, you must know 5 fundamental parameters:
interface_name: This is typically eth0 for Ethernet or wlan0 for Wi-Fi.
static_ip_address: Enter the desired static IP address for your Raspberry Pi.
static_router: Enter the IP address of your router or gateway.
static_dns: Specify the DNS server's IP address. You can use a public DNS like Google's (8.8.8.8) or your router's DNS.
By Terminal

1.Open Terminal:
You can either connect directly to your Raspberry Pi via SSH or open a terminal window if you're using a monitor and keyboard connected to the Pi.
2.Edit dhcpcd.conf:
sudo nano /etc/dhcpcd.conf
Use the following command to open the dhcpcd.conf file in a text editor (e.g., nano):
3.Configure Static IP
Scroll to the bottom of the file and add the following lines (replace interface_name,
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8
static_ip_address, static_router, and static_dns with your desired values):
4.Save and Exit:
After making changes, press Ctrl + X, then Y to confirm saving, and press Enter to exit nano.
5.Restart dhcpcd:
sudo systemctl restart dhcpcd
To apply the changes, restart the dhcpcd service with the command:
6.Verify IP Configuration:
ip addr show
Check if the static IP is configured correctly by running:
After completing these steps, your Raspberry Pi should now have a static IP address configured. You can test the connectivity to ensure everything is working as expected.
By GUI
1.Open the panel Wireless & Wired Network Settings

2.Select the Interface and complete IPv4, Router and DNS Servers

3.Clic Apply and reboot