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.
2 Answers 2
You think that raspberrypi-zero-wh
is that name of your Raspberry Zero WH, but as can be seen in the output of the ping
command, that name resolves to 127.0.0.1
.
So you don't try to connect to the Raspberry Zero WH, you try to connect to the computer running the ssh
command.
It seems to be a problem with the assignment of the DNS name.
-
Good spot. The name is given by the pfSense, which is NOT my immediate DNS resolver. As mentioned, a PiHole is, which uses the pfSense upstream. I'll look into the PiHole log to find more.Marcel– Marcel2019年07月02日 06:55:51 +00:00Commented Jul 2, 2019 at 6:55
-
It was indeed a problem with DNS. In my DNS server (phihole), I had to whitelist the qualified domain raspberrypi-zero-wh.my.lan. Without that it had been blocked by my quite strict rules.Marcel– Marcel2019年07月03日 19:54:25 +00:00Commented Jul 3, 2019 at 19:54
raspberrypi-zero-wh
Which I assume is your hostname is meaningless.
Try raspberrypi-zero-wh.local
which should be resolved by zero-conf
on a standard Raspbian and is supported by most Linux distributions.
-
Does your suggestion assume I am connecting from a Raspberry? I am connecting from an Ubuntu box TO a Raspberry.Marcel– Marcel2019年07月02日 06:54:20 +00:00Commented Jul 2, 2019 at 6:54
-
I made no assumption, other than assuming zero-conf was on both platformsMilliways– Milliways2019年07月02日 07:03:42 +00:00Commented Jul 2, 2019 at 7:03