Ubuntu – Avahi name resolution not respected for subdomains in 19.04

19.04avahidnsmdns

This seems to be a behavior difference which only started in either 18.10 or 19.04.

While avahi-resolve --name my.subdomain.local returns a valid IP address and is working it doesn't work outside of that, i.e. ping, curl or chrome.

The name resolution does still work though for subdomain.local. This seems to be related to the fact that *.subdomain.local is resolved as mDNS CNAME.

Content of nsswitch.conf

passwd:         compat systemd
group:          compat systemd
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

Content of /etc/resolv.conf

nameserver 127.0.0.53
options edns0

Best Answer

  • There are many ways to set up DNS, but with the standard Ubuntu install using systemd I find that intermittent failures occur unless I also install the libnss-resolve package. The only thing this package does is to alter the "hosts" line in the /etc/nsswitch.conf file -- adding in "resolve [!UNAVAIL=return]" before the dns entry. e.g.

    hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns myhostname  
    

    See bugs 1727237 systemd-resolved is not finding a domain, 1805027 systemd-resolved can't resolve Comcast mail server addresses, and 1804487 systemd-resolved has issues when the answer is over 512 bytes with EDNS disabled

    What makes these name resolution failures hard to track down is that they occur only under certain conditions, when a fallback to UDB has a limit of 512 bytes for results. How this problems relates to the nsswitch.conf hosts line is even harder to figure out, but the suggestion of adding the libnss-resolve package was mentioned in the bugs, and it fixed all my occasional problems.

    This "fix" would be applied to the discovering machine(s), but no longer works in Ubuntu 20.04. short names are no longer resolved regardless of the installation of libnss-resolve unless passed directly to the router in dig. On the bright side, I see no more name resolution errors without the libnss-resolve package (which is not installed by default).

  • Related Question