一台debian的机器,无法ping通域名
提示unknow hosts,开始以为是没设置DNS
cat /etc/reslove.conf
nameserver 202.106.0.20
奇怪了想用nslookup和dig命令,结果没有安装这2个包
那就先apt-get install dnsutils
然后dig -t a www.baidu.com
; <<>> DiG 9.4.2 <<>> -t a www.baidu.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5977
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 4, ADDITIONAL: 0
;; QUESTION SECTION:
;www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 1137 IN CNAME www.a.shifen.com.
www.a.shifen.com. 1137 IN A 202.108.22.5
www.a.shifen.com. 1137 IN A 202.108.22.43
;; AUTHORITY SECTION:
a.shifen.com. 71693 IN NS ns6.a.shifen.com.
a.shifen.com. 71693 IN NS ns1.a.shifen.com.
a.shifen.com. 71693 IN NS ns3.a.shifen.com.
a.shifen.com. 71693 IN NS ns5.a.shifen.com.
;; Query time: 647 msec
;; SERVER: 211.99.197.19#53(211.99.197.19)
;; WHEN: Sun Mar 30 00:35:25 2008
;; MSG SIZE rcvd: 162
看来DNS是正常的,那为啥ping www.baidu.com不能解析呢?
exchange:~# ping www.baidu.com
ping: unknown host www.baidu.com
原来是/etc/nsswitch.conf里面的设置
vi /etc/nsswitch.conf
hosts: files
在后面加一个dns就可以了
hosts: files dns
保存退出
exchange:~# ping www.baidu.com
PING www.a.shifen.com (202.108.22.5) 56(84) bytes of data.
64 bytes from xd-22-5-a8.bta.net.cn (202.108.22.5): icmp_seq=1 ttl=51 time=371 ms
现在可以解析了
作者:风吹云动