记一次ping: unknown host错误

Posted wxzhe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了记一次ping: unknown host错误相关的知识,希望对你有一定的参考价值。

虚拟机上一台主机,之前一直在用,可以通过xshell连接,但是忽然发现ping百度失败了!

[[email protected] ~]# ping www.baidu.com
ping: unknown host www.baidu.com

检查这个失败感觉很麻烦,检查了配置文件,修改了ip结果都不可以!但是发现ping  ip地址是可以的!

[[email protected] ~]# ping 14.215.177.39             #百度的一个ip
PING 14.215.177.39 (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39: icmp_seq=1 ttl=56 time=14.2 ms
64 bytes from 14.215.177.39: icmp_seq=2 ttl=56 time=5.94 ms
^C
--- 14.215.177.39 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1945ms
rtt min/avg/max/mdev = 5.941/10.113/14.285/4.172 ms
[[email protected] ~]

感觉应该是域名解析的问题,检查了/etc/resolv.conf配置文件,发现文件是空的(不晓得为啥?)在文件中添加域名解析服务器!

[[email protected] ~]# cat /etc/resolv.conf 
nameserver 192.168.1.1              #当前服务器的网关
nameserver 8.8.8.8

问题解决:

[[email protected] ~]# ping www.baidu.com
PING www.baidu.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39: icmp_seq=1 ttl=56 time=13.0 ms
64 bytes from 14.215.177.39: icmp_seq=2 ttl=56 time=6.62 ms
^C
--- www.baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1732ms
rtt min/avg/max/mdev = 6.629/9.860/13.091/3.231 ms

 

以上是关于记一次ping: unknown host错误的主要内容,如果未能解决你的问题,请参考以下文章

CentOS ping: unknown host 解决方法

Linux不能上网ping:unknown host问题怎么解决?

ping unknown host解决办法

ping: unknown host www.baidu.com

linux 下出现ping: unknown host www.baidu.com问题

1.linux ping:unknown host www.***.***