Automatically create routes in OS X using VPN

Very annoyed in OS X, that after the establishment of VPN-connections, you had to manually are forwarding some subnets inside VPN. After a while it got tired and was written a little script that is executed automatically immediately after the VPN-connection is established.

$ sudo nano -w /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. ppp0)
#	$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


if [ "${IPREMOTE}" == "" ]; then
    /sbin/route add -net 10.1 -interface ${IFNAME}
    /sbin/route add -net 10.2 -interface ${IFNAME}
    /sbin/route add -net 10.9 -interface ${IFNAME}
    /sbin/route add -host -interface ${IFNAME}

$ sudo chmod +x /etc/ppp/ip-up

Leave a Reply