0

I am using a Raspberry Pi Zero 2W for some development, and am having trouble with headless operation through SSH.

The usual method is via "ssh user@raspberrypi.local". This is on and off functional for me, and I often have to resort to connecting a monitor etc. to find the IP address.

The error when ".local" doesn't work is "ssh: Could not resolve hostname ccp.local: name or service not known".

I have found this guide about using Bonjour and Avahi, which I implemented at least a year ago, and still get the exact same problem here and there.

I have also tried this and this guide regarding setting up ssh over USB, then attempting ssh via both command line and PuTTY, which again results in the above error when using command prompt, and the error "Unable to open connection to raspberrypi.local. Host does not exist".

Using the IP address instead of raspberypi.local seems to always work, but the intended use case for the pi is rather reliant on headless being functional upon startup.

Does anyone know why this is so unreliable?

3 Answers3

0

This happens occasionally. The .local resolution works by sending a broadcast message.

The problem is not with the Pi (it affects other devices) and appears to be related to address caching.

The only reliable solution is to restart the router and occasionally the target device.

arp probing can explore the issue and may resolve it.

Milliways
  • 62,573
  • 32
  • 113
  • 225
0

My experience has been mostly similar to Milliways. However, I have found that one thing seems to help:

Your hostname is stored in /etc/hostname; in my case /etc/hostname contains the following:

$ less /etc/hostname
raspberrypi3b

Make sure that the file /etc/hosts contains at least this reference to 127.0.1.1 as the final entry:

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
127.0.1.1       raspberrypi3b.local

Note that you can add additional hostnames here, so I always put this in for the final line of /etc/hosts:

...
127.0.1.1       raspberrypi3b.local raspberrypi3b

I've found that this gives me more reliable name resolution under avahi.

Seamus
  • 23,558
  • 5
  • 42
  • 83
0

In addition to the suggestions by other commenters, I found a thread discussing what seemed to be a fairly similar problem, where installing the package called "Samba" was suggested for Windows users. This solved the immediate issue for me.

Here is the thread I found.