A static IP address, as opposed to a dynamic IP address, doesn’t change. The single-board computer Raspberry Pi always needs a static IP address; if we want to access it with other devices for a long time. This refers to the private IP address of the Raspberry IP that a computer locates within the local network as well as the public IP address of the network via which we can access the Raspberry Pi on the internet. For example, if we’re using it as as a server. But how do we provide Raspberry Pi with an IP address that is always the same? This tutorial will explain which options we have for linking a static IP address to our Raspberry Pi.
Want to buy a Raspberry pi?
- Raspberry Pi 4 Model B
- Raspberry Pi 3 Model B+
- 5V 2.5A US/EU Plug Power Supply Adapter
- 5V Type C adapter
- Pi 3B+Heatsink
Step 1: Plugging in the Raspberry Pi
First of all, we need to have a Raspberry Pi board and an SD card on which we have installed the Raspbian OS. Then we should plug the board to our computer and open Raspbian OS.
Step 2: Check the parameters
Once the terminal in the OS is opened, we need to check our IP address. For that type
And it will give us information about the network connection. By checking, we can find the IP address. Then we have to check our gateway. We have to type
sudo route -n
Which will show us our gateway.
Step 3: Assigning a static IP address
We have checked our parameters such as the IP address and gateway. Now, we have to assign an IP address. for that we have to type
sudo nano /etc/dhcpcd.conf
This will open the file “/etc/dhcpcd.conf”. After that, we should type the following:
interface wlan0 static ip_address=192.168.0.75 //this is your static IP address static routers=192.168.0.1 //this is your gateway IP address static domain_name_servers= 22.214.171.124 126.96.36.199
Note: Ethernet users should type interface eth0
Once done, we have to type ‘Ctrl+X’ and press ‘Y’ for the question asked, and press ‘enter’. Then type ‘sudo reboot’. Once the board is rebooted, we should check the IP address by typing ‘ifconfig’. And we can see that a static IP address has been assigned to our Raspberry Pi.
Note: If we wish to connect to our Raspberry Pi through remote control, we need to have a static IP address, so that we can connect to it.
Here is awesome tutorial