虚拟机上一台主机,之前一直在用,可以通过xshell连接,但是忽然发现ping百度失败了!
[root@mgt02 ~]# ping www.baidu.com ping: unknown host www.baidu.com
检查这个失败感觉很麻烦,检查了配置文件,修改了ip结果都不可以!但是发现ping ip地址是可以的!
[root@mgt02 ~]# 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 [root@mgt02 ~]
感觉应该是域名解析的问题,检查了/etc/resolv.conf配置文件,发现文件是空的(不晓得为啥?)在文件中添加域名解析服务器!
[root@mgt02 ~]# cat /etc/resolv.conf nameserver 192.168.1.1 #当前服务器的网关 nameserver 8.8.8.8
问题解决:
[root@mgt02 ~]# 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