![为什么普通 wifi 可以正常工作,而添加 wifi 热点连接会导致 VPN 无法正常工作?](https://linux22.com/image/1504942/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%99%AE%E9%80%9A%20wifi%20%E5%8F%AF%E4%BB%A5%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C%EF%BC%8C%E8%80%8C%E6%B7%BB%E5%8A%A0%20wifi%20%E7%83%AD%E7%82%B9%E8%BF%9E%E6%8E%A5%E4%BC%9A%E5%AF%BC%E8%87%B4%20VPN%20%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C%EF%BC%9F.png)
当我从家里连接到我的普通 wifi 连接时,它是 192.168,我的 VPN 一切正常,并使用以下命令为 10.0.0.0 地址添加了所需的额外路由:
路由添加-net 10.0.0.0/8 gw 10.100.1.99
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 303 0 0 wlo1
10.0.0.0 10.100.1.99 255.0.0.0 UG 0 0 0 ppp0
10.100.1.99 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 303 0 0 wlo1
但是当我连接我的 wifi 热点设备(yourkarma.com)时,它会添加:
169.xxx
地址为 192.168 上方的 wlo1,然后 VPN 就无法正常工作。
当 169 ip 在路由 -n 列表中时,知道如何通过 wifi 热点让 VPN 工作吗?
以下是完整历史记录:
route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 303 0 0 wlo1
192.168.0.0 0.0.0.0 255.255.255.0 U 303 0 0 wlo1
echo "c myvpn" > /var/run/xl2tpd/l2tp-control
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 303 0 0 wlo1
10.100.1.99 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.0.0 0.0.0.0 255.255.255.0 U 303 0 0 wlo1
# at this point if I do route add -net 10.0.0.0/8 gw 10.100.1.99
# i would get this new route and ssh to ips inside my vpn would work
# 10.0.0.0 10.100.1.99 255.0.0.0 UG 0 0 0 ppp0
#
# but to show the problem instead of adding that route, I swtich over to karma wifi
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 303 0 0 wlo1
10.100.1.99 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlo1
192.168.1.0 0.0.0.0 255.255.255.0 U 303 0 0 wlo1
# notice the new 169.254.0.0 with that 255.255.0.0 Genmask show up. When I try and
# add the route for 10.0.0.0/8 I get:
SIOCADDRT: Network is unreachable