linux 局域网内通外网不通gateway不生效解决方案

当前操作系统未debian 10

interface内容

auto eth1
allow-hotplug eth1
iface eth1 inet static
address 192.168.6.218
netmask 255.255.0.0
gateway 192.168.6.1
dns-nameservers 202.96.128.86
hwaddress ether ca:9f:57:40:45:7d

 

问题:ping内网通,跨网段也同,ping 192.168.6.1 192.168.1.1 也通 ,百度ip   ping 202.108.22.5 不通

查看问题原因:

ip地址跟dns无关,但是ping下dns发现 8.8.8.8 114.114.114.114  202.96.128.86都不通,说明本机信息路由不到外网

1.有限制得情况下查看到外网得路由器是否绑定内网ip和对应mac

2.查看本地路由是否有到网关得信息

netstat -rn 查看本地路由表显示

Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0  0.0.0.0  255.255.0.0      U 0 0 0 eth1

没有本地到192.168.6.1路由信息,增加一条对应路由

 route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.6.1

netstat -rn 查看本地路由表显示

Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.6.1 0.0.0.0 UG 0 0 0 eth1
192.168.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

有了一条到gateway的路由

再ping 202.108.22.5 通了

 

posted on 2022-04-21 11:20  DuoRuaiMi4567  阅读(814)  评论(0编辑  收藏  举报