route -n 查看当前网关,发现无线网络没有网关

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.3.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
10.10.80.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

#添加一个
添加的网关和ip在同一个网段:route add default gw 192.168.3.1 dev wlan0
添加的网关和ip不在同一个网段:
1、route add -host 192.168.2.3 dev eth0
2、route add default gw 192.168.2.5 dev eth0

route -n

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.3.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.3.1 0.0.0.0 UG 0 0 0 wlan0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
10.10.80.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