Systemd-resolved can't resolve mDNS .local names, Avahi can

I’m running NixOS 24.11 as a VM guest within a Fedora host, using a bridged network interface (no virtual NAT). Some relevant NixOS config:

networking.networkmanager.enable = true;
services.avahi.enable = false;
services.resolved.enable = true;

mDNS is reported as enabled for systemd-resolved and for the network interface:

$ resolvectl status
Global
           Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: stub
Fallback DNS Servers: [...]

Link 2 (enp1s0)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6 mDNS/IPv4 mDNS/IPv6
         Protocols: +DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: [...]
       DNS Servers: [...]
        DNS Domain: home

But when I try to query another local machine by its hostname, the request times out after a few seconds of waiting:

$ resolvectl query foo.local
foo.local: resolve call failed: All attempts to contact name servers or networks failed

I can ping the host by its IPv4 and IPV6 address just fine, and the name can also be resolved on the host system.

If I switch my configuration to enable Avahi and disable systemd-resolved, then I can resolve the name just fine with avahi-resolve -n foo.local. So mDNS queries can get out of the VM guest and work properly, it’s just systemd-resolved that’s having trouble.

Any idea why Avahi’s mDNS works, but systemd-resolved’s doesn’t?

systemd-resolved doesn’t have multicast DNS enabled by default. You have to add MulticastDNS=yes to services.resolved.extraConfig, but even this isn’t enough. You still have to make your network manager enable mDNS on the actual interface. I think this command might do the trick?

nmcli connection modify "Wired connection 1" connection.mdns yes

Or if you use systemd-networkd, you can use

systemd.network.networks.<name>.networkConfig.MulticastDNS = true;
1 Like

If I’m interpreting resolvectl status as posted above correctly, mDNS should be available globally and for the interface already? Or is this setting still needed?

EDIT: I tried it anyway and nothing changed.