Avahi isn't being used to resolve .local domain names

Hello, I’m new to Fedora (but not to Linux in general) and in general I like it a lot. This one problem has me stumped though. mDNS name hostname resolution isn’t working. Avahi is able to resolve the hostname when I use avahi-resolve-host-name, but getent hosts doesn’t resolve it. For example, with an mDNS-enabled printer:

[mtrescott@R8501300 ~]$ avahi-resolve-host-name xpress-c1860fw.local
[mtrescott@R8501300 ~]$ getent hosts xpress-c1860fw.local
[mtrescott@R8501300 ~]$ echo $?

I’m not sure what’s wrong here since Avahi seems to be working fine on its own. Here’s what I’ve tried:

  • Checking firewall configuration: mDNS is allowed (and anyway, Avahi works on its own)
  • Adding to NetworkManager’s additional DNS servers for my connection config. (this adds a nameserver line to /etc/resolv.conf.
  • Adding an /etc/mdns.allow file with the default settings to allow .local domains.
  • Switching Avahi to use .alocal instead of .local in /etc/avahi/avahi-daemon.conf in case the router’s DNS server handles the .local TLD already.

I don’t think my configuration is out of the ordinary anywhere else. I installed Fedora using the minimal install media and then gradually installed the packages that I want/need. Here’s some configuration lines that might be relevent:

hosts line from /etc/nsswitch.conf:
hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname

Contents of /etc/resolv.conf:

# Generated by NetworkManager
search attlocal.net
nameserver 2600:1702:5a0:82f0::1

If anyone can help me on this, thank you in advance!

Just for your information. I don’t have avahi installed, but executing getent hosts xpress-c1860fw.local followed by echo $? returns the same number 2. However, if I do the same for a host I know exists, i get the entries for that host from getent.

Are you sure it is not just a problem with the xpress host?

P.S. I may be a longtime fedora user, but I never used avahi and I am certainly not server knowledgeable. Hope you can forgive if this is a newby query xD.

Yeah, I’m sure it must be something wrong with my Fedora configuration because when I use getent hosts the resolution should be routed through Avahi via the mdns4_minimal NSSwitch module.

If your had started with the minimal install media, maybe then your setup is having a systemd-resolved running instead of the avahi-daemon.service?

Arch Wiki:
Note: systemd-resolved has a built-in multicast DNS service, make sure to disable systemd-resolved’s mDNS resolver and responder or disable systemd-resolved.service entirely before using Avahi. For details, refer to resolved.conf(5).

Oh yeah, I forgot to mention that I checked that too—thanks for the suggestion though. systemd-resolved isn’t running:

● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-resolved.service(8)

man avahi-daemon:
If you enable publish-resolv-conf-dns-servers in avahi-daemon.conf the file /etc/resolv.conf will be read, too.


:flying_saucer: !? SELinux? Are your have a “Permission denied” entries inside of the system logs?

I tried uncommenting publish-resolv-conf-dns-servers=yes in avahi-daemon.conf and restarting Avahi, but it didn’t change anything. And there aren’t any relevant errors when I do journalctl --boot | grep denied

I wish I know how to debug something like this with GDB or something.

If i’m understand correct, your will need an debug build of the program your wish to debug. With the symbols and the such not stripped (not dev myself).

PS: Maybe your try to (i’ve limited traffic myself) install the Workstation variant? :flying_saucer: Of course, your potentially will have less fun…

By trial and error, I finally figured it out! (Kinda—I have no idea why this works and the default config doesn’t)

I created the file /etc/mdns.allow with the following contents:


(I added a trailing empty line to this file but it didn’t make any difference in my tests.)

Then I switched to using the regular mdns4 or mdns module instead of mdns4_minimal in /etc/nsswitch.conf, and it worked! Apparently this was a combination I didn’t try before.

My hosts line now looks like:

hosts:      files mdns4 [NOTFOUND=return] dns myhostname

And I get the output I expect for the network printer:

$ getent hosts xpress-c1860fw.local    xpress-c1860fw.local

Side note 1: What helped me figure this out was the --service parameter for the getent command. By using getent --service=mdns hosts xpress-c1860fw I was able to bypass the sequence of services specified in /etc/nsswitch.conf and isolate the problem to the mdns4_minimal NSS service. The red flag was the fact that getent would return immediately, so I know that there was no network activity going on. Apparently mdns4_minimal is broken.

Side note 2: I really don’t understand why mdns4_minimal doesn’t work. It ought to. Maybe this deserves a bug report?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.