Raspberry Pi 4B Raspberry Pi | #Beginner Tutorial 06# How to set static IP and fix Raspberry Pi IP

In the process of using the Raspberry Pi, DHCP will often automatically assign the Raspberry Pi’s IP, so the IP address of the Raspberry Pi is not fixed, so you need to check the Raspberry Pi’s IP address every time you log in to the Raspberry Pi remotely. IP address is very troublesome. Therefore, after we manually set a static IP address for the Raspberry Pi, the IP address of the Raspberry Pi is fixed.

Type in the Raspberry Pi terminal:
sudo nano /etc/dhcpcd.conf

After entering the file, find the code as shown below at the bottom of the file:
Insert picture description here

If you need to fix the IP of the Raspberry Pi when 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 should also be modified:
Insert picture description here

If you need to fix the IP of the Raspberry Pi when using wireless, you need to eth0change it wlan0, remove the comment symbol #, and change the static IP to the Raspberry Pi IP when connected to wireless:
Insert picture description here

After modification, press ctrl+x, yto entersave and exit the file

Restart the Raspberry Pi:
sudo reboot

Use the command again in the terminal to view the IP address:
ifconfig

Test whether the Raspberry Pi can connect to the Internet:
ping baidu.com

ipconfigCheck the router ip address under Windows :

  • In the start menu search box, cmdafter entering OK, open the command dialog

  • Enter the ipconfiginstruction, click the Enterbutton to confirm

  • In the pop-up message, find the default gateway, which corresponds to the IP address
    Insert picture description here

Note: The static IP manually set cannot be the same as the IP automatically assigned by the router DHCP, otherwise the Raspberry Pi may not be able to connect to the Internet normally.

Guess you like

Origin blog.csdn.net/Naiva/article/details/105197196