[Bug 1833193] Re: systemd-networkd fails to apply static IPv4 when the static IP is the same as previously configured by DHCP
Dan Streetman
dan.streetman at canonical.com
Mon Sep 30 16:23:29 UTC 2019
Thanks! that clarifies it - I think this is a bug upstream with
systemd.
> if I set "dhcp4: no" explicit when confiugring static addressing, it
behaves as expected
are you sure? that isn't what I would expect, it seems the problem is
networkd doesn't adjust the address lifetime when networkd is restarted
and the address changes from dhcp->static; i would not expect the
DHCP=no param it fix that. Although that's a netplan config, so
possibly netplan does something additional under the covers, other than
what systemd-networkd does.
> It seems like upon a restart, systemd-networkd will allways add
whatever IP config it had before the service stopped, and then apply
changes
not exactly, what's happening is when you stop networkd, it does not
remove network configuration that it manages, so in this case it would
leave the dhcp address on the interface. then when you (re)start
networkd, it does not change existing addresses that it manages, so it
sees that the interface already has the address that it's been
configured to use as a static address, and does not change it. It looks
like networkd needs to also check the address's lifetime to make sure
static addrs have their lifetime set to 'forever' (I have not actually
checked the code yet to verify this).
If you reboot, or manually remove the address, or just bring the
interface down and back up, networkd will re-add the address with
'forever' lft, so this should only be a problem when you have manually
changed the config for an address from dhcp->static using the same ip
address, and then restart networkd without rebooting, at least IIUC.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to systemd in Ubuntu.
https://bugs.launchpad.net/bugs/1833193
Title:
systemd-networkd fails to apply static IPv4 when the static IP is the
same as previously configured by DHCP
Status in systemd package in Ubuntu:
New
Bug description:
In bionic, running systemd 237-3ubuntu10.22 and netplan.io
0.97-0ubuntu1~18.04.1, systemd-networkd fails to configure an
interface with a static IPv4 address if the statically confiugred
address is the same as the interface already has gotten from DHCP.
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~18.04.1
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.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1833193/+subscriptions
More information about the foundations-bugs
mailing list