From a4e49535a8702e16e40c3617a31afbf65a4aa016 Mon Sep 17 00:00:00 2001 From: willemserruys Date: Sun, 16 Oct 2022 20:07:27 +0200 Subject: [PATCH] add login and logout script for VPN --- VPN/login.sh | 14 ++++++++++++++ VPN/logout.sh | 7 +++++++ 2 files changed, 21 insertions(+) create mode 100755 VPN/login.sh create mode 100755 VPN/logout.sh diff --git a/VPN/login.sh b/VPN/login.sh new file mode 100755 index 0000000..e5cef03 --- /dev/null +++ b/VPN/login.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Connecting to VPN..." + +echo "c HOMESERVER" > /var/run/xl2tpd/l2tp-control + +sleep 10 + +# To have all internet traffic routed through the VPN uncomment: +#ip route add default dev ppp0 + +# To only have a remote subnet routed through the VPN uncomment +# (this line assumes the remote subnet you want routed is 192.168.0.0/24 and the remote VPN end is 10.11.0.1: +ip route add 192.168.2.0/24 via dev ppp0 onlink diff --git a/VPN/logout.sh b/VPN/logout.sh new file mode 100755 index 0000000..b8803b5 --- /dev/null +++ b/VPN/logout.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +ip route del default dev ppp0 +ip route del 192.168.2.0/24 dev ppp0 + +echo "d HOMESERVER" > /var/run/xl2tpd/l2tp-control +service xl2tpd restart