我使用的是 ubuntu 16.04 LTS 笔记本电脑。我有一台 raspberry pi zero,我将 raspbian 刷入其中。我在 raspberry pi 上启用了 ssh,并将其设置为以太网小工具,以便我可以通过微型 usb 连接 ssh 进入它。我可以从朋友的 macbook ssh 进入 pi,因此 raspberry 软件配置正确。
avahi 守护进程已启动并正在运行:
$ sudo service avahi-daemon status
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-01-04 14:22:11 EST; 42min ago
Main PID: 4114 (avahi-daemon)
Status: "avahi-daemon 0.6.32-rc starting up."
CGroup: /system.slice/avahi-daemon.service
├─4114 avahi-daemon: running [vivobook.local
└─4122 avahi-daemon: chroot helpe
Jan 04 14:44:16 vivobook avahi-daemon[4114]: Interface wlp2s0.IPv6 no longer relevant for mDNS.
Jan 04 14:44:16 vivobook avahi-daemon[4114]: Withdrawing address record for 172.18.94.241 on wlp2s0.
Jan 04 14:44:16 vivobook avahi-daemon[4114]: Leaving mDNS multicast group on interface wlp2s0.IPv4 with address 172.18.94.241.
Jan 04 14:44:16 vivobook avahi-daemon[4114]: Interface wlp2s0.IPv4 no longer relevant for mDNS.
Jan 04 14:55:22 vivobook avahi-daemon[4114]: Joining mDNS multicast group on interface wlp2s0.IPv4 with address 172.18.94.241.
Jan 04 14:55:22 vivobook avahi-daemon[4114]: New relevant interface wlp2s0.IPv4 for mDNS.
Jan 04 14:55:22 vivobook avahi-daemon[4114]: Registering new address record for 172.18.94.241 on wlp2s0.IPv4.
Jan 04 14:55:24 vivobook avahi-daemon[4114]: Joining mDNS multicast group on interface wlp2s0.IPv6 with address fe80::fc9:a526:6f49:7e33.
Jan 04 14:55:24 vivobook avahi-daemon[4114]: New relevant interface wlp2s0.IPv6 for mDNS.
Jan 04 14:55:24 vivobook avahi-daemon[4114]: Registering new address record for fe80::fc9:a526:6f49:7e33 on wlp2s0.*.
但是我无法 ping raspberrypi.local 或 raspberry.local。
我不知道 172.18.94.241 地址是什么,但我可以 ping 它但不能 ssh 它,所以我不认为它是 pi。
ifconfig
没有显示树莓派连接:
sudo ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:ae:ef:4b:aa
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:18973 errors:0 dropped:0 overruns:0 frame:0
TX packets:18973 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14786295 (14.7 MB) TX bytes:14786295 (14.7 MB)
wlp2s0 Link encap:Ethernet HWaddr 7c:5c:f8:b3:46:5b
inet addr:172.18.94.241 Bcast:172.18.95.255 Mask:255.255.248.0
inet6 addr: fe80::fc9:a526:6f49:7e33/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:236543 errors:0 dropped:0 overruns:0 frame:0
TX packets:26241 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:277975117 (277.9 MB) TX bytes:4022218 (4.0 MB)
我尝试卸载并重新安装 avahi 守护程序,但没有效果。我做错了什么?
答案1
我使用以下方法解决了 Raspberry Pi Zero W 的问题:
网络管理器菜单 -> 编辑连接,编辑新的以太网连接(对我来说是“有线连接 2”)。IPv6 设置 -> 方法 -> 仅本地链接。
网络管理器现在应该能够建立连接。
$ ifconfig
enp0s20f0u1 Link encap:Ethernet HWaddr 8a:dd:a1:c0:72:c0
inet6 addr: fe80::2f6d:7bde:ad10:d2a7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:165 errors:0 dropped:0 overruns:0 frame:0
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:30167 (30.1 KB) TX bytes:81949 (81.9 KB)
运行以下命令检查 avahi-daemon 是否检测到新设备:
$ avahi-resolve-host-name raspberrypi.local
raspberrypi.local fe80::c813:143e:4bf0:7607
进而:
$ ssh -6 pi@fe80::c813:143e:4bf0:7607%enp0s20f0u1
Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l
...
不幸的是,简单的主机名解析方式不起作用:
$ ssh -6 [email protected]
ssh: Could not resolve hostname raspberrypi.local: Name or service not known
感谢 quantenProjects 的评论这里。