← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2000596] Re: Netplan: Improve support for directly (on-link) connected gateways

 

This bug is believed to be fixed in cloud-init in version 23.1. If this
is still a problem for you, please make a comment and set the state back
to New

Thank you.

** Changed in: cloud-init
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/2000596

Title:
  Netplan: Improve support for directly (on-link) connected gateways

Status in cloud-init:
  Fix Released

Bug description:
  Hi,
  I am having trouble configuring my directly connected IPv6 gateway via cloud-init when generating configuration for Netplan.

  I'll focus on IPv6 but I think IPv4 shares the same code. Let's assume my network_data.json contains the following network (and *no* extra routes):
  "ip_address": "2001:cafe::/64",
  "gateway": "2001:ffff::"

  
  First off, let me explain what works with other renderers.
  On AlmaLinux 9, the sysconfig renderer generates an ifcfg file that, when read by NetworkManager, result in one route to reach the gateway and a default route, something like this:
  2001:ffff:: dev eno1 proto static metric 100 pref medium
  default via 2001:ffff:: dev eno1 proto static metric 100 pref medium

  
  On Debian 11, the eni renderer generates a working configuration too, because ifupdown always adds the "onlink" flag to the gateway, see https://salsa.debian.org/debian/ifupdown/-/commit/8b7bca9597d2f75670b182f0fc149cdbaec3544c.
  I get something like this:
  default via 2001:ffff:: dev eno1 metric 1024 onlink pref medium

  However, on Ubuntu 22.10, no route gets created. This is because Netplan acts as a thin wrapper for systemd-networkd, so it doesn't try to automatically guess that the route is on-link.
  The resulting Netplan config looks like:
  gateway6: 2001:ffff::

  Which Netplan turns into a systemd-networkd .network that contains this:
  [Network]
  […]
  Gateway=2001:ffff::

  systemd-networkd debug logs show:
  eno1: Requesting static route (n/a): dst: n/a, src: n/a, gw: 2001:ffff::, prefsrc: n/a, scope: global, table: main(254), proto: static, type: unicast, nexthop: 0, priority: 1024, flags: n/a

  In order to get a working route via cloud-init, I had to add a route to the gateway in my network_data.json:
   "routes": [
  	{
  	   "network": "2001:ffff::",
  	   "netmask": 128,
  	   "gateway": "::0"
  	}
   ],

  This way, I get a behaviour similar to AlmaLinux 9's: one route to the
  gateway in addition to the default route.

  What I would like to see is an option to generate this kind of Netplan config:
  routes:
    - to: default
      via: 2001:ffff::
      on-link: true

  This results in the following .network file:
  [Route]
  Destination=::/0
  Gateway=2001:ffff::
  GatewayOnLink=true

  Logs show:
  eno1: Configuring static route (requesting): dst: n/a, src: n/a, gw: 2001:ffff::, prefsrc: n/a, scope: global, table: main(254), proto: static, type: unicast, nexthop: 0, priority: 1024, flags: onlink
  And the route looks like this:
  default via 2001:ffff:: dev eno1 proto static metric 1024 onlink pref medium

  I don't know how cloud-init could handle this, maybe it could perform some kind of check:
  if gateway not in ip_subnet:
      # add on-link to config

  If this is acceptable, I can file a PR that does it. It'll require
  migrating away from the deprecated "gateway4" and "gateway6" options
  (https://github.com/canonical/netplan/commit/7844058dde8e2df4c6b45d4f08d82832d7932bab)
  but I don't think that is a problem, we can specify the gateways
  manually in Netplan's "routes" section.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/2000596/+subscriptions



References