由于公司的服务基本都是ubuntu的,大部分和centos差不多,还是有区别的。如下记录修改DNS
[email protected]:~# cat /etc/resolvconf/resolv.conf.d/base #(这个文件默认是空的) nameserver 218.2.2.2 nameserver 223.5.5.5
#新插入的DNS说明
- 218.2.2.2 是南京电信的DNS
- 223.5.5.5 是阿里的DNS
- 如果有多个DNS就一行一个
修改好以后重新加载,执行resolvconf -u
[email protected]:~# sudo resolvconf -u [email protected]:~# cat /etc/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 nameserver 218.2.2.2 nameserver 223.5.5.5
可以看到我们的设置已经加上了,然后再ping一个域名,当时就可以解析了,无需重启。
[email protected]:~# ping -c4 baidu.com PING baidu.com (111.13.101.208) 56(84) bytes of data. 64 bytes from 111.13.101.208: icmp_seq=1 ttl=50 time=25.0 ms 64 bytes from 111.13.101.208: icmp_seq=2 ttl=50 time=26.0 ms 64 bytes from 111.13.101.208: icmp_seq=3 ttl=50 time=24.8 ms 64 bytes from 111.13.101.208: icmp_seq=4 ttl=50 time=25.6 ms --- baidu.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3006ms rtt min/avg/max/mdev = 24.812/25.380/26.025/0.503 ms
时间: 2024-10-21 14:28:51