Solved: make sure that libnss-mdns is installed!

I'm having trouble using SSH'ing from my netbook to my desktop using a .local hostname. Every so often, I have to reset the router I use, which resets the addresses it give out to my devices, so a while ago I set up Avahi to get around this*. The /etc/avahi/services/ssh.service file is the standard one copied from the documentation:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<!-- See avahi.service(5) for more information about this configuration file -->
    <name replace-wildcards="yes">%h</name>

This used to work fine, but now for some reason when I try to ssh from my netbook to my desktop, I get the following error message (note I changed my pc's hostname in this output):

user@netbook>> ssh pc.local -vvv
OpenSSH_6.2p2 Ubuntu-6ubuntu0.3, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/username/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
ssh: Could not resolve hostname pc.local: Name or service not known

I can ssh from my netbook to my PC when I put in the IP address manually, and when I've set up /etc/hosts correctly (so the daemon on my PC is working fine), it only stops working when I try to use the .local address. SSH'ing in the other direction (PC->netbook) works fine, even when using a .local hostname. Avahi also appears to be working fine:

user@netbook>> avahi-browse -a -t+  
+  wlan0 IPv6 netbook                                  SSH Remote Terminal       local
+  wlan0 IPv6 netbook [<MAC address>]       Workstation                       local
+  wlan0 IPv6 netbook                                  Remote Disk Management local
+  wlan0 IPv4 netbook                                  SSH Remote Terminal       local
+  wlan0 IPv4 netbook [<MAC address>]       Workstation                       local
+  wlan0 IPv4 netbook                                  Remote Disk Management local
+  wlan0 IPv4 pc                                          SSH Remote Terminal       local
+  wlan0 IPv4 pc [<MAC address>]               Workstation                       local
+  wlan0 IPv4 pc                                          Remote Disk Management local
+  wlan0 IPv6 pc                                          SSH Remote Terminal       local
+  wlan0 IPv6 pc [<MAC address>]               Workstation                      local
+  wlan0 IPv6 pc                                          Remote Disk Management local

The netbook is running Lubuntu 13.10; note that I did change to Lubuntu recently, and I only recall seeing this error with Lubuntu and not with plain Ubuntu. My desktop is running Ubuntu 13.10.

Any help would be appreciated!

*I am aware that can set up my router to permanently give set addresses to both devices, and I will do that if I can't resolve this issue, but I'd prefer to try and fix this rather than work around it.

ETA: Pinging the PC from the netbook with the .local hostname doesn't work (unknown host) .

Edit 2: Contents of /etc/nsswitch.conf

# /etc/nsswitch.conf
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd:         compat
group:          compat
shadow:         compat
hosts:          files mdns4_minimal dns [NOTFOUND=return] mdns4
networks:       files
protocols:      db files
services:       db files
ethers:         db files
rpc:            db files
netgroup:       nis
  • I haven't used DHCP nor Avahi for a while now, but can't you simply ssh user@hostname:/folder?
    – Alex
    May 4, 2014 at 4:22
  • Did ping test pass ping pc.local?
    – user.dz
    May 4, 2014 at 5:31
  • 1
    @Alex: Ideally that's what I'd like to do, but as I pointed out in the post every so often I have to reset the router, which resets the addresses it gives out, which mean's I'd be changing /etc/hosts files regularly, which is why I set up Avahi. May 4, 2014 at 7:46
  • 1
    @Sneetsher: Just tried it, and it doesn't: "ping: unknown host pc.local." May 4, 2014 at 7:49
  • Running strace ssh user@foo will also show that ssh contacts avahi-daemon with the request to resolve foo, which times out... In my case changed in /etc/nsswitch.conf: From "hosts: files mdns4_minimal [NOTFOUND=return] dns" to "hosts: files dns mdns4_minimal". Not sure why avahi daemon is supposed to NOT ask DNS servers, it may have to do something with the incompatibility between multicast DNS and DNS both on the LAN (see also: .local TLD ... having .local is bad practice anyway) Nov 23, 2017 at 13:12

1 Answer 1


Well, *.local are not resolved.

So on Client machine (Notebook)

  1. Install avahi-dnsconfd

    sudo apt-get install avahi-daemon avahi-dnsconfd avahi-discover avahi-utils

    avahi-dnsconfd listens to the publishing and passes them to resolvconf.

  2. Install libnss-mdns (This library was missing, Installing it fixed the problem in this case)

    sudo apt-get install libnss-mdns

    nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) providing host name resolution via Multicast DNS (using Zeroconf, aka Apple Bonjour / Apple Rendezvous ), effectively allowing name resolution by common Unix/Linux programs in the ad-hoc mDNS domain .local

  3. Check /etc/nsswitch.conf

    hosts:     files wins mdns4_minimal dns [NOTFOUND=return] mdns4

    It should have mdns4_minimal or mdns4 before [NOTFOUND=return] and before dns if you have a DNS server that configured resolve *.local.

    Remove wins if you are not using winbind/samba to resolve Windows share hostnames.

  4. Reboot

