Setup Static IP Address on Raspberry Pi – Part 1

We are in part 2 of tutorial series of Building Raspberry Pi Line Follower Robot! If you want to jump back and forth or missed any of my previous tutorials – here is the consolidated list.

All Tutorials to Build IOT Raspberry Pi Robot

  1. Build Raspberry Pi Robot controlled by Internet – IOT Robot
  2. Setup Static IP Address on Raspberry Pi
  3. Installing Web Server on Raspberry Pi
  4. Controlling Raspberry Pi LED via internet
  5. Raspberry Pi LED controlled by Internet
  6. Build REST API using Python and Flask
  7. Raspberry Pi Robot Logitech Camera Server
  8. Create Web Dashboard for IOT Robot Control

Entire project Video Tutorial


Having a Static IP Address on the Raspberry Pi is extremely helpful as it will make the SSH association of the Raspberry Pi substantially more straightforward. In the event that you recall that, we have to check for the IP Address of the Raspberry Pi at whatever point we have to interface with it through SSH. On the off chance that you attempt to login utilizing a more seasoned IP Address, you will be denied get to.

This is on account of, each time your Raspberry Pi boots (reboot), it will have another IP Address allocated by the Router. This kind of changing IP Addresses is called Dynamic IP Address. At whatever point we detach the Raspberry Pi from the system or turn down its power, the IP Address will change. On the off chance that you are worn out on filtering the IP Address of your Raspberry Pi each time you need to login utilizing SSH or remote association, at that point appointing a Static IP Address to the Raspberry Pi would make your life simple.

Setting Up Static IP Address

We will see the means to set a Static IP Address on our Raspberry Pi. By Static IP Address, we don’t mean a committed Static IP Address from the ISP. We mean a changeless IP Address from our router.

Actually, the Router, which we use in our homes, goes about as a DHCP Server as it relegates Dynamic IP Addresses to the gadgets associated with the system.

What we will do is, out of the conceivable IP Addresses, we will allot a Static IP Address (in fact, two Static IP Addresses – one for Wired Connection and the other for WLAN) for our Raspberry Pi.

Find Default Gateway

If you are using windows – go to command prompt and type ipconfig. You can find out default gateway from here.

You can also find gateway from SSH via command route -n

In my case it is 192.168.1.1

If we want to set a Static IP Address to our Raspberry Pi, it should be in the range 2 – 255. Also, the Static IP Address we assign shouldn’t be already assigned to any other gadget.

Finding DNS

In windows you can go to command prompt and type in ipconfig /all

In Raspberry Pi via SSH you can type command

Network Settings Config

Now, we will setup network settings. For that, we need to modify the dhccpcd.conf file. The dhcpcd is a DHCP Client that configures the system to work on a network. To open the dhcpcd file, type the following command and hit enter.

sudo nano /etc/dhcpcd.conf

You will find several lines of code already present in the file. If you scroll down to the end of the file, you will find the line nohook lookup-hostname. Without making any changes to the existing commands (even if they are commented – starting with #), type the following code in the dhcpcd.conf file.

Test the Static IP Address

Reboot the Raspberry Pi with this command: sudo reboot

Now if you open Advanced IP Scanner application, Pi 3 will have IP address 192.168.1.100. So, no more pain now to keep on changing IP address.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *