Ubuntu系统的ECS实例修改resolv.conf文件后,由于重启系统,自动还原了之前的DNS配置信息,如下图所示。
Ubuntu系统中/etc/resolv.conf
其实是一个软连接(Link),它其实指向的是/run/resolvconf/resolv.conf
。如果需求开机不进行自动还原,需要修改上述文件。也可以直接修改网卡配置文件,或者修改/etc/resolvconf/resolv.conf.d/tail
文件后通过resolvconf -u
命令进行更新。
可以参阅如下步骤进行修改和调整。
vi /run/resolvconf/resolv.conf
命令,修改配置文件。
$ vi /run/resolvconf/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
options timeout:1 attempts:1 rotate
nameserver 223.5.5.5
nameserver 223.6.6.6
vi /etc/network/interfaces
命令,在网卡配置文件/etc/network/interfaces
里面,添加相应DNS服务器地址,比如:dns-nameservers223.5.5.5 223.6.6.6。
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
address 112.*.*.131
netmask 255.255.252.0
dns-servers 223.5.5.5 223.6.6.6
up route add -net 0.0.0.0 netmask 0.0.0.0 gw 112.*.*.247 dev eth1
auto eth0
iface eth0 inet static
address 10.*.*.214
netmask 255.255.240.0
up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.*.*.247 dev eth0
up route add -net 100.64.0.0 netmask 255.192.0.0 gw 10.*.*.247 dev eth0
up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.*.*.247 dev eth0
~
vi /etc/resolvconf/resolv.conf.d/tail
命令,修改配置文件。
options timeout:1 attempts:1 rotate nameserver 223.5.5.5 nameserver 223.6.6.6
resolvconf -u系统显示类似如下。
Stopped Name Service Cache Daemon: nscd. Starting Name Service Cache Daemon nscd ...done.
在文档使用中是否遇到以下问题
更多建议
匿名提交