Tuesday, September 26, 2023
How ToIoT HardwaresRaspberry PiTutorials/DIY

How To Setup Static IP Address on Raspberry Pi

If you want to set the IP Address of Your Raspberry Pi So that it does not change. So in this post i am telling to you How To Setup Static IP Address on Raspberry Pi. This is simple, You need to edit the configuration file /etc/network/interfaces.
To edit this file, type the following command:

$ sudo nano /etc/network/interfaces 

You may like also: How To Use Raspberry pi in a truely headless mode

How To Setup Static IP Address on Raspberry Pi

First decide on an IP address to use. You need to pick one that is both unused by any other machine on the network and within the allowed range of IP addresses for your home hub. In this case, I will use Modify the contents of the file, changing the word dhcp to static.

With the file changed as shown here, the static IP address has been assigned to the eth0 interface.

auto lo

iface lo inet loopback
iface eth0 inet static
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

For most networks, the netmask setting should be set to and the gateway should be the IP address of your home router irself. This will be the same as the IP Address you use to connect to the admin console of your router. After you edit and save the file, run the following commands to clear out all the existing DHCP leases, and restart your Pi so that changes will take effect.

$ sudo rm /var/lib/dhcp/*
$ sudo reboot

You may like also:

Buy now : Raspberry PI 3 Model B+ Motherboard

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. I am a tech blogger and an IoT Enthusiast. I am eager to learn and explore tech related stuff! also, I wanted to deliver you the same as much as the simpler way with more informative content. I generally appreciate learning by doing, rather than only learning. 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!

11 thoughts on “How To Setup Static IP Address on Raspberry Pi

Leave a Reply