在阿里云部署的vpn,本地连接后,上不了外网了,经查看,多了一条默认路由,
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.252.13 0.0.0.0 UG 50 0 0 tun0
0.0.0.0 192.168.0.1 0.0.0.0 UG 600 0 0 wlp6s0
10.0.0.0 192.168.252.13 255.0.0.0 UG 50 0 0 tun0
vpn-IP 192.168.0.1 255.255.255.255 UGH 600 0 0 wlp6s0
172.16.162.0 0.0.0.0 255.255.255.0 U 0 0 0 vmnet1
192.168.0.0 0.0.0.0 255.255.255.0 U 600 0 0 wlp6s0
192.168.252.0 192.168.252.13 255.255.255.0 UG 50 0 0 tun0
192.168.252.13 0.0.0.0 255.255.255.255 UH 50 0 0 tun0
# ifconfig
wlp6s0: flags=4163 mtu 1500
inet 192.168.0.190 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::4303:1c6:4625:942d prefixlen 64 scopeid 0x20
tun0: flags=4305 mtu 1500
inet 192.168.252.14 netmask 255.255.255.255 destination 192.168.252.13
可以看见tun0 的 Metric 是50,本地的是600,而且怎么删都删不掉,route del default gw 192.168.252.13
所以只能以退为进,先删除本地默认网关,再加上
route del default gw 192.168.0.1
route add default gw 192.168.0.1
在查看,本地的Metric 就变成0了,这样其他不用变,默认所有流量(除了10.0.0.0网段)走本地。
完美解决!
评论前必须登录!
注册