How to add route on Mac

Let’s assume the IP is only accessible through the VPN, 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


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


sudo route add -net gw

Where /16 is the 16 bit mask:

8 bit mask =
16 bit mask =
24 bit mask =
32 bit mask =

To check if the routing is in place:

route -n get

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.