Ubuntu 能ping通DNS 地址 无法解析域名
ping通qq百度都行,唯独谷歌不行,
主机能够ping通google的dns服务器地址 8.8.8.8,却无法解析域名
$ ping www.google.co.uk
ping: unknown host www.google.co.uk
查看/etc/network/interfaces文件写的有 dns-nameservers 8.8.8.8 8.8.4.4 这句,再查看/etc/resolv.conf 文件,
$ 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 8.8.8.8 nameserver 8.8.4.4
重启网卡,发现还是不行,再看这个文件,nameserver的配置又不见了。
又查了下资料,发现/etc/resolv.conf 每次都要重写,需要更改
/etc/resolvconf/resolv.conf.d/head
在这个文件末尾增加nameserver 配置
# 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 8.8.8.8 nameserver 8.8.4.4
重启网卡就好了
BTW, 我在CentOS7.1也碰到同样的情况,Ping 8.8.8.8可以,不能解析。
错误提示: failed to start lsb bring up/down networking。 通过以下操作解决了问题:
systemctl stop NetworkManager
systemctl disable NetworkManager
Reboot
。。。。。。
systemctl start NetworkManager
systemctl enable NetworkManager
专业从事搬砖多年,还是在继续搬砖中,厚积薄发~