2

First time setting up a Pi yesterday, I installed Raspberry Pi OS Lite 64 bit and filled in options in the Imager application to configure wifi out of the box, as well as setting the hostname and allowing ssh through keys only. To my delight, I could ssh into the Pi right off the bat with ssh [email protected] from my Windows laptop. I understand this is due to the magic of something called mDNS.

Fast forward to this morning, and my laptop can no longer find the Pi hostname on the network:

❯ nslookup rubus.local
Server:  homerouter.cpe
Address:  192.168.8.1

*** homerouter.cpe can't find rubus.local: Non-existent domain

(Of course I don't have output from when it worked in the beginning.)

ssh [email protected] still works, so the network connection is fine - it's just the hostname that has vanished.

Reading and googling furiously, I found this thread and installed Bonjour Print Services for Windows v2.0.2 from Apple, which made no difference at all. I have also seen this thread, read man avahi-daemon.conf and reviewed my Avahi config and status. LGTM.

How does this work from the first boot and then just stop working overnight?

Hardware, versions, config etc.:

  • My laptop is running Windows 10 Pro 21H1 build 19043.1526.

    • Checked in services.msc that the Bonjour Service is running.
  • Raspberry Pi 3 Model B+

    • Running Raspberry Pi OS Lite 64 bit.

    • Avahi config (comments and empty sections removed):

       [server]
       use-ipv4=yes
       use-ipv6=yes
       ratelimit-interval-usec=1000000
       ratelimit-burst=1000
      
       [wide-area]
       enable-wide-area=yes
      
       [publish]
       publish-hinfo=no
       publish-workstation=no
      
    • Avahi status:

       pi@rubus:~ $ service avahi-daemon status
       ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
            Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
            Active: active (running) since Fri 2022-02-11 15:12:32 CET; 47min ago
       TriggeredBy: ● avahi-daemon.socket
          Main PID: 1294 (avahi-daemon)
            Status: "avahi-daemon 0.8 starting up."
             Tasks: 2 (limit: 780)
               CPU: 112ms
            CGroup: /system.slice/avahi-daemon.service
                    ├─1294 avahi-daemon: running [rubus.local]
                    └─1295 avahi-daemon: chroot helper
      
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Joining mDNS multicast group on interface lo.IPv6 with address ::1.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: New relevant interface lo.IPv6 for mDNS.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Joining mDNS multicast group on interface lo.IPv4 with address 127.0.0.1.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: New relevant interface lo.IPv4 for mDNS.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Network interface enumeration completed.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Registering new address record for fd48:3fe9:897a:9100:ff1f:9525:1d53:e2a5 on eth0.*.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Registering new address record for 192.168.8.110 on eth0.IPv4.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Registering new address record for ::1 on lo.*.
       Feb 11 15:12:32 rubus avahi-daemon[1294]: Registering new address record for 127.0.0.1 on lo.IPv4.
       Feb 11 15:12:33 rubus avahi-daemon[1294]: Server startup complete. Host name is rubus.local. Local service cookie is 994918085.
      
  • Router is a Huawei B525 4G.

    • I have tried connecting the Pi both over wifi and LAN, no difference. I can ssh to the IP, but not the hostname.
3
  • RPi seems to be working, so I'll guess this is a Windows problem. I wonder if you'll get much help for that here. Have you tried to find any solutions through a search?
    – Seamus
    Commented Feb 11, 2022 at 18:23
  • Everything was working until it stopped working, so I'm curious how you determined that it's specifically a Windows problem? :)
    – kthy
    Commented Feb 11, 2022 at 22:23
  • 1
    If I could explain why Windows does all the strange things it does, I wouldn't be here :P
    – Seamus
    Commented Feb 12, 2022 at 0:24

1 Answer 1

5

nslookup won't be able to find your RPi3 because it uses a DNS lookup, rather than mDNS. i.e. it queries whatever DNS server your laptop is set up to use, which won't be likely to know about your local systems. mDNS works by sending out a multicast request on the local network, asking the server with the matching name to identify itself. If you try ping rubus.local, you are more likely to get a response. Note that recent versions of Windows 10 should have mDNS enabled - you no longer need to install Bonjour separately.

I have had a couple of problems that have fouled up mDNS resolution. In some cases, Avahi seems to have got confused, or I have had temporarily had two systems with the same hostname configured, and my RPi has ended up with an mDNS name like raspberrypi-2.local rather than raspberrypi.local. You should be able to resolve this by checking there are no duplicate hostnames, then restarting Avahi using a command like

sudo systemctl restart avahi-daemon.service

I have also had a problem with Docker containers interfering with mDNS. Specifically, I was trying to run a Samba server inside a docker container, which seemed to be trying to advertise itself using Avahi. mDNS worked briefly, but once Samba started, the RPi started responding to raspberrypi.local with the IP address of the Docker container. As this address was only reachable inside the Docker virtual network, my Win10 laptop could resolve the RPi's name, but not connect to it unless I typed the normal IP address explicitly. To fix this, I had to reconfigure Samba to stop trying to advertise itself. You might have a similar problem if ping rebus.local returns a reply from a different IP address than the one you were expecting.

2
  • Thanks for the nslookup tip, and confirming my suspicion that the Bonjour thing is outdated. Your talk of Samba shares led me to my network settings on Windows - after switching the profile from public to private network ssh [email protected] works again. Beats me how it worked in the first place, though!
    – kthy
    Commented Feb 11, 2022 at 22:50
  • Looks like the culprit is the Windows firewall then. Since the RPI is inside your LAN, home/private network should be the correct setting.
    – Kate
    Commented Feb 12, 2022 at 14:07

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.