今天,我在玩vmware的时候,用ping命令ping www.baidu.com的时候,结果显示unkown hosts www.baidu.com,但ping某一ip是正常的.
实例如下:
[[email protected] ~]# ping www.baidu.com
ping: unknown host www.baidu.com
[[email protected] ~]# 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
显示正常.