summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Luttermann Poulsen <llp@nordu.net>2019-02-08 10:03:33 +0100
committerLasse Luttermann Poulsen <llp@nordu.net>2019-02-08 10:03:33 +0100
commit82aaad1b52b53c1bd4108d63e70eeb67a3c7d9e3 (patch)
tree3f36f01ffe44e5f714ee169f22efd424ece9635e
Initial commit
-rwxr-xr-xscripts/ip-up80
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/ip-up b/scripts/ip-up
new file mode 100755
index 0000000..7b367c1
--- /dev/null
+++ b/scripts/ip-up
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# /etc/ppp/ip-up
+#
+# When the ppp link comes up, this script is called with the following
+# parameters
+# $1 the interface name used by pppd (e.g. ppp3)
+# $2 the tty device name
+# $3 the tty device speed
+# $4 the local IP address for the interface
+# $5 the remote IP address
+# $6 the parameter specified by the 'ipparam' option to pppd
+
+# Script found here: https://gist.github.com/blt04/6093918
+# Modified by BSS 2017-09-09 to fit my needs
+
+# Available variables:
+# $SERVER - the VPN server address
+
+#
+function ip_up_post () {
+ case $SERVER in
+ # "NDN MGMT KAS"
+ "dk-kas-mfw.nordu.net" )
+ SERVERNAME="NDN MGMT KAS"
+ ;;
+ # "NDN MGMT UNI"
+ "dk-uni-mfw.nordu.net" )
+ SERVERNAME="NDN MGMT UNI"
+ ;;
+ # "NDN MGMT FRE"
+ "se-fre-mfw.nordu.net" )
+ SERVERNAME="NDN MGMT FRE"
+ ;;
+ # "NORDUnet VPN TUG"
+ 109.105.104.2 )
+ SERVERNAME="NORDUnet VPN TUG"
+ /sbin/route -n add 109.105.96.0/19 -interface $IFNAME # NDN Public
+ /sbin/route -n add 193.10.0.0/15 -interface $IFNAME # NDN Public #2
+ ;;
+ # "NDN MGMT ORE"
+ "dk-ore-mfw.nordu.net" )
+ SERVERNAME="NDN MGMT ORE"
+ ;;
+ # "NDN MGMT TUG"
+ "se-tug-mfw.nordu.net" )
+ SERVERNAME="NDN MGMT TUG"
+ ;;
+ # "NORDUnet VPN Øre"
+ 109.105.99.180 )
+ SERVERNAME="NORDUnet VPN Øre"
+ /sbin/route -n add 109.105.110.128/26 -interface $IFNAME # VMWare Kaltura Jupiter
+ /sbin/route -n add 109.105.112.224/27 -interface $IFNAME # Zoom Project
+ /sbin/route -n add 109.105.113.128/28 -interface $IFNAME # dk-ore-sx-01 DC
+ /sbin/route -n add 109.105.113.144/28 -interface $IFNAME # dk-uni-sx-01 DC
+ /sbin/route -n add 109.105.113.208/28 -interface $IFNAME # SBC
+ /sbin/route -n add 109.105.113.224/27 -interface $IFNAME # VCONF MCU
+ /sbin/route -n add 10.96.0.0/16 -interface $IFNAME # Panopto
+ /sbin/route -n add 185.174.116.0/24 -interface $IFNAME # Zoom servers
+ /sbin/route -n add 185.174.117.0/24 -interface $IFNAME # Zoom servers
+ ;;
+ # "NORDUnet VPN KAS"
+ 109.105.106.4 )
+ SERVERNAME="NORDUnet VPN KAS"
+ /sbin/route -n add 109.105.96.0/19 -interface $IFNAME # NDN Public
+ /sbin/route -n add 193.10.0.0/15 -interface $IFNAME # NDN Public #2
+ ;;
+ esac
+ osascript -e "display dialog \"Created routes for $SERVER ($SERVERNAME) on $IFNAME\" with title \"VPN Info\" buttons {\"OK\"} default button 1"
+}
+
+# Find the current VPN connection and call ip_up_post
+SERVICES=$(echo "list State:/Network/Service/[^/]+/PPP" | /usr/sbin/scutil | /usr/bin/cut -c 16- | /usr/bin/cut -d / -f 1-4)
+for SERVICE in $SERVICES
+do
+ if [ "$(echo show $SERVICE/PPP | /usr/sbin/scutil | grep InterfaceName | /usr/bin/cut -c 19-)" == "$IFNAME" ]; then
+ SERVER=$(echo show $SERVICE/PPP | /usr/sbin/scutil | grep CommRemoteAddress | /usr/bin/cut -c 23-)
+ ip_up_post
+ fi
+done