LINUX 解决linux ping: unknown host www.baidu.com
Posted zxiaotian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LINUX 解决linux ping: unknown host www.baidu.com相关的知识,希望对你有一定的参考价值。
当系统提示:
[root@localhost ~]# ping www.baidu.com
ping: unknown host www.baidu.com
时,首先看看能否ping通路由器,并且路由器能够连接上外网
[[email protected] ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=123 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=175 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=196 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 123.681/165.315/196.354/30.601 ms
如果网络安全没有问题且可以ping通
确定已经设置了域名服务器, 如果没有, 推荐设置DNS服务,
[[email protected] ~]# cat /etc/resolv.conf
search localdomain
因为我的DNS没有设置所以导致了ping外网ping不通。
[[email protected] ~]# vi /etc/resolv.conf
nameserver (自己的IP)
或者加入(网关)
确保网关已设置 :
[[email protected] ~]# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eno16777736:GATEWAY=192.168.100.2
如果未设置, 可以用以下方式增加网关:
# route add default gw 192.168.100.2
确定可用dns解析
# grep hosts /etc/nsswitch.conf
[[email protected] ~]# grep hosts /etc/nsswitch.conf
#hosts: db files nisplus nis dns
hosts: files dns
修复了以上问题,在尝试用ping一下www.baidu.com
[[email protected] ~]# ping www.baidu.com
PING www.a.shifen.com (183.232.231.173) 56(84) bytes of data.
64 bytes from 183.232.231.173: icmp_seq=1 ttl=128 time=31.9 ms
64 bytes from 183.232.231.173: icmp_seq=2 ttl=128 time=26.0 ms
64 bytes from 183.232.231.173: icmp_seq=3 ttl=128 time=26.0 ms
64 bytes from 183.232.231.173: icmp_seq=4 ttl=128 time=25.4 ms
64 bytes from 183.232.231.173: icmp_seq=5 ttl=128 time=25.6 ms
64 bytes from 183.232.231.173: icmp_seq=6 ttl=128 time=37.5 ms
64 bytes from 183.232.231.173: icmp_seq=7 ttl=128 time=27.3 ms
以上是关于LINUX 解决linux ping: unknown host www.baidu.com的主要内容,如果未能解决你的问题,请参考以下文章
LINUX 解决linux ping: unknown host www.baidu.com
linux ip已经配好了也可以ping通,可是cmd ping就不同,linux下ping windows下IP也ping不同 如何解决?