There are two network interfaces on my Macbook: an ethernet LAN and Wi-Fi, which are both DHCP-configured (albeit separately).

I only need to access a limited number of hosts through my Ethernet network, and want every other request to be routed through Wi-Fi. Those 'Ethernet' hosts can mostly be recognised by their domain mask which is *.foobar.com, but there are also a few exception which domain is different (but they can be identified by their exact IPs).

What would be the best way for me to organise it? I am thinking giving my Wi-Fi the top priority (by dragging it to the top in 'System Settings / Network' list), and then creating a routing rule like this:

route add -host -interface en0

Is that a right approach? If so, what is the equivalent command that I can use to define en0 as a default route by domain mask (*.foobar.com) rather than by exact IP?

  • 1
    You can't set routes based on DNS names. The question you raised about this also opens this up to further clarification...does the target hosts in question obtain their IP via DCHP?
    – Allan
    Sep 26, 2018 at 12:12
  • I don't know that and actually don't want to know. If the only way is to list all the IPs individually I'd rather not do that at all.
    – Yuriy
    Sep 26, 2018 at 12:40
  • 1
    I ask because if the hosts obtain their IPs dynamically, then adding a static route to a specific host will only be good for that lease. If you have two network interfaces on the same network, and you set a priority for one interface with an override for another, and the target hosts change, you will create "confusion" within the routing tables.
    – Allan
    Sep 26, 2018 at 13:02

1 Answer 1


As has been pointed out in the comments, using DNS names for traffic distribution isn't possible (in your scenario). You need to provide local routing as desired and this needs to use IP addresses or subnets.

What you can do is set up the default gateway on the wi-fi NIC or lower the metric for wi-fi - if you want to stick to the all-DHCP setup you'll need to change this on the DHCP server. This takes care of using wi-fi as default network connection.

Then, you set up specific, local routes for the "Ethernet services'" IP addresses that have lower metrics for the Ethernet NIC with route add.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .