systemd-networkd fails to apply static IPv4 when the static IP is the same as previously configured by DHCP
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd |
Fix Released
|
Unknown
|
|||
systemd (Ubuntu) |
Fix Released
|
Medium
|
Dan Streetman | ||
Bionic |
Fix Released
|
Medium
|
Dan Streetman | ||
Disco |
Won't Fix
|
Medium
|
Dan Streetman |
Bug Description
[impact]
if networkd is configured with a static address, and the address has already been assigned by dhcp (so that it has finite valid_lft), networkd will not change the valid_lft to 'forever' during startup, which leaves networkd thinking the address is static (meaning, networkd will not attempt to renew the dhcp lease) but the address valid_lft counting down.
Once the valid_lft expires, the kernel will remove the address from the interface, breaking the system's networking.
[test case]
configure a system with networkd similar to:
[Match]
Name=ens3
[Network]
DHCP=ipv4
restart systemd-networkd, and ens3 should get a DHCP address, e.g.:
$ ip -4 a show ens3
2: ens3: <BROADCAST,
inet 192.168.122.147/24 brd 192.168.122.255 scope global dynamic ens3
valid_lft 2295sec preferred_lft 2295sec
then, edit the networkd config to use a static address, e.g.:
[Match]
Name=ens3
[Network]
Address=
Gateway=
DNS=192.168.122.1
Domains=vm
make sure to use the exact same address that was provided by dhcp.
Then, without rebooting, just restart networkd and check the address lft:
$ sudo systemctl restart systemd-networkd
$ ip -4 a show ens3
2: ens3: <BROADCAST,
inet 192.168.122.147/24 brd 192.168.122.255 scope global dynamic ens3
valid_lft 2992sec preferred_lft 2992sec
the address should have 'forever' valid_lft, but it doesn't.
[regression potential]
this changes the details of how networkd updates static addresses during startup, so any regression would occur at networkd startup when using static addresses.
[scope]
this is needed only in Bionic and Disco.
this is fixed by upstream:
https:/
specifically commit a47a6daebe0af26
which is included in Eoan and later.
In Xenial using networkd, testing shows this problem does not occur, because this older version of networkd removes the 'foreign' dhcp address before re-assigning it as a static address.
[other info]
original description:
---
In bionic, running systemd 237-3ubuntu10.22 and netplan.io 0.97-0ubuntu1~
This will cause the interface to loose its IP address when the DHCP lease exires, even though you've told netplan to configure it as static.
I expect systemd-networkd to actually configure an IP address as static, regardless of what address the interface has before from DHCP.
# lsb_release -rd
Description: Ubuntu 18.04.2 LTS
Release: 18.04
# apt-cache policy systemd
systemd:
Installed: 237-3ubuntu10.22
# apt-cache policy netplan.io
netplan.io:
Installed: 0.97-0ubuntu1~
A paste of systemd-networkd's debug log when I run "netplan apply" and the interface already has the static IP configured from DHCP.
It seems like upon a restart, systemd-networkd will allways add whatever IP config it had before the service stopped, and then apply changes (if any). Since my new config has the same IP as it already had, it does nothing even though the new config has static configuration.
summary: |
- systemd-network fails to apply static IPv4 when the static IP is the + systemd-networkd fails to apply static IPv4 when the static IP is the same as previously configured by DHCP |
Changed in systemd: | |
status: | Unknown → Fix Released |
tags: | added: bionic ddstreet disco eoan focal sts systemd |
Changed in systemd (Ubuntu Bionic): | |
status: | New → In Progress |
Changed in systemd (Ubuntu Disco): | |
status: | New → In Progress |
assignee: | nobody → Dan Streetman (ddstreet) |
Changed in systemd (Ubuntu Bionic): | |
assignee: | nobody → Dan Streetman (ddstreet) |
Changed in systemd (Ubuntu Disco): | |
importance: | Undecided → Medium |
Changed in systemd (Ubuntu Bionic): | |
importance: | Undecided → Medium |
Changed in systemd (Ubuntu): | |
status: | In Progress → Fix Released |
description: | updated |
description: | updated |
tags: | removed: eoan focal |
I should add that if I set "dhcp4: no" explicit when confiugring static addressing, it behaves as expected, but according to the current documentation, this parameter should default to "no", so this should not be neccescary.