Both methods are ok
1. Enter the /etc/rc.local
file:
sudo nano /etc/rc.local
sudo vi /etc/rc.local
2. Add a segment before exit0:
ifconfig wlan0 192.168.x.xxx // 在 ifconfig wlan0 后面添加想要固定的 IP 地址
As shown in the figure:
press ctrl + o to save (if nano editor is used) and
prompt whether to write, press Enter to confirm (if nano editor is used)
press ctrl + x to exit (if nano editor is used)
3. Restart the Raspberry Pi
Both methods are ok
1. Enter the /etc/dhcpcd.conf
file:
vi /etc/dhcpcd.conf
2. Choose to add configuration items:
interface eth0 //指定接口 eth0
static ip_address=192.168.xxx.xxx/24 //指定静态IP,/24表示子网掩码为 255.255.255.0
static routers=192.168.xxx.xxx //路由器/网关IP地址
static domain_name_servers=8.8.8.8 //手动自定义DNS服务器
save document