Ubuntu中设置永久的DNS
2017-01-23 13:52
218 查看
由于公司的服务基本都是ubuntu的,大部分和centos差不多,还是有区别的。如下记录修改DNS
218.2.2.2 是南京电信的DNS
223.5.5.5 是阿里的DNS
如果有多个DNS就一行一个
修改好以后重新加载,执行resolvconf -u
我举个例子,删除了我默认网关,然后添加上就OK了
root@ubuntu:~# 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
root@ubuntu:~# sudo resolvconf -u root@ubuntu:~# 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一个域名,当时就可以解析了,无需重启。
root@ubuntu:~# 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此时若是还是不能ping外网,在查查你的网关
我举个例子,删除了我默认网关,然后添加上就OK了
root@ubuntu:/home/leco# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 root@ubuntu:/home/leco# sudo route add default gw 192.168.5.1 root@ubuntu:/home/leco# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.5.1 0.0.0.0 UG 0 0 0 eth0 192.168.5.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 root@ubuntu:/home/leco# ping 117.185.7.45 PING 117.185.7.45 (117.185.7.45) 56(84) bytes of data. 64 bytes from 117.185.7.45: icmp_seq=1 ttl=50 time=10.1 ms ^C --- 117.185.7.45 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 10.179/10.179/10.179/0.000 ms root@ubuntu:/home/leco# ping baidu.com PING baidu.com (180.149.132.47) 56(84) bytes of data. 64 bytes from 180.149.132.47: icmp_seq=1 ttl=55 time=24.1 ms ^C --- baidu.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 24.181/24.181/24.181/0.000 ms
相关文章推荐
- ubuntu设置永久dns
- ubuntu设置DNS永久生效
- ubuntu 永久设置dns信息
- Ubuntu中设置永久的DNS
- ubuntu永久dns设置
- ubuntu 永久设置静态ip和dns
- 【Linux】Ubuntu -- 设置永久 DNS
- ubuntu 12.04 设置DNS的一种方法
- DNS服务器设置(Ubuntu10.04)
- ubuntu设置ip和dns
- Ubuntu DNS配置与使用命令设置Ubuntu的ip地址
- ubuntu设置ip和dns
- ubuntu 11.10 /etc/resolv.conf文件重启被清除,dns设置
- ubuntu设置ip和dns
- ubuntu设置静态IP及修复重启电脑后DNS须重新设置的问题
- Ubuntu实践(5):DNS服务器设置
- ubuntu 手动设置DNS服务器,重启后不能上网
- [转]Ubuntu 11.04设置IP地址和DNS
- ubuntu 8.10 设置IP及DNS(解决重启需要重设的问题)
- Ubuntu DNS配置与使用命令设置Ubuntu的ip地址