当你发现试过网上的大多数可以搜到的博客之后还ping 不通 www.baidu.com 的时候你的福音终于来了
看这里 你是不是报这个错
ping: www.baidu.com: Name or service not known
或者是这个
ping: 114.114.114.114: connect: Network is unreachable
不慌,遇到这篇文章就是你的福音!!! 记得双击么么哒
没错就是这个命令
netstat -rn
可以看到这些个展示
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.44.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
把你的网关地址加进来 我知道你已经在经历了无数失败后已经把en33文件配置好了 把里面GETWAY复制出来
运行下面命令
route add default gw 192.168.44.2
再运行
netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.44.2 0.0.0.0 UG 0 0 0 ens33
192.168.44.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
多出了192.168.44.2网关
重启下network
service network restart
兄弟 尽情的ping吧
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data.
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=128 time=11.6 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=128 time=10.2 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=128 time=10.2 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2020ms
rtt min/avg/max/mdev = 10.241/10.722/11.656/0.665 ms
[root@localhost network-scripts]# ping 114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=2.58 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=2.17 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=128 time=2.48 ms
64 bytes from 114.114.114.114: icmp_seq=4 ttl=128 time=2.10 ms
64 bytes from 114.114.114.114: icmp_seq=5 ttl=128 time=3.32 ms
64 bytes from 114.114.114.114: icmp_seq=6 ttl=128 time=2.65 ms
当然了,你成功了不用感谢我,感谢这位大哥吧!!!
虚拟机ping不通主机与外网的解决方法_树先森&懒的博客-CSDN博客_linux虚拟机ping不通主机和外网
这时只是暂时的配置,永久配置需要配置文件
vi /etc/sysconfig/network
文件中加入
GATEWAY=你的网关ip
保存并退出
重启网络 service network restart
可以了!!!