Run a script when the VPN connection is connected

Wikis > Informatique > MacOSX > VPN > Run a script when the VPN connection is connected

When pppd establish the connection, the process will call /etc/ppp/ip-up with the following arguments:

ip-up
interface-name
tty-device speed
local-IP-address
remote-IP-address
ipparam

So you can for example add route:
/etc/ppp/if-up

#!/bin/bash
IFNAME="${1}"
/sbin/route add 192.168.1.0/24 -interface ${IFNAME}