Created
September 23, 2021 15:43
-
-
Save philayres/2325f4b03afd78ec13a6969df7d710af to your computer and use it in GitHub Desktop.
On a Mac, set a route after connecting to a SoftEther VPN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set up a route to the be used when logged into | |
# AWS SoftEther VPN | |
# VPN IP addresses should be in the 192.168.99 subnet after connection is made. | |
# The gateway for the route is usually set to the address received via DHCP. | |
# On Mac OSX the route sent by DHCP is ignored and must be set manually | |
echo "Setting up routing for AWS VPN interface....." | |
INTFC=$(/sbin/ifconfig | grep ppp | awk -F: '{print $1}') | |
if [ -z $INTFC ]; then | |
echo "No ppp interface found. Check VPN connection" | |
exit 1 | |
else | |
echo "VPN interface is $INTFC ....." | |
fi | |
GW=$(/sbin/ifconfig | grep 192.168.99 | awk '{print $2}') | |
if [ -z $GW ]; then | |
echo "No IP address found for 192.168.99 network. Check VPN connection." | |
exit 1 | |
else | |
echo "VPN IP address is $GW" | |
/sbin/route -n add -net 172.31.0.0/16 $GW | |
fi | |
echo "" | |
if netstat -rn | grep 172.31; then | |
echo "ROUTE ADDED for AWS network" | |
else | |
echo "ERROR adding route for AWS. Consult system administrator." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment