Mac OSX Route Mapping: Use LAN for specific Server and Wifi for other

When working with internal services through LAN, we have some problem that we cannot connect to the outside world which we normally connect by Wifi.

Scenario — Expect Result

When going to internal server e.g. the ip 10.200.10.20 use LAN

en0 Wifi
en5 LAN

Removing LAN default Gateway

Open System Preference > Network

  1. Remove the default gateway in Green

Adding gateway

sudo route -n add -host <target_host_ip> <gateway_ip>// Example
sudo route -n add -host 10.200.10.20 10.175.30.40

Add interface

sudo route add -host 10.200.10.20 -interface en5

Seeing route

OSX version of route miss the command to see route.

netstat -nr
...
10.200.10.20 10.175.30.40 UGHS en5
...
default            172.24.200.1       UGSc           en0

Bonus

For those with ip range, we can avoid tedious one by one adding with CIDR block range /16 , /24 etc.

sudo route -n add -net 172.16.0.0/16 192.168.1.49