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
Bugs, which is subscribed to 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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1833193/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to