由于公司的服务基本都是ubuntu的,大部分和centos差不多,还是有区别的。如下记录修改DNS
root@ubuntu:~#cat/etc/resolvconf/resolv.conf.d/base#(这个文件默认是空的) nameserver218.2.2.2 nameserver223.5.5.5
#新插入的DNS说明
218.2.2.2 是南京电信的DNS
223.5.5.5 是阿里的DNS
如果有多个DNS就一行一个
修改好以后重新加载,执行resolvconf -u
root@ubuntu:~#sudoresolvconf-u root@ubuntu:~#cat/etc/resolv.conf #Dynamicresolv.conf(5)fileforglibcresolver(3)generatedbyresolvconf(8) #DONOTEDITTHISFILEBYHAND--YOURCHANGESWILLBEOVERWRITTEN nameserver218.2.2.2 nameserver223.5.5.5
可以看到我们的设置已经加上了,然后再ping一个域名,当时就可以解析了,无需重启。
root@ubuntu:~#ping-c4baidu.com PINGbaidu.com(111.13.101.208)56(84)bytesofdata. 64bytesfrom111.13.101.208:icmp_seq=1ttl=50time=25.0ms 64bytesfrom111.13.101.208:icmp_seq=2ttl=50time=26.0ms 64bytesfrom111.13.101.208:icmp_seq=3ttl=50time=24.8ms 64bytesfrom111.13.101.208:icmp_seq=4ttl=50time=25.6ms ---baidu.compingstatistics--- 4packetstransmitted,4received,0%packetloss,time3006ms rttmin/avg/max/mdev=24.812/25.380/26.025/0.503ms