Route specific traffic to VPN OSX

Let’s assume you are on the road, you need to connect to services that are only available via your companies IP address or static VPN tunnel. A VPN server is running at your company where you can connect to and by default only the IP subnet that you got assigned via DHCP will be routed through your VPN tunnel.

In my case it is a vpn tunnel using ppp0 as interface and I need to connect to an external service that is only reachable from the company.

Edit or add

, this file gets executed once VPN tunnel is active.

If you want to route based on an url / domain name, I have enhanced this script with dns resolution and support for cdns (round robin domains with multiple IPs).