Score:0

How can I control which interface host.local resolves to?

cn flag

I've got a server on my network (we'll called the host name server) and I can access the machine on the LAN using the host name server.local which resolves to its local address (let's call it 192.168.1.50). Most devices talk to this machine via WiFi, but for added performance I recently connected another machine directly to it via an Ethernet cable. The server's IP address on this interface is 10.0.0.1, and on the machine that connects to it (client1) it's 10.0.0.2. I noticed after a while I could ping server.local from client1 and it was resolving server.local as 10.0.0.1 instead of 192.168.1.50.

This is great because this means that I don't have to explicitly specify the IP address (this is good for web pages forget their state when the IP address changes), but periodically I see slow performance and when I ping server.local I see it has switched back to 192.168.1.50. After a while it goes back to 10.0.0.1 again.

How can I pin server.local to resolving to the ethernet interface's IP address, at least for the connected machine? It's fine for now if it has to resolve to the same thing for all machines on the network, as currently the directly connected one is the only one using it.

ru flag
That's a DNS issue related to what resolves `server.local` for each client- if your system resides on both networks, then it's however the Router serves to the rest of the network the lookups for `server.local`. Generally speaking, there's no way for you to *pin* the result on client systems except by hardcoding them in the hosts files of those respective clients.
Score:1
it flag

The .local domain is resolved (translated to an IP address) by dnsmasq (see man dnsmasq systemd-dnsmasq), and "local" has different meanings on different systems.

Rather than try to trick .local, simply add the hostnames and IP addresses to /etc/hosts:

sudoedit /etc/hosts
servereth   10.0.0.1
serverwifi  192.168.1.50

Read man sudoedit hosts.

The connection of IP addresses with actual interface names is done via "packet routing", see man ip ip-route, do ip route, and bear in mind that almost all packets use the "default" route.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.