##设置IP地址、网关 cp /etc/network/interfaces /etc/network/interfacesbak #备份原有配置文件 vim /etc/network/interfaces #编辑网网卡配置文件 auto lo auto eth0 iface lo inet loopback iface eth0 inet static address 192.168.21.166 netmask 255.255.255.0 gateway 192.168.21.2 dns-nameservers 192.168.20.20
直接修改/etc/resolv.conf 重启后可能会清空
vim /etc/resolvconf/resolv.conf.d/base nameserver 192.168.20.20 nameserver 114.114.114.114 sudo resolvconf -u #使配置生效