1. 利用resolvconf:
    安装resolvconf:
    apt-get install resolvconf
    修改 /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8

重启虚拟机,dns将被自动写入 /etc/resolv.conf

  1. 修改interfaces:
    修改 /etc/network/interfaces,例如:
auto eth0
iface eth0 inet static
address 112.23.11.18
netmask 255.255.255.128
gateway 112.213.110.29
auto eth1
iface eth1 inet static
address 10.0.151.34
netmask 255.0.0.0
dns-nameservers 8.8.8.8 114.114.114.114 223.5.5.5

重启虚拟机,配置生效到 /etc/resolv.conf中。

如果觉得我的文章对你有用,请随意赞赏