5

Resolving .local hostnames has become slow since updated from 18.04 to 20.04. Things as simple as:

ping flibble.local

work immediately in 18.04, but take about 5 seconds or so in 20.04, after which it behaves normally. However, it still takes another 5 seconds when run again.

I haven't customized anything since updating. If it matters, Ubuntu is running as a VM in Parallels. I can provide details as necessary.

My /etc/nsswitch.conf file contains the usual:

hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname

I've tried searching for solutions to this problem, but nothing so far has fixed it.

systemctl status systemd-resolved.service output:

● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-10-05 09:55:47 PDT; 10min ago
       Docs: man:systemd-resolved.service(8)
             https://www.freedesktop.org/wiki/Software/systemd/resolved
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 592 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 7061)
     Memory: 9.4M
     CGroup: /system.slice/systemd-resolved.service
             └─592 /lib/systemd/systemd-resolved

Oct 05 09:55:47 invasion-ubuntu20 systemd[1]: Starting Network Name Resolution... Oct 05 09:55:47 invasion-ubuntu20 systemd-resolved[592]: Positive Trust Anchors: Oct 05 09:55:47 invasion-ubuntu20 systemd-resolved[592]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d Oct 05 09:55:47 invasion-ubuntu20 systemd-resolved[592]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.> Oct 05 09:55:47 invasion-ubuntu20 systemd-resolved[592]: Using system hostname 'invasion-ubuntu20'. Oct 05 09:55:47 invasion-ubuntu20 systemd[1]: Started Network Name Resolution. Oct 05 09:55:47 invasion-ubuntu20 systemd-resolved[592]: Using degraded feature set (UDP) for DNS server 192.168.6.1.

Bill Barton
  • 141
  • 1
  • 5

2 Answers2

9

Looks like the solution might not depend on nss-mdns at all. I was unfamiliar with systemd-resolved, which appears to have mdns resolution capability. It appears to outperform nss-mdns. However, mdns in systemd-resolved appears to be off by default. Here's how I activated it and deactivated nss-mdns.

  1. Change /etc/nsswitch.conf:

    hosts:          files dns myhostname
    
  2. Edit /etc/systemd/resolved.conf:

    MulticastDNS=yes
    
  3. Create a new /etc/NetworkManager/conf.d/mdns.conf containing:

    [connection]
    connection.mdns=2
    
  4. Restart NetworkManager:

    sudo service NetworkManager restart
    
  5. Might also need to restart systemd-resolved:

    sudo service systemd-resolved restart
    

Test results with:

resolvectl mdns

When it's working, you should get:

Global: yes
Link 2 (enp0s5): yes

Now:

time ping -c1 invasion.local

completes in under 150ms.

Bill Barton
  • 141
  • 1
  • 5
1

In addition to Bill Barton's excellent answer which helped me quite a bit, I also had to disable IPV6 in my configuration. Machines that had IPv6 enabled would still resolve quickly. If I tried to ping a machine that didn't have IPv6 enabled, like my Nas4Free server, it would take around 5~10 seconds before the ping would start responding. NSLookup was the same.

I followed the instructions on How to disable IPv6 address on Ubuntu 20.04 LTS Focal Fossa - LinuxConfig.org to disable IPv6 on my Ubuntu 20.04 machine.

Kulfy
  • 18,154
mcmoyer
  • 41