我无法使用FRITZ!WLAN USB 记忆棒 N将我的 Raspberry Pi 1B 连接到我的无线网络。我看到了几个问题,但无法找到并消除根本原因。该问题可以在 Raspberyy Pi 3B 上重现。
启动过程结束时,无线网络不可用,网络设备显示为ifconfig
,但没有 IP 地址。iwconfig
报告
wlan0 IEEE 802.11abgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
手动修复(有效)
如果我使用手动启动 wlan0 ifup wlan0
,一切都会正常工作,并且机器连接到我的网络(尝试忽略希望不相关的东西):
wpa_supplicant[854]: Successfully initialized wpa_supplicant
dhclient: Internet Systems Consortium DHCP Client 4.3.1
dhclient: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
wpa_supplicant[855]: wlan0: Associated with xx:xx:xx:xx:xx:xx
wpa_supplicant[855]: wlan0: WPA: Key negotiation completed with xx:xx:xx:xx:xx:xx [PTK=CCMP GTK=CCMP]
[...]
wpa_supplicant[855]: wlan0: CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed [id=0 id_str=]
dhcpcd[485]: wlan0: carrier acquired
wpa_supplicant[855]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=COUNTRY_IE type=COUNTRY alpha2=DE
dhcpcd[485]: wlan0: adding address xxxx::xxxx:xxxx:xxxx:xxxx
dhcpcd[485]: wlan0: IAID 43:0d:1f:fd
dhcpcd[485]: wlan0: rebinding lease of xxx.xxx.x.xx
dhcpcd[485]: wlan0: soliciting an IPv6 router
dhclient: DHCPREQUEST on wlan0 to 255.255.255.255 port 67
dhclient: bound to xxx.xxx.x.xx -- renewal in 335050 seconds.
但是,我想让(无头)系统在无人监督的情况下启动和连接。
假设
也许问题是 USB 记忆棒在加载固件后更改了 USB ID?
系统日志告诉我该棒在启动过程的早期(t=4.2s)被识别,具有 idVendor=057c 和 idProduct=84ff。紧接着(t=5.3s),检测到带有标签“FRITZ!WLAN selfinstall 1.00 PQ:0 ANSI:0 CCS”的SCSI CD-ROM。我猜想棒本身提供了驱动器来让机器加载一些 USB 芯片固件。
在 t=12s 和 t=15.5s 之间的某个时刻,_wpa_supplicant_ 尝试启动网络设备但失败:
wpa_supplicant[264]: Successfully initialized wpa_supplicant
wpa_supplicant[264]: Could not read interface wlan0 flags: No such device
wpa_supplicant[264]: nl80211: Driver does not support authentication/association or connect commands
wpa_supplicant[264]: Could not read interface wlan0 flags: No such device
wpa_supplicant[264]: WEXT: Could not set interface 'wlan0' UP
wpa_supplicant[264]: wlan0: Failed to initialize driver interface networking[198]: Configuring network interfaces...wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
networking[198]: run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
networking[198]: Failed to bring up wlan0.
networking[198]: done.
很久之后(t=30s)USB 设备断开连接并重新连接,显示 idVendor=057c, idProduct=8401。不久之后(t=34.2s),DHCPCD再次尝试但无法连接到网络:
dhcpcd[484]: wlan0: adding address xxxx::xxxx:xxxx:xxxx:xxxx
dhcpcd[484]: wlan0: waiting for carrier
kernel: [ 35.199371] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
khcpcd[484]: wlan0: carrier acquired
dhcpcd[484]: wlan0: IAID 43:0d:1f:fd
dhcpcd[484]: wlan0: carrier lost
dhcpcd[484]: wlan0: deleting address xxxx::xxxx:xxxx:xxxx:xxxx
为什么会失败?我想不出一个正确的主意。
静坐(不起作用)
尝试设置我的后备解决方案:让ifup wlan0
被称为系统服务。创建 /etc/systemd/system/fritz.wlan.service 以尽可能晚地启动 shell 脚本:
[Unit]
Description=Fritz WLAN Stick N
After=ntp.target multi-user.target
[Service]
Type=oneshot
ExecStartPre=/bin/sleep 5
ExecStart=/usr/local/bin/fritz.wlan.sh
[Install]
WantedBy=multi-user.target
和一个 shell 脚本 /usr/local/bin/fritz.wlan.sh:
#!/bin/sh
/bin/sleep 660
iwconfig 2>&1 | grep ESSID:\"xxx > /dev/null || ifup wlan0 2>&1 >> /var/log/fritz.wlan.log
这不会导致成功。该脚本在 multi-user.target 之后立即启动。系统日志告诉我设备已启动并获得了 DHCP 租约,但不久之后,内核决定取消对设备的身份验证,从而解除整个连接:
kernel: [ 717.685006] wlan0: deauthenticating from e0:28:6d:37:3e:f5 by local choice (Reason: 3=DEAUTH_LEAVING)
dhcpcd[465]: wlan0: carrier lost
wpa_supplicant[1330]: wlan0: CTRL-EVENT-DISCONNECTED bssid=e0:28:6d:37:3e:f5 reason=3 locally_generated=1
哼。之后,系统表明初始化过程已完成。不早了。好吧,不过。
systemd[1]: Started Fritz WLAN Stick N.
systemd[1]: Startup finished in 3.332s (kernel) + 11min 54.388s (userspace) = 11min 57.720s.
难道ifup wlan0
是启动的时候就出现问题了系统而不是通过交互式 root shell?
Hacky(但有效)后备
计划任务在重新启动时创建 /var/run/fritz.wlan。另一个 cron 作业让 shell 脚本每分钟检查该文件是否存在。为了始终有一分钟的延迟,此脚本会触及 /var/run.fritz.wlan.2 并删除第一个文件并退出。当第二个文件存在的情况下下一分钟被调用时,脚本调用ifup wlan0
,删除第二个文件并退出。
改进之处在于甚至删除每分钟触发脚本的 cron 作业。
尽管如此,我还是想充分了解问题并找到适当的解决方案。有什么建议么?