linux系统:\"ping: unknown host www.baidu.com\"

"ping:unknownhostwww.baidu.com"

解决方案:

如果某台Linux服务器ping不通域名,如下提示:

#pingwww.baidu.com

ping:unknownhostwww.baidu.com

如果确定网络没问题的情况下,可以通过如下步骤寻找解决办法:

1)确定设置了域名服务器,没有的话,建议设置Google的公共DNS服务,它应该不会出问题的

#cat/etc/resolv.conf

-------------------------------------------------------------------

nameserver8.8.8.8

nameserver8.8.4.4

-------------------------------------------------------------------

2)确保网关已设置

#grepGATEWAY/etc/sysconfig/network-scripts/ifcfg*

-------------------------------------------------------------------

/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1

-------------------------------------------------------------------

如果未设置,则通过如下方式增加网关:

#routeadddefaultgw192.168.40.1

或者手工编写/etc/sysconfig/network-scripts/ifcfg*文件后,重启network服务:

#servicenetworkrestart

3)确保可用dns解析

#grephosts/etc/nsswitch.conf

-------------------------------------------------------------------

hosts:filesdns

-------------------------------------------------------------------

如果以上哪个有问题,修正后,再测试,应该就没问题了:

#ping-c3www.baidu.com

PINGwww.a.shifen.com(220.181.6.175)56(84)bytesofdata.

64bytesfrom220.181.6.175:icmp_seq=0ttl=50time=9.51ms

64bytesfrom220.181.6.175:icmp_seq=1ttl=50time=8.45ms

64bytesfrom220.181.6.175:icmp_seq=2ttl=50time=8.97ms

---www.a.shifen.compingstatistics---

3packetstransmitted,3received,0%packetloss,time2002ms

rttmin/avg/max/mdev=8.450/8.977/9.511/0.446ms,pipe2

--End--

相关推荐