wifi – Route with /etc/hosts on computer to computer network

As stated, it’s pretty difficult to do this. However, if you’re willing to change the goal a little, and use a name ending in “.local” instead of “.com”, it’s trivial (in fact, it’s already being done for you).

Let me start with a little networking theory. I think you’re mixing up two different levels: name resolution and routing.

Name resolution is how network names (like “thisismylaptop.com”) into numeric IP addresses (like or ::1). To simplify a bit, when you put in a name, your computer looks for it in /etc/hosts, and if it finds it it uses that number; if it doesn’t find it, it asks a DNS (Domain Name Service) server to look it up for you.

This is a problem in your scenario, because your computer’s /etc/hosts file applies only to that one computer; the other computer has its own /etc/hosts file, and it doesn’t have your custom entries in it. You could run a DNS server, but then you’d need to find a way to configure all of the computers to use that DNS service, which is a whole other can of worms.

Routing takes place after name resolution; it’s the “ok, I have a numeric address, now where do I actually send the packets (data) to get it there?” phase. And there’s another problem here, because always refers to “this computer right here”. That is, on your first computer, it sends packets to that first computer. On the second computer, it sends packets to the second computer. If you did manage to get all the computers to resolve “thisismylaptop.com” to, every computer would think that it was “thisismylaptop.com”. Instead, you need to figure out what the IP address(es) attached to your computer’s Wi-Fi interface is/are, and use that.

The good news is that wanting to do things like this is common, and so Apple worked out a solution long ago. Apple calls it Bonjour (the rest of the world calls it zeroconf), and it’s been built into Mac OS X since 2002. The main limitation is that it requires names ending in “.local” as a hint to the computers involved that they shouldn’t use a regular DNS lookup, but instead use multicast DNS, which basically consists of yelling over the local network: “Hey, is thisismylaptop.local out there? If so, send me your IP address(es), so we can talk.”

To use it, go open System Preferences on your Mac, select the Sharing preference pane, and look near the top, just below the computer name. It’ll probably say something like “Computers on your local network can access your computer at: nywillbs-MacBook.local”. If you don’t like that name, click Edit to change it (or change the computer name; by default it’s based on that). If your other computer is running macOS, you can just use that name directly. If it’s running Windows, install iTunes on it, and that’ll install Bonjour as well. (There’s supposed to be a way to install just Bonjour without iTunes, but I’m not sure it’s up to date.)

Subscribe to the TAMI Blog Newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *