Multiple default routes on MacOS I noticed that both WiFi and ethernet are enabled simultaneously on my MacOS machine, so I was curious about how routing would work. I see the following:

myprompt$ netstat -rn

Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.1.254      UGSc          173        0     en8       
default            192.168.1.254      UGScI           2        0     en0       
default            link#21            UCSI            0        0   utun2  
...


Using ifconfig, I can see that en8 is the 100baseTX ethernet port, and I guess en0 is WiFi. I guess utun2 is my VPN connection.

For any IP address destination that is not in the routing table, which default route would be selected? Is it a random selection? Or is there some other table or something else that I could inspect to figure that out?

This machine is on macOS Mojave version 10.14.5
macOS chooses which of those default routes to use based on the service order. You can set the order by opening System Preferences, select Network and then click the gear icon below the interface list to select Set Service Order. Drag and drop the interfaces to prioritize.

As you're working with the Terminal, this information is also available there by running:

networksetup -listnetworkserviceorder


This will show you the prioritized list. You can change the order by running:

networksetup -ordernetworkservices &lt;service1&gt; &lt;service2&gt; &lt;...&gt;


Note that this determines the route chosen only for connections initiated from your computer. If a connection is initiated by another device, the interface that it is initiated from will be used for that connection.

I.e. for example you have both an Ethernet and WiFi connection to another computer. You could set your service order so that you prefer connections to be made over WiFi. But if the other computer initiates the connection over Ethernet, then packets you send later on that connection will be sent over Ethernet.