]> git.sthu.org Git - shutils.git/commitdiff
add openvpn scripts
authorStefan Huber <shuber2@gmx.at>
Mon, 29 Oct 2012 17:08:58 +0000 (18:08 +0100)
committerStefan Huber <shuber2@gmx.at>
Mon, 29 Oct 2012 17:08:58 +0000 (18:08 +0100)
openvpn/setroute [new file with mode: 0755]
openvpn/start [new file with mode: 0755]

diff --git a/openvpn/setroute b/openvpn/setroute
new file mode 100755 (executable)
index 0000000..26081b8
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+vpnserver="sthu.org"
+
+serverip=$(host ${vpnserver} | awk '{ print $4 }')
+vpnip=$(route -n | grep -m 1 "tun0" | awk '{ print $1 }')
+
+
+defgw=$(route -n | grep -m 1 "^0.0.0.0" | awk '{ print $2 }')
+defif=$(route -n | grep -m 1 "^0.0.0.0" | awk '{ print $8 }')
+echo "current default gw ${defgw} dev ${defif}"
+echo ""
+
+
+echo "add route to ${serverip} via dev ${defif}"
+route add -host $serverip gw ${defgw} dev ${defif}
+echo "remove old default route via gw ${defgw}"
+route del default gw ${defgw}
+echo "add default gw ${vpnip} (vpnip)"
+route add default gw ${vpnip}
+
+echo ""
+echo "Press to restore default route"
+read
+
+
+echo "restore default gw ${defgw} dev ${defif}"
+route add default gw ${defgw} dev ${defif}
+echo "remove default route"
+route del default gw ${vpnip}
+echo "remove route to ${serverip}"
+route del ${serverip} gw ${defgw}
+
+
diff --git a/openvpn/start b/openvpn/start
new file mode 100755 (executable)
index 0000000..9f2975b
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+openvpn --config /etc/openvpn/sthu.org/tun0.conf verb 6