How to add route on Mac

Let’s assume the IP 10.67.0.0 is only accessible through the VPN 192.168.120.254, then you can use route command to access your destination IP through the Gataway.

To view you route table on you Mac you use the following command:

netstat -rnf inet
route -n get default

Add a static route to your machine

Mac:

route add -net <IP> <GW IP>

where ‘IP’ is the ip you need to reach (and probably searched with a ping) and GW IP is the ip from the VPN.

sudo route -n add -net 10.67.0.0/16 192.168.120.254

Linux:

sudo route add -net 10.67.0.0/16 gw 192.168.120.254

Where /16 is the 16 bit mask:

8 bit mask =  255.0.0.0
16 bit mask = 255.255.0.0
24 bit mask = 255.255.255.0
32 bit mask = 255.255.255.255

To check if the routing is in place:

route -n get www.google.com

To delete a route you have to use the following command:

sudo route -n delete x.x.x.x/24 x.x.x.x

If something is wrong, the reason could be anyone of those:
– the address that the VPN provides isn’t actually allowed to access the target on port 22
– the route command is wrong; it doesn’t get the traffic on the right port (on your end)
– the VPN doesn’t allow it

all of these steps are basically needed to diagnose where the packets are lost.