Avahi mDNS and link-local addressing


My local network consists of a workstation, a server, and a bunch of other devices, all using avahi for mDNS advertising. I’d like to get a faster than gigabit connection between the workstation and server, and that’s an expensive prospect. I’ve been tinkering with a direct 10G ethernet link between the 2, no switch, since I’d need 10G cards anyway. When I configured the network as link-local on both boxes, everything worked fine. Avahi picked up the new link-local addresses and advertised the mDNS name on each. When a machine resolved the other’s hostname.local address, it always returned the link-local address. Is this incidental, intentional, or configurable, this apparent prioritization of link-local connections in DNS resolution? If this behavior could be relied on it’d greatly simplify some other scripting and configuration.


Hi @anti, welcome to the community. :slightly_smiling_face:

If you set one of the _minimal modules in /etc/nsswitch.conf, Avahi will only resolve host names that end in .local or are in the range 169.254.x.x. It’s pretty easy to set up, check it out:


Hostname resolution

Avahi provides local hostname resolution using a “hostname.local” naming scheme. To enable it, install the nss-mdns package and start/enable avahi-daemon.service.

Then, edit the file /etc/nsswitch.conf and change the hosts line to include mdns_minimal [NOTFOUND=return] before resolve and dns:

hosts: mymachines **mdns_minimal [NOTFOUND=return]** resolve [!UNAVAIL=return] files myhostname dns


  • If you experience slowdowns in resolving .local hosts (or you do not want to use IPv6) try to use mdns4_minimal and mdns4 instead of mdns_minimal and mdns respectively.
  • The line above makes nss-mdns authoritative for the .local domain, unless your unicast DNS server responds to SOA queries for the top level local name, or if the request has more than two labels. See nss-mdns activation notes.

They have more options for the _minimal modules if you want to get fancy with it. You can combine the _minimal and the normal NSS modules if you want to make mDNS authoritative for Zeroconf host names, to use as a fallback or to take the curse off the DNS servers by not hitting them with all the failing requests. You can read more about that in their documentation: https://github.com/lathiat/nss-mdns/blob/master/README.md#documentation