问题现象:手动设置静态ip地址:sudo vi /etc/network/interfaces发现dns无效,怎么配置都无法上网
问题原因:/etc/resolv.conf是旧时生成文件,重启之后失效
问题解决:使用NetworkManager设置静态ip,方法如下:
1、Check netowrk connection:
pi@Smart4418SDK:~$ sudo nmcli connection show NAME UUID TYPE DEVICE Wired connection 1 cffa785e-0425-3777-b670-092c79328a1f 802-3-ethernet eth0
2、The above messages show that there is a wired connection named "Wired connection 1". You can set a static IP for "Wired connection 1" by running the following commands:
sudo nmcli connection modify 'Wired connection 1' connection.autoconnect yes ipv4.method manual ipv4.address 192.168.2.199/24 ipv4.gateway 192.168.2.1 ipv4.dns 192.168.2.1 sudo reboot
3、If this is successful the connection will be assigned a static IP with IP address to be 192.168.2.199 and both gateway and DNS to be 192.168.2.1
PS:the ‘/24’ represents the number of subnetwork bits active in the mask.