栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

ping不通外网 连不上外网

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ping不通外网 连不上外网

当你发现试过网上的大多数可以搜到的博客之后还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

可以了!!!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/941955.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号