分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

centos6 内网可达,外网不可达 Network is unreachable

发布时间:2023-09-06 02:28责任编辑:白小东关键词:暂无标签

错误内容

[root@djx-2 yum.repos.d]# ping 3.0.82.21connect: Network is unreachable[root@djx-2 yum.repos.d]# ping www.baidu.comconnect: Network is unreachable

局域网和ping网关都是通的,ping外网就出现 Network is unreachable
检查配置文件 ,dns设置没有问题,onboot也设置为yes.

问题原因

本地没有默认路由。

正常的默认网络设置是有默认路由的。

[root@djx-2 ~]# route -nKernel IP routing tableDestination ????Gateway ????????Genmask ????????Flags Metric Ref ???Use Iface192.168.1.0 ????0.0.0.0 ????????255.255.255.0 ??U ????0 ?????0 ???????0 eth0169.254.0.0 ????0.0.0.0 ????????255.255.0.0 ????U ????1002 ??0 ???????0 eth00.0.0.0 ????????192.168.1.254 ??0.0.0.0 ????????UG ???0 ?????0 ???????0 eth0[root@djx-2 ~]# ip route192.168.1.0/24 dev eth0 ?proto kernel ?scope link ?src 192.168.1.201 169.254.0.0/16 dev eth0 ?scope link ?metric 1002 default via 192.168.1.254 dev eth0 

以default开头的就是默认的。

而我们出错的网络配置默认是没有默认路由的。如下图。

[root@djx-2 ~]# ip route192.168.1.0/24 dev eth0 ?proto kernel ?scope link ?src 192.168.1.201 169.254.0.0/16 dev eth0 ?scope link ?metric 1002 [root@djx-2 ~]# route -nKernel IP routing tableDestination ????Gateway ????????Genmask ????????Flags Metric Ref ???Use Iface192.168.1.0 ????0.0.0.0 ????????255.255.255.0 ??U ????0 ?????0 ???????0 eth0169.254.0.0 ????0.0.0.0 ????????255.255.0.0 ????U ????1002 ??0 ???????0 eth0

解决方法

添加默认路由:

route add default ?gw ?192.168.1.254 (这个ip地址是网关地址)

我们再查看下我们默认的配置。

[root@djx-2 ~]# route -nKernel IP routing tableDestination ????Gateway ????????Genmask ????????Flags Metric Ref ???Use Iface192.168.1.0 ????0.0.0.0 ????????255.255.255.0 ??U ????0 ?????0 ???????0 eth0169.254.0.0 ????0.0.0.0 ????????255.255.0.0 ????U ????1002 ??0 ???????0 eth00.0.0.0 ????????192.168.1.254 ??0.0.0.0 ????????UG ???0 ?????0 ???????0 eth0[root@djx-2 ~]# ip route192.168.1.0/24 dev eth0 ?proto kernel ?scope link ?src 192.168.1.201 169.254.0.0/16 dev eth0 ?scope link ?metric 1002 default via 192.168.1.254 dev eth0 

我们可以查看到我们的默认配置已经添加上去了。我们再去ping www.baidu.com .
就可以了。

centos6 内网可达,外网不可达 Network is unreachable

原文地址:https://www.cnblogs.com/operationhome/p/10207257.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved