Linux创建完虚拟机centos6后,有时不能上网,ping www.baidu.com时,出现connect: Network is unreachable

Linux创建完虚拟机centos6后,有时不能上网,ping www.baidu.com时,出现connect: Network is unreachable,但ping网关又正常,有可能是本地没有默认的路由

转载于虚拟机centos6 ping 百度时出现Network is unreachable–乾元轩 http://www.imwen.com/post/319.html

问题:创建完虚拟机centos6后,有时不能上网,ping www.baidu.com时,出现connect: Network is unreachable,但ping网关又正常,有可能是本地没有默认的路由
解决:
1、使用ip route查看

192.168.88.0/24 dev eth0 proto kernel scope link src 192.168.88.100
169.254.0.0/16 dev eth0 scope link metric 1002
2、使用route -n查看

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.88.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
3、添加静态的默认路由,即网关

route add default gw 192.168.88.2
4、再次查看路由表
[root@CentOS64 ~]# ip route
192.168.88.0/24 dev eth0 proto kernel scope link src 192.168.88.100
169.254.0.0/16 dev eth0 scope link metric 1002
default via 192.168.88.2 dev eth0
[root@CentOS64 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.88.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
0.0.0.0 192.168.88.2 0.0.0.0 UG 0 0 0 eth0
5、测试,成功
[root@CentOS64 ~]# tracepath www.baidu.com
[LOCALHOST] pmtu 1500
1: 192.168.88.2 (192.168.88.2) 0.192ms
2: 192.168.88.2 (192.168.88.2) 0.122ms
@猪十三少 投稿作品

你可能感兴趣的:(Linux创建完虚拟机centos6后,有时不能上网,ping www.baidu.com时,出现connect: Network is unreachable)