From 8e2c203d3575adb153597954438cb40f43bd0857 Mon Sep 17 00:00:00 2001 From: Zeno Zeng Date: Fri, 26 Sep 2014 13:55:11 +0800 Subject: [PATCH] zjunet vpn route --- vpn.sh | 8 ++++++-- xl2tpd.sh | 20 +++++++++++++++----- zjunet.sh | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/vpn.sh b/vpn.sh index f6066d2..bc842b9 100755 --- a/vpn.sh +++ b/vpn.sh @@ -60,13 +60,13 @@ set_up_routes() { esac # NEXTHOP - ip route delete default > /dev/null devs=$(ip addr show | grep 'inet.*ppp' | grep ' 10.5.' | awk '{print $7}') - cmd="ip route add default" + cmd="ip route replace default" for dev in $devs; do cmd="${cmd} nexthop dev ${dev}" done $cmd + ip route } disconnect() { @@ -101,6 +101,10 @@ BASEDIR=$(dirname $0) case "$1" in + route) + set_up_routes + ;; + -d) disconnect ;; diff --git a/xl2tpd.sh b/xl2tpd.sh index 86c98fb..b427d1f 100755 --- a/xl2tpd.sh +++ b/xl2tpd.sh @@ -113,6 +113,17 @@ connect() { xl2tpd-control disconnect ${LAC_NAME} } +disconnect() { + xl2tpd-control disconnect ${LAC_NAME} + tail $PPP_LOG_FILE + echo -n > $PPP_LOG_FILE +} + +# 强制踢下线 +force_disconnect() { + disconnect +} + case $1 in connect) @@ -124,9 +135,8 @@ case $1 in ;; disconnect) - xl2tpd-control disconnect ${LAC_NAME} - tail $PPP_LOG_FILE - echo -n > $PPP_LOG_FILE - ;; - + if [ ! -e $L2TPD_CONTROL_FILE ]; then + xl2tpd_restart + fi + force_disconnect esac diff --git a/zjunet.sh b/zjunet.sh index 3696caf..4c6bc58 100755 --- a/zjunet.sh +++ b/zjunet.sh @@ -41,7 +41,7 @@ Usage: zjunet [ACTION] Actions: user add/edit/delete/list/enable/disable User Manager - vpn connect(-c)/disconnect(-d) Connect VPN + vpn connect(-c)/disconnect(-d)/route Connect VPN / Set up ip route wlan login/logout ZJUWLAN dns Test and set up DNS Server EOF