接口 IPv6 LinkLocal 地址还没初始化导致的问题

问题描述

将 ifupdown2 替换回 ifupdown, LXC 容器 IP 丢失

非 PVE 的 ifupdown2 无法拉起 network.target

排查服务状态发现是 networking 没启动, 但是容器刚开始是能连上的, 是因为 DHCPv6 失败以后 DHCP Client 被杀掉导致没有续期

x networking.service - Raise network interfaces
     Loaded: loaded (/usr/lib/systemd/system/networking.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2025-08-19 17:41:11 CST; 6s ago
 Invocation: 46b72b1275da41a1b53d12315873ac80
       Docs: man:interfaces(5)
    Process: 88 ExecStart=/usr/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
    Process: 186 ExecStopPost=/usr/bin/touch /run/network/restart-hotplug (code=exited, status=0/SUCCESS)
   Main PID: 88 (code=exited, status=1/FAILURE)
   Mem peak: 9.7M
        CPU: 125ms

Aug 19 17:41:11 localhost dhclient[172]: than a configuration issue please read the section on submitting
Aug 19 17:41:11 localhost dhclient[172]: bugs on either our web page at www.isc.org or in the README file
Aug 19 17:41:11 localhost ifup[88]: ifup: failed to bring up eth0
Aug 19 17:41:11 localhost dhclient[172]: before submitting a bug.  These pages explain the proper
Aug 19 17:41:11 localhost dhclient[172]: process and the information we find helpful for debugging.
Aug 19 17:41:11 localhost dhclient[172]: 
Aug 19 17:41:11 localhost dhclient[172]: exiting.
Aug 19 17:41:11 localhost systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Aug 19 17:41:11 localhost systemd[1]: ::::networking.service: Failed with result 'exit-code'.
Aug 19 17:41:11 localhost systemd[1]: Failed to start networking.service - Raise network interfaces.
Aug 19 17:41:11 localhost dhclient[172]: Can't bind to dhcp address: Cannot assign requested address
Aug 19 17:41:11 localhost ifup[172]: Can't bind to dhcp address: Cannot assign requested address

尝试解决

这个 Bug 可以追溯到十年前, Ubuntu LaunchPad Bug

就是接口 IPv6 LinkLocal 地址还没初始化就进行 DHCP 导致的问题

解决方案

建议使用 SLAAC

给网卡加上 pre-up sleep 5 是可以解决问题的, 但是 PVE 会覆盖配置
最后修改:2025 年 08 月 19 日
如果觉得我的文章对你有用,请随意赞赏