Linux ping不通域名的解决办法

来源:互联网 发布:淘宝商品推广的方法 编辑:程序博客网 时间:2024/04/29 15:18

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

ping www.baidu.com
ping: unknown host www.baidu.com

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

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

cat /etc/resolv.conf
-------------------------------------------------------------------
nameserver 8.8.8.8
nameserver 8.8.4.4
-------------------------------------------------------------------

2) 确保网关已设置

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

ps:ubuntu 10.3  找不到此文件,也许版本不对


3) 确保可用dns解析

grep hosts /etc/nsswitch.conf
-------------------------------------------------------------------
hosts:      files dns
-------------------------------------------------------------------

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

#ping -c 3 www.baidu.com
PING www.a.shifen.com (220.181.6.175) 56(84) bytes of data.
64 bytes from 220.181.6.175: icmp_seq=0 ttl=50 time=9.51 ms
64 bytes from 220.181.6.175: icmp_seq=1 ttl=50 time=8.45 ms
64 bytes from 220.181.6.175: icmp_seq=2 ttl=50 time=8.97 ms
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 8.450/8.977/9.511/0.446 ms, pipe 2

--End--

0 0
原创粉丝点击