我已经通过 wifi 将运行 ubuntu 20.04 的树莓派 4 连接到我的本地 LAN。
从我的笔记本电脑上,我可以通过 SSH 连接到树莓派:
$ ssh ubuntu@192.168.0.47
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-1022-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
...
不必每次都输入该 IP,而我希望能够使用主机名 SSH 到它:rasp01
。我找到了这个指南:
https://thepihut.com/blogs/raspberry-pi-tutorials/19668676-renaming-your-raspberry-pi-the-hostname
我遵循的。在我重新启动树莓派并登录后,我有这个:
ubuntu@rasp01:~$ hostname
rasp01
ubuntu@rasp01:~$ cat /etc/hosts
rasp01 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
ubuntu@rasp01:~$ cat /etc/hostname
rasp01
但是,当我尝试使用该主机名时,我从同一 LAN 上的笔记本电脑(也运行 ubuntu)SSH 到树莓派,我得到:
$ ssh ubuntu@rasp01
ssh: Could not resolve hostname rasp01: Name or service not known
$ ssh ubuntu@rasp01.local
ssh: Could not resolve hostname rasp01.local: Name or service not known
$ ssh ubuntu@rasp01.local.
ssh: Could not resolve hostname rasp01.local.: Name or service not known
我错过了什么?