Were you able to ping
previoushost.local from the other computers on the same LAN, prior to changing the hostname?
No. I assume that is because
127.0.1.1 <previousHost> is missing in
I don’t think it would be because something is missing on the device’s
/etc/hosts file, although adding something to the PC’s
/etc/hosts file might have a made a difference. I understand that mDNS / zeroconf / Bonjour / Avahi does not require changes to the
/etc/hosts file in order to resolve hostnames. For example, I have a balenaOS device here of hostname
b1878c6, and on my macOS laptop
ping b1878c6.local works, even though the
/etc/hosts file of neither the laptop nor the device include any mention of
Any detailed guide to achieve this?
Usually it “just works” - which is the whole point of “zero configuration”! In practice, it isn’t always like that… But the problems are almost always with mDNS / zeroconf / Bonjour / Avahi installation on the PC, not on the device. So, depending on the PC’s operating system:
Bonjour is built in, and it should just work.
- Linux: Avahi is installed by default on most desktop Linux distributions. Otherwise, on Debian or Ubuntu, the installation command would be
sudo apt-get install avahi-daemon.
- Windows: I understand that some graphical applications built on UWP (Universal Windows Platform) are capable of built-in mDNS resolution, however this would not work on a command line with the
ping command. For every application to work, including ping, the Apple Bonjour service needs to be running. Many Windows machines will already have this service installed, because it is (or used to be) bundled in popular applications such as Skype (Wikipedia lists several others). Otherwise, Bonjour for Windows can be downloaded and installed from: https://support.apple.com/kb/DL999 . The caveat is that these instructions are many years old, and I don’t know how much they are still relevant.
Also, something known to get in the way of mDNS / zeroconf / Bonjour / Avahi is “Internet Sharing”. For example, if I plug an ethernet cable between a Raspberry Pi 2 (which does not have WiFi) and my laptop, and give internet access to the Pi by enabling the macOS internet connection sharing, then running
ping hostname.local on my laptop does not work, and I believe it is because macOS blocks the mDNS packets over the internet sharing interface.
Similarly, some local WiFi routers could be configured to drop mDNS / zeroconf / Bonjour / Avahi packets.
A somewhat defeatist alternative is not to use mDNS / zeroconf / Bonjour / Avahi, by either setting up a proper DNS server (maybe even with a domain name and a DHCP server), or using
ping <ip-address> instead.