[Bug 1836695] Re: Netplan ignores static routes when using DHCP

Dan Streetman dan.streetman at canonical.com
Fri Sep 27 15:38:58 UTC 2019


@pedersen-larserik, @zagarin, can either of you could test your netplan
config on 19.10 (Eoan) to verify things work for you there?

** Description changed:

+ [impact]
+ 
+ a systemd-networkd configuration that uses ipv4 dhcp but ignores the
+ dhcp-provided route, and instead sets up a static route, and also does
+ not include a static ipv4 address, fails to actually create the static
+ route.
+ 
+ This is due to networkd attempting to set up the static route before the
+ dhcp ipv4 address is assigned, and the kernel does not allow creation of
+ the route before setting up corresponding ipv4 address.
+ 
+ this results in a network that does have the dhcp-provided ipv4 address,
+ but is missing both its dhcp-provided route (because networkd is
+ configured to ignore it) and the static route (because networkd was not
+ able to create it).
+ 
+ [test case]
+ 
+ (remove or unconfigure netplan, so it will not conflict with this manual
+ networkd configuration)
+ 
+ create a networkd config file, e.g.:
+ 
+ $ cat /etc/systemd/network/10-eth0.network 
+ [Match]
+ Name=eth0
+ 
+ [Network]
+ DHCP=ipv4
+ 
+ [Route]
+ Destination=10.0.0.0/8
+ Gateway=10.202.51.1
+ 
+ [DHCP]
+ UseRoutes=false
+ 
+ 
+ then *reboot* the system, and check that the static route was not applied:
+ 
+ $ ip r
+ 10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 
+ 
+ 
+ note that because networkd does not remove ipv4 addresses that it manages (including dhcpv4 addresses), restarting networkd after the initial boot
+ will correctly create the static route, e.g.:
+ 
+ ubuntu at lp1836695-b:~$ ip r
+ 10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 
+ ubuntu at lp1836695-b:~$ sudo systemctl restart systemd-networkd
+ ubuntu at lp1836695-b:~$ ip r
+ 10.0.0.0/8 via 10.202.51.1 dev eth0 proto static 
+ 10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 
+ 
+ [regression potential]
+ 
+ adjusting how networkd works always carries the risk of breaking
+ networking.
+ 
+ TBD detailed regression potential after analyzing fix.
+ 
+ [other info]
+ 
+ original description:
+ 
+ --
+ 
+ 
  Consider the following setup:
  
  network:
-   version: 2
-   renderer: networkd
-   ethernets:
-     ens4:
-       dhcp-identifier: mac
-       dhcp4: yes
-       dhcp4-overrides:
-         use-dns: no
-         use-ntp: no
-         send-hostname: no
-         use-hostname: no
-         use-routes: no
-       routes:
-       - to: 10.0.0.0/8
-         via: 10.50.0.1
-       optional: true
+   version: 2
+   renderer: networkd
+   ethernets:
+     ens4:
+       dhcp-identifier: mac
+       dhcp4: yes
+       dhcp4-overrides:
+         use-dns: no
+         use-ntp: no
+         send-hostname: no
+         use-hostname: no
+         use-routes: no
+       routes:
+       - to: 10.0.0.0/8
+         via: 10.50.0.1
+       optional: true
  
  Thus I only need to get the IP address by DHCP, then add some static
  routes. This setup doesn't work. Apparently `routes` keyword only works
  when using static addresses.

** Summary changed:

- Netplan ignores static routes when using DHCP
+ systemd fails to setup static routes at boot when using DHCP

** Also affects: systemd (Ubuntu Bionic)
   Importance: Undecided
       Status: New

** Also affects: systemd (Ubuntu Eoan)
   Importance: High
       Status: New

** Also affects: systemd (Ubuntu Disco)
   Importance: Undecided
       Status: New

** Changed in: systemd (Ubuntu Eoan)
       Status: New => Fix Released

** Changed in: systemd (Ubuntu Eoan)
   Importance: High => Medium

** Changed in: systemd (Ubuntu Bionic)
   Importance: Undecided => Medium

** Changed in: systemd (Ubuntu Bionic)
       Status: New => In Progress

** Changed in: systemd (Ubuntu Bionic)
     Assignee: (unassigned) => Dan Streetman (ddstreet)

** Changed in: systemd (Ubuntu Disco)
   Importance: Undecided => Medium

** Changed in: systemd (Ubuntu Disco)
       Status: New => In Progress

** Changed in: systemd (Ubuntu Disco)
     Assignee: (unassigned) => Dan Streetman (ddstreet)

-- 
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/1836695

Title:
  systemd fails to setup static routes at boot when using DHCP

Status in netplan:
  Invalid
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
Status in systemd source package in Eoan:
  Fix Released

Bug description:
  [impact]

  a systemd-networkd configuration that uses ipv4 dhcp but ignores the
  dhcp-provided route, and instead sets up a static route, and also does
  not include a static ipv4 address, fails to actually create the static
  route.

  This is due to networkd attempting to set up the static route before
  the dhcp ipv4 address is assigned, and the kernel does not allow
  creation of the route before setting up corresponding ipv4 address.

  this results in a network that does have the dhcp-provided ipv4
  address, but is missing both its dhcp-provided route (because networkd
  is configured to ignore it) and the static route (because networkd was
  not able to create it).

  [test case]

  (remove or unconfigure netplan, so it will not conflict with this
  manual networkd configuration)

  create a networkd config file, e.g.:

  $ cat /etc/systemd/network/10-eth0.network 
  [Match]
  Name=eth0

  [Network]
  DHCP=ipv4

  [Route]
  Destination=10.0.0.0/8
  Gateway=10.202.51.1

  [DHCP]
  UseRoutes=false

  
  then *reboot* the system, and check that the static route was not applied:

  $ ip r
  10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 

  
  note that because networkd does not remove ipv4 addresses that it manages (including dhcpv4 addresses), restarting networkd after the initial boot
  will correctly create the static route, e.g.:

  ubuntu at lp1836695-b:~$ ip r
  10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 
  ubuntu at lp1836695-b:~$ sudo systemctl restart systemd-networkd
  ubuntu at lp1836695-b:~$ ip r
  10.0.0.0/8 via 10.202.51.1 dev eth0 proto static 
  10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.254 

  [regression potential]

  adjusting how networkd works always carries the risk of breaking
  networking.

  TBD detailed regression potential after analyzing fix.

  [other info]

  original description:

  --

  
  Consider the following setup:

  network:
    version: 2
    renderer: networkd
    ethernets:
      ens4:
        dhcp-identifier: mac
        dhcp4: yes
        dhcp4-overrides:
          use-dns: no
          use-ntp: no
          send-hostname: no
          use-hostname: no
          use-routes: no
        routes:
        - to: 10.0.0.0/8
          via: 10.50.0.1
        optional: true

  Thus I only need to get the IP address by DHCP, then add some static
  routes. This setup doesn't work. Apparently `routes` keyword only
  works when using static addresses.

To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/1836695/+subscriptions



More information about the foundations-bugs mailing list