装了一台CentOS7,配置网络后 ping 百度一会通一会不通
详细信息:
[root@localhost ~]# ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
^C
--- baidu.com ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms
[root@localhost ~]# ping baidu.com
PING baidu.com (110.242.68.66) 56(84) bytes of data.
64 bytes from 110.242.68.66: icmp_seq=1 ttl=50 time=31.2 ms
64 bytes from 110.242.68.66: icmp_seq=2 ttl=50 time=30.8 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 30.808/31.019/31.230/0.211 ms
[root@localhost ~]# ping baidu.com
PING baidu.com (39.156.66.10) 56(84) bytes of data.
^C
--- baidu.com ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
问题背景:
排除地址冲突问题后,检查网关和DNS配置8.8.8.8没有问题,还是不行
解决方式:
# 这种情况是域名解析了两个IP地址,后面就使用hosts固定了其中可以通的地址
# 编辑/etc/hosts文件 末尾添加 110.242.68.66 baidu.com
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
110.242.68.66 baidu.com
# 保存退出后再次尝试ping百度 没有问题
说明:
能解决什么问题不清楚