如果在vpn设置/ ipv4设置/路由中选中了“仅将此连接用于其网络上的资源”,则无法从vpn访问类似192.168.12.123的服务器,但是如果未选中此标志,则无法访问。
路由地址/网络掩码:
192.168.0.0 255.0.0.0
10.0.0.0 255.0.0.0
标记未选中:
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 ppp0
10.35.5.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
168.68.168.6 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0
168.68.168.6 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
标志被检查
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 ppp0
10.35.5.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
168.68.168.6 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0
168.68.168.6 192.168.0.1 255.255.255.255 UGH 0 0 0 wlan0
192.168.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
主要区别是网关。
如果未选中标志,则为0.0.0.0;否则为192.168.0.1。
如何更改已检查标志的网关?
感谢前进。
您可以使用命令添加默认网关
通过IP地址
sudo ip route add default via xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
-代表VPN服务器的IP
或通过接口
sudo ip route add default dev ppp0
当您连接到VPN时,可以从终端手动完成此操作。
第二种解决方案是使连接VPN时使脚本具有默认gw的机会
然后,当界面ppp0
打开时,将执行创建脚本女巫。
创建ppp0
界面脚本
sudo nano /etc/ppp/if-up.d/script
在脚本中放这个
# Check for specific interface if desired
[ "$IFACE" != "ppp0" ] || exit 0
# trigger vpn connection
ip route add default dev ppp0
保存并退出。
使script
具有执行权限的脚本被调用755
sudo chmod 755 /etc/network/if-up.d/script
解释
当vpn
连接将建立和ppp0
接口高达脚本将运行并设置为默认设备ppp0
您也可以手动将路由添加到vpn
站点上的资源
sudo ip route add xxx.xxx.xxx.xxx/yy dev ppp0
xxx.xxx.xxx.xxx
-代表主机/网络
yy
-代表网络掩码
例子:
添加到主机10.35.5.181
槽的路径ppp0
sudo ip route add 10.35.5.181/32 dev ppp0
10.35.5.0
使用掩码255.255.255.0
槽将路由添加到网络范围ppp0
sudo ip route add 10.35.5.0/24 dev ppp0
这也可以在中完成Network Manager
。在相同的地方,use this connection only for resources on its network
您可以添加路线。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句