Welcome to Raspberry Pi 4B repository
2.5 Fixing Raspberry Pi IP
After we manually set a static IP address for the Raspberry Pi, the IP address of the Raspberry Pi is fixed.
We need to enter the command shown below at the command terminal:
sudo nano /etc/dhcpcd.conf
After entering the file, find the code shown below at the bottom of the file:
If you need to fix the IP address of the Raspberry Pi using the network cable, you can remove the comment symbol "#" and change the static IP to the Raspberry Pi IP when using the network cable
The router/network management IP address is also need to modified:
As shown below(Just for exmaple)
You need to set it according to your actual Raspberry Pi IP when using the network cable.
If you need to fix the IP address of the Raspberry Pi when using wireless, you need to change eth0 to wlan0, and remove the comment symbol "#", and change the static IP to the Raspberry Pi IP when connected to wireless:
As shown below(Just for exmaple)
You need to set it according to your actual Raspberry Pi IP when connected to wireless.
After the modification is completed, press ctrl+x, “y”, “enter” to save and exit the file.
Restart the Raspberry Pi. You will find that the IP address has changed by using the "ifconfig" command on the terminal again.
We need to enter the command shown below at the command terminal to test if the Raspberry Pi can be networked :
sudo apt-get update
Note: The static IP address we set manually cannot be duplicated with the IP address assigned by the router DHCP, otherwise the Raspberry Pi may not be able to connect properly.