Wednesday, July 20, 2016

OS X - add routes on VPN up

OS X VPN rather than routing all traffic down the VPN to get to extra subnets add routes when the link comes up.

Make the file that get called on ppp up. i.e. /etc/ppp/ip-up and make it executable.

Use the remote router to select options to run. (It shows under ifconfig as the other end of the point to point interface.)

Example: when link to 192.168.2.0/24 via 192.168.2.1 comes up add a route to 192.168.3.0/24 via it.

/etc/ppp/ip-up

#!/bin/bash

IFNAME="${1}"
LOCALIP="${4}"
REMOTEIP="${5}"

if [[ "${REMOTEIP}" == "192.168.2.1" ]]; then
  /sbin/route add -net 192.168.3.0/24 -interface "${IFNAME}"
fi

No comments:

Post a Comment