Permanently Adding IP Route To Mac OSX VPN Connection

I’m annoyed, each time I connect to my office VPN I have to manually add an IP route so certain IP group is resolvable. Here’s how you can make the change permanent:

Add the route command to /etc/ppp/ip-up. This file gets executed each time VPN connection is activated.

#File: /etc/ppp/ip-up
#!/bin/sh
/sbin/route add 192.168.16.0/24 $5

In the above configuration I routed any IP starting with 192.168.16 to the newly established VPN connection (denoted by $5 variable).

You can check your IP routing table by using netstat -rn

Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default                 UGSc           36        0    ppp0
default            192.168.1.1        UGScI          14        0     en0
25                 link#8             UC              1        0    ham0
25.84.162.40       7a:79:19:51:a5:3c  UHLWIi          1        1     lo0
127                127.0.0.1          UCS             0        0     lo0
127.0.0.1          127.0.0.1          UH              1   143939     lo0
169.254            link#4             UCS             0        0     en0
192.168.1          link#4             UCS             4        0     en0
192.168.1.1        0:60:64:91:be:65   UHLWIir        18      618     en0   1183
192.168.1.2        127.0.0.1          UHS             0        0     lo0
192.168.1.5        0:23:ae:a:c9:63    UHLWI           0       21     en0   1016
192.168.1.8        1c:1a:c0:6f:b7:6a  UHLWI           0        0     en0   1139
192.168.1.9        1c:1a:c0:6f:b7:6b  UHLWI           0        0     en0   1140
192.168.16              UGSc            1        0    ppp0
192.168.18         ppp0               USc             0        0    ppp0
          UHr            40       16    ppp0
     192.168.1.1        UGHS            1      376     en0

Leave a Reply