Debuging hints:

  • Client machine (Notebook)

    1. Check avahi-dnsconfd service status

      $ service avahi-dnsconfd status
      avahi-dnsconfd start/running, process 1548
    2. Run avahi-discover, Your desktop should be listed in IPv4→local→Workstation

      Example in screenshot mx5 is my PC where salah-Aspire-5738 is an other machine.

      enter image description here

    3. See if Avahi can resolve host names

      avahi-resolve -4 --name yourdesktop.local
    4. Ping test

      $ ping salah-Aspire-5738.local
      PING salah-Aspire-5738.local ( 56(84) bytes of data.
      64 bytes from salah-Aspire-5738.local ( icmp_seq=1 ttl=64 time=2.69 ms
  • Server machine (Desktop), In case avahi-discover in Client machine did not list Server entry.

    1. Confirm that avahi-daemon is installed

      sudo apt-get install avahi-daemon avahi-dnsconfd avahi-discover avahi-utils

      avahi-daemon provide services publishing.

    2. Check its service status

      $ service avahi-daemon status
      avahi-daemon start/running, process 1517
    3. By default avahi publish _workstation._tcp service. check using avahi-discover locally, if not listed try enabling it in /etc/avahi/avahi-daemon.conf (remove #)


      Then restart daemon:

      sudo service avahi-daemon restart

      Check again.

  • No luck unfortunately. avahi-discover and avahi-dnsconfd were not installed on my netbook or PC, so I installed them on both. I also edited /etc/nsswitch to look like the sample you provided (previously the only entries were files and dns) but both ping and avahi still give the same error. Any more advice? May 4, 2014 at 12:26
  • Arrgh, this is extremely perplexing. May 5, 2014 at 11:02
  • Removing wins did not help. avahi-dnsconf is running on the netbook (though I had to use sudo service avahi-dnsconfd to list it, otherwise service would respond with unknown job). avahi-discover (when run on my netbook) does list the desktop (and correctly), both under the Workstation heading and the ssh heading. Yet I still cannot ping or ssh into the pc using .local hostnames. I checked the daemon on the desktop anyway, and avahi-daemon is running. Any ideas? (btw, thanks for all your advice, I appreciate it) May 5, 2014 at 11:10
  • 1
    Wasn't installed. Installed it, and it worked!!!!!!!!! Thank you so much for your help! Maybe add that to your post so others can see it a bit easier? May 13, 2014 at 11:55
  • 1
    @user.dz Thank you for this! My problem was right at the end with "not publishing the workstation". I was frustrated and confused because I could see the hostname show up from the client side when running avahi-discover, but SSH wouldn't find or connect to it. Looks like I needed to publish a workstation service!
    – aardvarkk
    Dec 21, 2021 at 6:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .