15

I installed Avahi with libnss-mdns to be able to access my pi by hostname. Relevant info:

$ cat /etc/hostname
raspberrypi

$ ps ax | grep avahi
2103 ?        S      0:00 avahi-daemon: running [raspberrypi.local]
2104 ?        S      0:00 avahi-daemon: chroot helper

$ sudo service avahi-daemon status
Avahi mDNS/DNS-SD Daemon is running

ls -l /etc/avahi/services/
total 8
-rw-r--r-- 1 root root 449 Jul 31 13:16 multiple.service
-rw-r--r-- 1 root root 299 Mar 10 17:15 udisks.service

And on the pi itself it is working:

$ avahi-browse -a
+   eth0 IPv4 XBMC (raspberrypi)                            _airplay._tcp        local
+   eth0 IPv4 B827EBA83303@XBMC (raspberrypi)               AirTunes Remote Audio local
+   eth0 IPv4 XBMC (raspberrypi)                            _xbmc-jsonrpc._tcp   local
+   eth0 IPv4 XBMC (raspberrypi)                            _xbmc-events._udp    local
+   eth0 IPv4 XBMC (raspberrypi)                            _xbmc-jsonrpc-h._tcp local
+   eth0 IPv4 XBMC (raspberrypi)                            Web Site             local
+   eth0 IPv4 raspberrypi                                   Remote Disk Management local
+   eth0 IPv4 raspberrypi                                   _device-info._tcp    local
+   eth0 IPv4 raspberrypi                                   SSH Remote Terminal  local
+   eth0 IPv4 raspberrypi [b8:27:eb:a8:33:03]               Workstation          local

Although I only see local services (and there are others that I can see on my Mac).

On my Mac I can't see it (with Bonjour Browser.app) or resolve:

⌘ ping raspberrypi.local
ping: cannot resolve raspberrypi.local: Unknown host

The other way around does not work either:

$ ping Tino.local
ping: unknown host Tino.local

They are on the same network (192.168.178.x) and I can ssh into the pi and back into my mac. I have rebooted multiple times already.

What next steps can I take?

4 Answers 4

13

In case someone else stumbles upon this, this might be useful:

  • you could try avahi-resolve to see if it's a problem with the NSS integration or the actual hostname resolution

  • try a tcpdump -i wlan0 port 5353 or igmp -w /tmp/mdns.pcap (IGMP) and wireshark /tmp/mdns.pcap (should work from both the pi and your laptop) to inspect what's sent over the wire and see who's not doing what they are supposed to

Better late than never ...

1
  • Definitely. I tried avahi-resolve -n Tino.local and it works now! No idea what changed in the past 6 months (had given up a little) but pinging works on both sides now. Thanks for the help anyway
    – Tino
    Commented Jan 17, 2015 at 12:07
1

You can check the name used by using service or systemctl

alexis@Oreo:~$ sudo systemctl status avahi-daemon
[sudo] password for alexis: 
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor pre
   Active: active (running) since Wed 2021-02-03 08:33:50 CET; 5h 50min ago
 Main PID: 1692 (avahi-daemon)
   Status: "avahi-daemon 0.7 starting up."
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/avahi-daemon.service
           ├─1692 avahi-daemon: running [Oreo.local]
           └─1708 avahi-daemon: chroot helper

You can fix it by editing /etc/avahi/avahi-daemon.conf and rebooting (or restarting the service)

[server]
host-name=the_hostname
domain-name=local
1
  • 1
    This prompted me to check my avahi-daemon.conf file and I discovered that I had an allow-interfaces= line that didn't list my network adapter.
    – matth
    Commented Mar 17, 2021 at 14:19
0

As libnss_mdns communicates with avahi-daemon via UNIX-domain socket, strace helps (as it always does :) In my case it discovered wrong permissions on /run/avahi-daemon:

$ ping example
ping: unknown host
$ getent hosts example.local
(no answer)
$ strace -ff -tt -s4096 -ostrace.out getent hosts example.local
$ less strace.out*
...
00:19:07.361257 connect(3, {sa_family=AF_UNIX, sun_path="/var/run/avahi-daemon/socket"}, 110) = -1 EACCES (Permission denied)
$ ls -ld /run/avahi-daemon/
drwx------ 2 avahi avahi 80 Dec  9 23:25 /run/avahi-daemon//
$ sudo chmod 755 /run/avahi-daemon/
$ getent hosts example.local
192.168.1.11    example.local
-2

Try them on the same network hub, not going through a router. Thus, both on the same line out of your router, then they might be able to hear each other.

1
  • 1
    What do you mean? "on the same line out of your router"? They are both on the LAN side, so the router functions as a hub. It should work with a router as well btw.
    – Tino
    Commented Oct 20, 2014 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.