Fixing the routing table when using the University of Melbourne VPN

After connecting to the university of melbourne VPN using the built in Mac OS X VPN facilities. You will find you can no longer connect to the internet, only to university servers. Using the university proxy server helps with access to web sites, but everything else is still blocked.

This problem can be solved by altering your routing table after starting up the VPN. The following shell script will guess which interface is the VPN interface and then fix the routing table.

#!/bin/sh

UTUN=`netstat -rn | perl -lane 'print $F[1]' | grep utun[0-9] | sort -u`
echo VPN appears to be using address $UTUN

sudo route add 128.250.0.0/16 -interface $UTUN
sudo route add 172.22.0.0/16 -interface $UTUN
sudo route delete default -interface $UTUN
sudo route add default -interface en1

It is interface is usually utun0 and en1 is usually the name of your local physical interface. If you are having problems you can find out the correct interface names by inspectin the output of the following command:

ifconfig

vpn