You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Launchpad user Louis Sautier(lesbraz) wrote on 2022-12-27T20:07:44.718227+00:00
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
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::
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 (canonical/netplan@7844058) but I don't think that is a problem, we can specify the gateways manually in Netplan's "routes" section.
The text was updated successfully, but these errors were encountered:
Launchpad user Alberto Contreras(aciba) wrote on 2023-02-22T16:52:40.695982+00:00
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
This bug was originally filed in Launchpad as LP: #2000596
Launchpad details
Launchpad user Louis Sautier(lesbraz) wrote on 2022-12-27T20:07:44.718227+00:00
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:
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 (canonical/netplan@7844058) but I don't think that is a problem, we can specify the gateways manually in Netplan's "routes" section.
The text was updated successfully, but these errors were encountered: