Giving Raspberry Pi a static IP address

Today I want to write a post about giving Raspberry Pi a static IP address. This will be much help because we don’t have to search for its IP again and again. But I told you that if you forgot what’s the static IP was, there will be almost impossible to find it back, so it’s better to do a fresh OS install for your ‘lost’ Raspberry Pi. At this point, if you have any unused monitor with HDMI cable, maybe you can get your lost Raspberry Pi back by plugging it into monitor and restore the configuration file into before the configuration was made.

Okay let’s start the configuration..

First, ensure you are logged in into your Raspberry pi. You can do this either by using a monitor or using SSH service into your Raspberry Pi (by scanning its IP address first of course).

Second, edit the network configuration file, especially the DHCP file located at /etc/dhcpcd.conf. You can do this by executing this command:

pi@raspberrypi:~$ sudo nan0 /etc/dhcpcd.conf

After that, scroll to the bottom. At the lowermost line, add the following lines:

Configuration changes

You can change the IP address above. Note that I’m using those address because my network is actually using that address. You can change them whatever you want. The word ip_address is what IP address that we want to give to Raspberry Pi. The routers is what the gateway address. And the domain_name_servers is the address for DNS. In my case, I’m just setting the gateway address and the DNS server address into my laptop, which is 10.42.0.1.

Finally, save the file, and reboot your Raspberry Pi. And after that, it should working, you can check it by executing command ifconfig to check the address of your Raspberry Pi.

I think that’s all about making Raspberry Pi using static IP address. Thanks for reading this post!

Source: here.

Like what you read? Give Fatah Nur Alam Majid a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.