OpenNebula / one-apps

Toolchain to build OpenNebula appliances
Apache License 2.0
12 stars 13 forks source link

one-context 6.8 / netplan breaks configs with on-link gateway #124

Open gbonfiglio opened 4 months ago

gbonfiglio commented 4 months ago

I've just upgraded my VMs to one-context 6.8 which comes with the migration from /etc/network/interfaces/ to netplan, and it seems to be breaking configurations where the gateway is on-link (outside the subnet of the main ip address).

My autogenerated /etc/network/interfaces looks like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address REDACTED.237
  network REDACTED.237
  netmask 255.255.255.255
  gateway REDACTED.232

And this is the default route it creates:

root@core:~# ip r
default via REDACTED.232 dev eth0 onlink

Autogenerated /etc/netplan/50-one-context.yaml instead looks like this:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - REDACTED.237/32
      routes:
        - to: "0.0.0.0/0"
          via: REDACTED.232
          metric: 0

With this, my VMs come up without a default route:

root@core:~# ip r
root@core:~#

I've worked the issue around by rolling back to the previous mechanism (NETCFG_TYPE="interfaces") but would be interested in figuring out a solution to make it work with netplan.

Either of the following netplan configs work for this use case. In the first, I create an additional route to tell the system REDACTED.232 is on-link, and then use REDACTED.232 as default gw as normal.

  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - REDACTED.237/32
      routes:
        - to: "REDACTED.232/32"
          on-link: true
          metric: 0
        - to: "0.0.0.0/0"
          via: REDACTED.232
          metric: 0

In the second option (probably cleaner), I directly add the on-link flag to the default route. In this config, metric: 0 doesn't seem to work (no route is created), so I bumped it to 100 (which works as intended).

  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - REDACTED.237/32
      routes:
        - to: "0.0.0.0/0"
          via: REDACTED.232
          on-link: true
          metric: 100

Netplan's reference docs (https://netplan.readthedocs.io/en/stable/netplan-yaml/) state the value of "metric" must be "a positive integer value", you might want to skip 0 as it seems to have unintended consequences in cases like the above. None of their examples (https://netplan.readthedocs.io/en/latest/examples/) has metric: 0.

A similar issue has been reported here https://forum.opennebula.io/t/debian-12-from-marketplace-netplan-does-not-apply-context-with-netplan/12008 with no solution.

gbonfiglio commented 4 months ago

As a side question - I have updated the file manually and it works but at reboot one-context does overwrite it. Is there a way to prevent this? Can't seem to find a solution in the docs.