vpslijie / chnroutes

Automatically exported from code.google.com/p/chnroutes
0 stars 0 forks source link

Linux ip-pre-up脚本 for openvpn 获取默认网关的方式有误。 #68

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
对于那些使用NetworkManager来配置OpenVPN的用户,下载的脚本有��
�题。不能获取到原来默认的网关。
经过测试,下面的shell可以获取到默认网关。

OLDGW=`ip route show | grep ' proto static' | grep -v tun0 | awk '{print $3}'`

ip-pre-up和ip-down两个脚本可以在VPN连接时,断开时被NetworkManage
r调用。
写一个脚本,放在/etc/NetworkManager/dispatcher.d/40-chroute
#!/bin/sh

export LC_ALL=C

if [ "$2" = "vpn-up" ]; then
/home/netroby/ip-pre-up
fi

if [ "$2" = "vpn-down" ]; then
/home/netroby/ip-down
fi

exit 0

Original issue reported on code.google.com by hufeng1...@gmail.com on 27 Oct 2012 at 12:33

GoogleCodeExporter commented 8 years ago
我发现,,使用
OLDGW=`ip route show | grep ' proto static' | grep -v tun0 | grep -v ppp0 | awk 
'{print $3}'`
可以同时适用networkmanager调用pptp和openvpn

可能ppp0换成ppp* 
会完成adsl拨号然后在拨pptp的方式,,后面待验证。

Original comment by jiec...@gmail.com on 13 Jan 2014 at 1:58