我试图通过 systemd-networkd 设置静态 IP,一切正常,在我删除自定义文件并重新启动设备后,eth0 和 wlan0 都无法启动。我希望他们能再次从 DHCP 获取地址,检查我看到的调试日志:
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_33 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=12 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.10 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Bus bus-api-network: changing state HELLO → RUNNING
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=4294967295 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=signal sender=org.freedesktop.DBus destination=:1.10 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=signal sender=org.freedesktop.DBus destination=:1.10 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=3 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.10 path=n/a interface=n/a member=n/a cookie=4 reply_cookie=2 signature=u error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Successfully acquired requested service name.
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.10 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=3 signature=n/a error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Match type='signal',sender='org.freedesktop.login1',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager',member='PrepareForSleep' successfully installed.
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: Link state is up-to-date
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: found matching network '/lib/systemd/network/80-wired.network'
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Setting '/proc/sys/net/ipv6/conf/eth0/disable_ipv6' to '0'
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: IPv6 successfully enabled
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Setting '/proc/sys/net/ipv6/conf/eth0/proxy_ndp' to '0'
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Setting '/proc/sys/net/ipv6/conf/eth0/use_tempaddr' to '0'
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Setting '/proc/sys/net/ipv6/conf/eth0/accept_ra' to '0'
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: DHCPv6 CLIENT: Failed to set DUID-EN: No medium found
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: DHCP6 CLIENT: Failed to set DUID: No medium found
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: Failed
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: eth0: State changed: initialized -> failed
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=13 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Dec 16 17:27:56 raspberrypi4 systemd-networkd[339]: DHCP CLIENT (0x0): STOPPED
然而过去ipv6地址是成功分配的。我找不到任何对该Failed to set DUID: No medium found
错误的引用
答案1
问题是我们在 /etc 上使用了 overridefs,它覆盖了/etc/machine-id
使用默认空文件生成的 systemd,因为 systemd 挂载的 tmpfs/ets/machine-id
正在被重写。
因此,DHCP6 客户端无法设置 DUID,因为该 DUID/etc/machine-id
为空。我通过将 /etc/machine-id 复制到覆盖分区(如果不存在)来修复它,使其在重新启动后保持不变。