I want to add IP routes for host that I do not have the IP address for. I basically want tell macOS to search for a host in a specific interface:

sudo route add -host <myHostname> -iface en7

Background: I have set up WiFi to be my primary network interface. But I want to be able to access host that are only available in the wired network with the interface en7. Therefore I wanted to add such a route to the system.

The command above results in the error: route: bad address: myHostname

Any ideas?


You can't do this; this is not the way IP routing works.

DNS is name resolution. It's nothing more than an address book of names pointing to some numbers (IPs)

myhost.com --------> 111.222.333.444

DNS tells you what the address is, not how to get there. IP routing is the mechanism of how you get from one point to the next. It's the same difference between "Contacts" and "Maps" in your iPhone.

I basically want tell macOS to search for a host in a specific interface:

You can't tell an interface what "hosts" (names) are there. You tell it what networks are accessible. Networks are defined by IP address(es).

For instance:

  • en0 has an IP of and is on the network
  • en1 has an IP of and is is on the network
  • A subnetwork, is attached (via switch) on the network


Now, you add a host called foo.bar in DNS and it has an IP address of Your system will know to go through interface en1 to get to it.

If another host, called foobar.foo had an IP address of, again, it would know to go through en1 because that route would be defined.

To accomplish what you're looking to do, your host has to be able to get name resolution across two separate domains (not interfaces). You can accomplish this two ways:

  • Some details of the answer are wrong: 1. the IP-address 111.222.333.444 ;-). 2. is no subnetwork of A route from the second to the first doesn't really exist. Proper networks would be (all include
    – klanomath
    Oct 31 '19 at 13:50

this is quite late response, but I just did what you've asked and it works for me.

I'm using VPN connection to get access to my office which is running on ppp0 interface. I've run below and now I can access hostnames which are only available via vpn, without setting up option to send all traffic through VPN.

/sbin/route add -host -interface


To the best of my knowledge setting a default next hop or interface for hostnames instead of IP addresses isn't possible.

Is there a reason you aren't creating a route pointing to the next hop or interface for the wired accessible subnet(s) instead?

You must log in to answer this question.

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