Pragmatism in the real world

Routing specific traffic to the VPN on OS X

I have a client that requires me to use a VPN when connecting to their servers. I use OS X’s built in L2TP VPN to connect, but don’t want all my traffic going that way.

To do this, I unchecked the Advanced VPN setting “Send all traffic over VPN connection” in the Network preferences and then created the file /etc/ppp/ip-up like this:

sudo touch /etc/ppp/ip-up
sudo chmod 755 /etc/ppp/ip-up

The file itself is a bash script that runs various /sbin/route commands and looks similar to this:


/sbin/route add -net -interface ppp0

Now, whenever I connect to the VPN, only traffic for hosts on 192.168.1.x is sent to the client’s VPN and we’re both happy.

One thought on “Routing specific traffic to the VPN on OS X

Comments are closed.