On a local LAN, I am trying to ssh into a freshly installed Raspberry Zero WH, by host name. I am connecting from an Ubuntu box.
The Rasbperry Pi does boot, and connects to the Wifi. I can see it in my PfSense firewall/router page "Status: DHCP leases" as up and running with it's IP address and host name. It's online and the lease type is static.
Now when I do
$ ssh pi@raspberrypi-zero-wh
I immediately get
ssh: connect to host raspberrypi-zero-wh port 22: Connection refused
However, I can ping it successfully ping it with this host name and immediately get a response.
$ ping raspberrypi-zero-wh
PING raspberrypi-zero-wh.my.lan (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.063 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.064 ms
I can also ssh into it by IP:
$ ssh [email protected]
[email protected]'s password:
Why does ssh work by IP, but no by host name?
Note:
- It's different from SSH works only with public IP but not with dynamic DNS hostname because this is all local, in the same subnet.
- Can ssh internally, but can't externally: port 22: connection refused may be related, but I fail to see a link between a firewall setting when IP-based routing works.
- I use a PiHole on the same LAN, but again, the ssh seems to be rejected by the destination device, not the DNS server.