Public bug reported:
## Summary
On Ubuntu 24.04 (systemd 255), running `systemctl restart systemd-networkd`
causes all DHCPv4-managed routes and IP address to be briefly removed and
re-added, resulting in a momentary network outage. This occurs even when
KeepConfiguration=yes is explicitly set in the .network file.
The same configuration works correctly on:
- Ubuntu 22.04 (systemd 249): not affected
- Ubuntu 26.04 (systemd 257+): fixed upstream
- Ubuntu 24.04 (systemd 255): affected (this bug)
## Environment
- OS: Ubuntu 24.04.4 LTS
- Kernel: 6.8.0-149-generic
- systemd: 255.4-1ubuntu8.18 (confirmed not fixed in .19 either)
## Reproduction
/etc/systemd/network/eth0.network:
[Match]
Name=eth0
[Network]
DHCP=ipv4
KeepConfiguration=yes
[DHCPv4]
SendRelease=no
Run:
$ ip monitor &
$ systemctl restart systemd-networkd
Observed output (before fix):
Deleted 10.x.x.x dev eth0 proto dhcp scope link ...
Deleted default via 10.x.x.x dev eth0 proto dhcp ...
Deleted 169.254.169.254 via 10.x.x.x dev eth0 proto dhcp ...
Deleted 2: eth0 inet 10.x.x.x/16 ... ← IP also removed
(re-added after DHCP completes ~100ms later)
Expected: no Deleted entries, routes and address preserved throughout.
## Root Cause
When a new networkd instance starts after restart, it calls
link_reconfigure_impl(). Inside this function (networkd-link.c ~line 1282),
two operations unconditionally destroy DHCP state regardless of
KeepConfiguration=:
/* Dropping old .network file */
r = link_stop_engines(link, false); ← (1) may_keep_dhcp always false
...
else {
r = link_drop_managed_config(link); ← (2) drops deserialized DHCP routes
}
This is confirmed in the debug log:
eth0: Configuring with /etc/systemd/network/eth0.network
eth0: Removing DHCPv4 route (configured): dst: 169.254.169.254/32 ← BUG
eth0: Removing DHCPv4 route (configured): dst: 0.0.0.0/0
eth0: Removing DHCPv4 address (configured): 10.x.x.x/16
eth0: DHCPv4 client: DISCOVER ← full DHCP cycle from scratch
Note: KeepConfiguration=yes IS honored during `systemctl stop` (routes
survive), but the new instance's startup path ignores it.
## Upstream Fix
Fixed in systemd v257 by commit:
82df2e0f0496834064f32e4f09cc32728c1cbddd
"network: make 'networkctl reconfigure' work safely even when
KeepConfiguration=dhcp or yes"
Author: Yu Watanabe <[email protected]>
Date: 2024-11-06
URL:
https://github.com/systemd/systemd/commit/82df2e0f0496834064f32e4f09cc32728c1cbddd
The upstream fix restructures link_reconfigure_impl() to check
KeepConfiguration before calling link_stop_engines(), using a new
link_drop_dynamic_config() helper and LinkReconfigurationFlag enum.
That full refactoring cannot be applied directly to v255 as it depends
on helper functions (link_drop_dhcp4_config, etc.) not present in this
codebase.
## Proposed Backport Patch
The attached patch implements the equivalent fix using the existing v255
code structure: check KEEP_CONFIGURATION_DHCP_ON_START before
link_stop_engines() and link_drop_managed_config() in
link_reconfigure_impl().
Changes: src/network/networkd-link.c only (11 insertions, 5 deletions)
## Test Results (verified on Ubuntu 24.04)
Patched binary built from systemd-255.4 source and tested:
$ ip monitor & systemctl restart systemd-networkd (×3 repetitions)
Before patch: 9× "Deleted" entries per restart, full DHCP DISCOVER cycle
After patch: 0 deletions (PASS ×3), routes re-confirmed in-place
## Related
- LP: #2098183 — same KeepConfiguration series; fixed IPv6+dhcp-on-stop
stop phase (backported in 255.4-1ubuntu8.9). Did not cover the DHCPv4
link_reconfigure_impl() restart path that this bug concerns.
- Not affected: Ubuntu 22.04 (systemd 249), Ubuntu 26.04 (systemd 257+)
** Affects: systemd (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174378
Title:
systemd-networkd: KeepConfiguration=yes does not prevent DHCPv4
routes/address removal on daemon restart (regression vs systemd 249,
fixed upstream in v257)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2174378/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs