Creating a static route through a specific interface My problem involves a High Sierra Mac Pro, a NAS and an old house. Things are like this: Mac Pro and NAS sit close together, and are connected via bonded Ethernet through a switch allowing for ultra-fast transfer speed between the two.

Being in an old house, the switch itself is connected to the main router only via a PowerLine interface. While this actually brings web surfing to the Mac Pro's Ethernet, the truth is that for this purpose only WiFi is way faster (about 10x).

For the sake of this example let's assume the web router is 192.168.0.1, Mac is 192.168.0.2 and NAS is 192.168.0.3; wifi is en2 and ethernet is bond0. I need my Mac to route all traffic through en2, except for traffic directed to 192.168.0.3 which should go through bond0 only.

I tried moving Ethernet on top of service order stack and removing its IPV4 Gateway, but my Mac still keeps connecting to the NAS via WiFi even though Ethernet comes first.

I understand I would need some kind of static route to do this, but after reading a lot of (contradictory) posts I'm still not sure how to exactly accomplish this...

Can someone help me? What sort of code should I type in Terminal to create this static route and make sure it's still there after reboot?

Thank you.
I tried moving Ethernet on top of service order stack and removing its IPV4 Gateway, but my Mac still keeps connecting to the NAS via WiFi even though Ethernet comes first.


Service order priority is great for different networks (i.e. home and work via VPN or work network and lab network).  If you're multi-homing to the same network (WiFi and Ethernet both connect to home), the priority doesn't matter.  Routes are determined by what gets advertised first, the least amount of latency, etc.  As you said, your WiFi is about 10x faster; it makes sense that the traffic will try to go through what it thinks is the fastest.   

Set a static route for the host

You can set a static route for an individual host and ensure that all traffic bound for that host goes through a particular interface (gateway).  The route command takes the following syntax:

% sudo route add -host &lt;target host IP&gt; &lt;IP of network adapter&gt;


So, in your case, using 0.3 as the NAS and 0.55 as your bonded interface, it would be as follows:

% sudo route add -host 192.168.0.3 192.168.0.55


All traffic would be to that one host (NAS) would be routed though the bonded interface while everything else would go through WiFi.

The problem with this is that it's only temporary.  You'll need to rerun this command every time you boot and quite possibly can get overridden (see next section).  To automate it, you'll need to put this into a script (call it setroute.sh for example) and have it executed with launchd.  See the following posts on how to accomplish this:


launchd plist format for running a command at a specific time on a weekday 
How do I run an app using launchd at regular intervals?
How do I create a static permanent ifconfig alias?


Create a different subnet

This is my preferred solution because the NAS will be on it's own network isolated from the rest of the traffic by default.  You won't have to tell it where to go or what traffic to prioritize because it will already know that.  In addition RIP (Route Information Protocol) advertising packets can't override any static routes you may have put in.  Yes, your router can tell your Mac how to get to hosts automatically and this may conflict with what you want. 




WiFi Network -> 192.168.0.0/24   ← 254 hosts max
NAS Network  -> 192.168.5.0/29   ← 6 hosts max


So, on your Mac, you'll have two network connections: 192.168.0.2 (WiFi)
and 192.168.5.2 (Bonded Connection) to the switch (or directly to the NAS).  The NAS, 192.168.5.3,  will have it's connection to the same Ethernet switch that your Mac is connected to.  All traffic destined for the NAS will have no choice but to go through the bonded Ethernet while all other traffic will go via WiFi.