标签:dns配置解析
今天,我在玩vmware的时候,用ping命令ping www.baidu.com的时候,结果显示unkown hosts www.baidu.com,但ping某一ip是正常的.
实例如下:
[root@yangguoqiang ~]# ping www.baidu.com
ping: unknown host www.baidu.com
[root@yangguoqiang ~]# ping 119.29.25.60
PING 119.29.25.60 (119.29.25.60) 56(84) bytes of data.
64 bytes from 119.29.25.60: icmp_seq=1 ttl=128 time=41.9 ms
64 bytes from 119.29.25.60: icmp_seq=2 ttl=128 time=43.3 ms
64 bytes from 119.29.25.60: icmp_seq=3 ttl=128 time=41.7 ms
64 bytes from 119.29.25.60: icmp_seq=4 ttl=128 time=41.7 ms
64 bytes from 119.29.25.60: icmp_seq=5 ttl=128 time=42.5 ms
经检查得出,DNS没有配置好:
查看/etc/resolv.conf发现:
nameserver xxx.xxx.xxx.xxx
于是重新配置/etc/resolv.conf
nameserver 8.8.8.8 (google域名主服务器)
nameserver 4.4.4.4 (google域名备用服务器)
配置完成后保存退出.
检测结果:
# ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=128 time=20.8 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=128 time=21.0 ms
64 bytes from 61.135.169.125: icmp_seq=3 ttl=128 time=20.8 ms
使用dig命令:
# dig www.baidu,com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> www.baidu,com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9710
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu,com. IN A
;; ANSWER SECTION:
www.baidu,com. 5 IN A 220.250.64.26
显示正常.
但是服务器重启之后,又会出现域名无法解析的情况,经过分析发现:
/etc/sysconfig/network-scripts/ifcfg-eth0文件中
PEERDNS=no ###DNS系统关闭状态
因此每次重启后DNS系统都无法解析域名。
可以将此项注释或者改为yes,修改完成以后,重启网络即可。
本文出自 “不一样的天空” 博客,谢绝转载!
标签:dns配置解析
原文地址:http://jiekeyang.blog.51cto.com/11144634/1870410