OSX PPTP: Only route VPN traffic to VPN

So my new macbook air ‘out of the box’ wasn’t able to connect to one of my data centres which requires connection via PPTP VPN.

This was very annoying, as a mobile solution for accessing the network was the macbook Air’s primary job in life.  Few googles later I found the solution.  The OSX vpn client doesn’t automatically create the relevant routes.  There is an option to push all traffic through the VPN, or none.  What if you just want to push relevant traffic to the VPN? ie. to access intranet or internal VPN services?

The steps I took:

  1. Create the VPN connection as per normal.
  2. Leave the ‘route all traffic’ Unchecked.  Ensure the VPN connection comes up.
  3. Work out what subnets you need to route to.  For me it was 172.1.1.0/24 – as the server I needed to connect to had the internal IP of 172.1.1.20
  4. Open up terminal
  5. Type ifconfig and verify there is a ppp0 connection. (This is the VPN).
  6. type ‘sudo nano /etc/ppp/ip-up’
  7. Paste in: #!/bin/sh # /etc/ppp/ip-up route add 172.1.1.0/24 $IPREMOTE

You will need to adjust the 172.1.1.0/24 to suit the subnet you want to connect to.
8. Press Ctrl + X, choose yes.
9. type ‘sudo chmod +x /etc/ppp/ip-up’
10. Disconnect and reconnect your VPN and try ping a server on your network.

Good luck and let me know if you have any problems following my instructions.