0

When I first got my Pi about six weeks ago, I could follow the setup instructions easily, and connect to the Pi using raspberrypi.local (without the Bonjour service installed on Windows). However, for some reason, this has stopped working. Connecting with PuTTY replies "host does not exist", and "ping raspberrypi.local" gives no response. My router knows the Pi and lists it as raspberrypi. The Pi is still called raspberrypi in /etc/hosts and /etc/hostname.

I have read this reply and followed the link to How-To Geek, I have installed the Bonjour service as instructed, and checked that avahi-daemon is running on the Pi. I have disabled the UFW firewall to check if that caused the problem.

Can anyone give me an idea of what the problem might be?

2
  • This is either a Windows problem or a limitation of your local network. Either way there is nothing on the Pi preventing Zero-conf from working. If a network problem restarting all devices on the network (including router) may help.
    – Milliways
    Feb 22, 2021 at 8:40
  • Shutdown your laptop, shutdown your RPi. Reboot your router. Reboot your RPi. Reboot your laptop. Now check your network to see what IP address your RPi has and try again with raspberrypi.local (you can use that in putty or a webserver).
    – Dougie
    Feb 22, 2021 at 10:23

2 Answers 2

1

One possibility, which I just ran into myself: avahi may have swapped to a different (incorrect) network interface. I was similarly seeing ping: cannot resolve raspberrypi.local: Unknown host from a remote machine (on the same network) but on the Pi I saw:

$ ping raspberrypi.local -c 1
PING raspberrypi.local (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1 (172.17.0.1): icmp_seq=1 ttl=64 time=0.204 ms

--- raspberrypi.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.238/0.238/0.238/0.000 ms

172.17? That's definitely not right, my router uses 192.168.*.*. So I looked at ifconfig to see where that IP address was coming from:

$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ...

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.86.21  netmask 255.255.255.0  broadcast 192.168.86.255
        ...

Ah! I'd installed Docker at some point and this must have confused Avahi. I looked in /etc/avahi/avahi-daemon.conf and saw an example deny-interfaces directive so I added:

deny-interfaces=docker0

and then ran:

sudo service avahi-daemon restart

Re-running ping on the Pi then reported the expected 192.168 address. After a few minutes other machines on my network had picked up the correct address as well.

-1

While I like mDNS and the Macintosh implementation, I found that my Windows machine wasn't playing nice with it. I had to create an entry in my windows hosts file, and later on I used WSDD to replace the broken network discovery of netbios names.

hosts on Windows This assumes that you have assigned a static IP address to your raspberry pi. I typically use DHCP reservation in my router for this task.

Type "cmd" in the search field.
In the search results, right-click CMD and select Run as administrator.
At the command prompt paste and run the following line:
notepad.exe c:\windows\system32\drivers\etc\hosts

Add a line at the bottom of the file. !st entry is the IP address, second entry is the Fully Qualified Domain Name FQDN that you choose as this DNS request will never make it out of your Windows machine as it reads the c:\windows\system32\drivers\etc\hosts first before using TCP/IP to run a DNS Query further afield:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

192.168.0.2 raspberrypi.local

Make the necessary changes to the file. Click File > Save to save your changes.

test it using ping:

ping raspberrypi.local

You may also be interested in Web Service Discovery host daemon WSDD that I mentioned.

2
  • 1
    Thanks Ron, this is definitely a (partial) solution. My Pi has fixed IP.
    – manscher
    Feb 23, 2021 at 13:59
  • You may want to look at .ssh/config file and work with that if you are simply looking for an ease of use for ssh. Personally I would use git for windows, as it puts bash onto my computer and can be hacked into providing a workable rsync solution. WSDD is going to interest you. Look into installing it on the pi then. Cheers!
    – Ron K.
    Feb 24, 2021 at 17:48

Your Answer

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

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