我遇到了由 systemd-networkd-wait-online 超时(2 分钟)直接导致的启动延迟。您能帮我诊断一下吗?特别是如何在 systemd-networkd-wait-online 调试中深入挖掘,也许使用一些额外的标志?到目前为止,我只知道“某些接口出现故障”......除了延迟之外,路由器、wifi 接入点和互联网连接功能正常。
我知道我可以通过在等待在线服务中添加“--any”标志来绕过这个延迟错误,但我很好奇是否可以在没有变通方法的情况下解决这个问题。
我使用的是 Ubuntu Server 22.04,内核为 6.2,PC 配置为路由器。WAN 连接是内置 RJ-45 NIC(逻辑名称:wan-wire)。LAN 是一个桥接器(逻辑名称:lan-wifi-bridge),由 USB 加密狗 NIC RJ-45(逻辑名称:usb-lan-wire)和使用 USB 加密狗创建的 hostapd 接入点(逻辑名称:usb-wifi)组成。
networkctl 启动后(延迟 2 分钟)查看结果 - 看到 usb-wifi 仍处于配置状态:
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 wan-wire ether routable configured
3 usb-lan-wire ether no-carrier configured
4 lan-wifi-bridge bridge no-carrier configured
5 usb-wifi wlan no-carrier configuring
Journalctl 日志(查看 12:54:34 和 12:56:31 之间的延迟,其中发生 2 分钟超时):
sudo journalctl -b | egrep -i networkd
Sep 11 12:54:30 thin systemd-networkd[599]: lan-wifi-bridge: netdev ready
Sep 11 12:54:30 thin systemd-networkd[599]: lo: Link UP
Sep 11 12:54:30 thin systemd-networkd[599]: lo: Gained carrier
Sep 11 12:54:30 thin systemd-networkd[599]: Enumeration completed
Sep 11 12:54:31 thin systemd-networkd[599]: lan-wifi-bridge: Link UP
Sep 11 12:54:31 thin systemd-networkd[599]: wan-wire: Link UP
Sep 11 12:54:31 thin systemd-networkd[599]: usb-lan-wire: Link UP
Sep 11 12:54:31 thin systemd-networkd[599]: lan-wifi-bridge: Gained carrier
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:31 thin systemd-networkd[599]: wlan0: Interface name change detected, renamed to usb-wifi.
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:31 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd[599]: usb-wifi: Link UP
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:32 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:33 thin systemd-networkd[599]: lan-wifi-bridge: Lost carrier
Sep 11 12:54:33 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:33 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:34 thin systemd-networkd[599]: wan-wire: Gained carrier
Sep 11 12:54:34 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:34 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:34 thin systemd-networkd-wait-online[603]: managing: wan-wire
Sep 11 12:54:34 thin systemd-networkd-wait-online[603]: managing: usb-lan-wire
Sep 11 12:54:34 thin systemd-networkd-wait-online[603]: managing: wan-wire
Sep 11 12:56:31 thin systemd-networkd-wait-online[603]: Timeout occurred while waiting for network connectivity.
Sep 11 12:56:31 thin systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FAILURE
Sep 11 12:56:31 thin systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
Sep 11 12:56:32 thin systemd[1]: Starting Dispatcher daemon for systemd-networkd...
Sep 11 12:56:32 thin networkd-dispatcher[628]: No valid path found for iwconfig
Sep 11 12:56:32 thin networkd-dispatcher[628]: No valid path found for iw
Sep 11 12:56:32 thin systemd[1]: Started Dispatcher daemon for systemd-networkd.
Hostapd 作为标准系统服务运行。Hostapd.conf 关键摘录:
interface=usb-wifi
bridge=lan-wifi-bridge
以及 netplan 配置:
network:
version: 2
renderer: networkd
ethernets:
wan-wire:
match:
macaddress: xxxxxxxxxxxxxxxxxxxxx
set-name: wan-wire
dhcp4: false
dhcp6: false
accept-ra: false
link-local: []
addresses:
- 192.168.0.100/24
nameservers:
addresses: [8.8.8.8,8.8.4.4]
search: []
routes:
- to: default
via: 192.168.0.1
usb-lan-wire:
match:
macaddress: yyyyyyyyyyyyyyyyyyy
set-name: usb-lan-wire
dhcp4: false
dhcp6: false
usb-wifi:
match:
macaddress: zzzzzzzzzzzzzzzzzzz
set-name: usb-wifi
dhcp4: false
dhcp6: false
#BRIDGE IS EXTENDED BY HOSTAPD AT LATER STAGE
bridges:
lan-wifi-bridge:
interfaces:
- usb-lan-wire
dhcp4: false
dhcp6: false
accept-ra: false
link-local: [ ]
addresses:
- 192.168.10.1/24
nameservers:
addresses: [8.8.8.8,8.8.4.4]
search: [ ]