- A static IP address is the opposite of a dynamic IP address and it’s doesn’t change.
- To access raspberry pi with other devices over a long period of time and it’s needing a static IP address.
- using the below command to check whether DHCPCD is already activated or not.
sudo service dhcpcd status
- Here DHCPCD was activated. but if DHCPCD is not activated and follows the below commands.
sudo service dhcpcd start
sudo systemctl enable dhcpcd
- Confirm the original status of the configuration of the file /etc/network/interfaces. the ‘iface’ configuration needs to be set at ‘manual’ for the interfaces.
- after a dhcpcd activation, run the below command to edit the dhcpcd.conf configuration file to set up a static IP address for your Raspberry Pi.
sudo nano /etc/dhcpcd.conf
- The type of network connection is:
wlan0 – Raspberry Pi is connected to the router wirelessly.
eth0 – Raspberry Pi connected using an Ethernet cable.
- Scroll down to the bottom of the file and add below file.
interface wlan0 // for wifi connection.
static ip_address=192.168.0.XXX/24 // To change “X” value only.
- To exit the editor, press “ctrl+x” and press the letter “Y” then hit enter.
- Now reboot a raspberry pi, and everything should be set.
- The new static IP address is assigned to the Raspberry Pi from the dhcpcd.conf file.
- Use the below command to check that it is working correctly.
- now the new static IP address is assigned to the raspberry pi.