[Bug 1833193] Re: systemd-networkd fails to apply static IPv4 when the static IP is the same as previously configured by DHCP

Dan Streetman ddstreet at canonical.com
Thu Dec 12 22:34:58 UTC 2019


** Description changed:

- 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.
+ [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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
+     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=192.168.122.147/24
+ Gateway=192.168.122.1
+ 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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
+     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://github.com/systemd/systemd/pull/11460/commits
+ specifically commit a47a6daebe0af26c07d8d423225eb4add110793c
+ which is included in Eoan and later.
+ 
+ In Xenial using networkd, testing shows this problem does not occur.
+ 
+ [other info]
+ 
+ original 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
+   Installed: 237-3ubuntu10.22
  
  # apt-cache policy netplan.io
  netplan.io:
-   Installed: 0.97-0ubuntu1~18.04.1
+   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.

** Description changed:

  [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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
-     inet 192.168.122.147/24 brd 192.168.122.255 scope global dynamic ens3
-        valid_lft 2295sec preferred_lft 2295sec
+     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=192.168.122.147/24
  Gateway=192.168.122.1
  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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
-     inet 192.168.122.147/24 brd 192.168.122.255 scope global dynamic ens3
-        valid_lft 2992sec preferred_lft 2992sec
- 
+     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://github.com/systemd/systemd/pull/11460/commits
  specifically commit a47a6daebe0af26c07d8d423225eb4add110793c
  which is included in Eoan and later.
  
- In Xenial using networkd, testing shows this problem does not occur.
+ 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~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.
+ 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.

-- 
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:
  Fix Released
Status in systemd package in Ubuntu:
  Fix Released
Status in systemd source package in Bionic:
  In Progress
Status in systemd source package in Disco:
  In Progress

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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
      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=192.168.122.147/24
  Gateway=192.168.122.1
  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,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
      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://github.com/systemd/systemd/pull/11460/commits
  specifically commit a47a6daebe0af26c07d8d423225eb4add110793c
  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~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/systemd/+bug/1833193/+subscriptions



More information about the foundations-bugs mailing list