MacOS – Selectively route VPN traffic – how to determine subnet value

macosNetworkvpn

I'm trying to route just specific traffic (a specific domain) on my Mac over my company VPN. This seems to be the most recommended way to do it,

Create the file /etc/ppp/ip-up with following content:

#!/bin/sh /sbin/route add SUBNET $5 replacing SUBNET with subnet, you want to route through VPN (for ex. 192.168.0.0/16)

execute as root:

chmod 0755 /etc/ppp/ip-up This file will be executed each time you connect to VPN.

…but I don't understand how to determine the SUBNET value. Do I need to create a subnet? Is the subnet name for the VPN in network preferences somewhere? I really don't have a good idea of what a subnet even is, so I'm not following how to implement the solution above.

Best Answer

You don't need to create a new subnet, you just need to figure out what subnet (or subnets) your company's network uses. For example, if the IP addresses on your company's network are in the ranges 10.0.0.1 to 10.0.0.255, then you can use the subnet mask "10.0.0.0/24". If the range is 10.0.0.1 to 10.0.255.255, then you can use the broader range "10.0.0.0/16". You can search for "subnet calculator" to find some tools that can help you figure out the notation for the subnet range you want to capture.

Make sure your local network doesn't overlap with the range, though. Your home network should use a different subnet (like 192.168.0.0/24 for example) that won't conflict with your office's network.