So, I've just got a Raspberry Pi Zero W and installed Raspbian Stretch Lite (headless Debian Stretch). I was able to configure WiFi in headless mode and the Raspberry connected to my home WiFi network.

I've then run nmap -p 22 to find out the device's IP:

Starting Nmap 7.70 ( https://nmap.org ) at 2019-06-07 22:01 +03

Nmap scan report for
Host is up (0.0095s latency).

22/tcp open  ssh

Nmap done: 256 IP addresses (5 hosts up) scanned in 2.76 seconds

Looks like is the droid I am looking for. Connecting over SSH works:

ssh pi@
Linux raspberrypi-1 4.14.98+ #1200 Tue Feb 12 20:11:02 GMT 2019 armv6l

pi@raspberrypi-1:~ $ hostname

I've already played a little with it and changed the hostname to raspberrypi-1, but everything I'm asking happened with the default name too (raspberrypi).

Avahi is running on my Raspberry:

pi@raspberrypi-1:~ $ ps axu | grep avahi
avahi      247  0.0  0.7   6384  3168 ?        Ss   17:54   0:00 avahi-daemon: running [raspberrypi-1.local]
avahi      255  0.0  0.3   6384  1480 ?        S    17:54   0:00 avahi-daemon: chroot helper
pi         829  0.0  0.4   4360  2028 pts/0    S+   19:10   0:00 grep --color=auto avahi

Self ping by raspberrypi-1.local name works too:

pi@raspberrypi-1:~ $ ping raspberrypi-1.local
PING raspberrypi-1.local ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=64 time=0.230 ms
--- raspberrypi-1.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms

Now, I'm trying to connect to Pi by it's hostname from my laptop:

$ ssh pi@raspberrypi-1.local                                                                                                                                                         
ssh: Could not resolve hostname raspberrypi-1.local: Name or service not known

But avahi-resolve is able to resolve that name!

$ avahi-resolve -nv raspberrypi-1.local                                                                                                                                                   
Server version: avahi 0.7; Host name: millennium-falcon.local

However, avahi-browse -arp does not show my Pi.

My laptop's /etc/nsswitch.conf is:

passwd: files mymachines systemd
group: files mymachines systemd
shadow: files

publickey: files

hosts: files mymachines mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns mdns4 myhostname
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files

And /etc/resolv.conf is:

nameserver fe80::1%wlp2s0

I cannot understand what's wrong with my config and why cannot I connect to the Pi using its hostname. WAIDW?


The issues seems to be gone after creating a /etc/mdns.allow file on my laptop:

$ ll /etc/mdns.allow                                                                                                                                                                      
-rw-r--r-- 1 root root 15 Jun  7 23:56 /etc/mdns.allow
$ cat /etc/mdns.allow                                                                                                                                                                     

I found the solution here. Still not sure why it doesn't work by default…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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