Skip to content

GATEWAY_IFACE not implemented in netplan and networkd network backends #329

Description

@jsfrerot

GATEWAY_IFACE was introduced in 2014 to allow users to designate which NIC should carry the default route when multiple NICs with gateways are defined (originally tracked in https://dev.opennebula.org/issues/2927 and implemented in OpenNebula/addon-context-linux#2).

The feature was implemented for the interfaces (ifupdown/Debian) and rhel backends, but was never ported to the netplan and networkd backends which are now the standard on modern distributions (Ubuntu 18.04+, Debian 12+).

Affected backends:

  • netcfg-netplan — no GATEWAY_IFACE handling in gen_routes()
  • netcfg-networkd — no GATEWAY_IFACE handling

Environment

  • one-context version: 7.0.1
  • OS: Ubuntu 24.04 (uses netplan backend)
  • OpenNebula: 7.0.1

To Reproduce

  1. Create a VM with 2 NICs, each on a different network with a gateway defined
  2. Set GATEWAY_IFACE="ETH0" in the VM context
  3. Boot the VM
  4. Run ip r — both NICs have a default route despite GATEWAY_IFACE being set

default via 10.211.8.1 dev enp3s0 proto static
default via 10.211.80.1 dev enp4s0 proto static

Expected Behavior

Only the designated interface (ETH0) should have a default route:

default via 10.211.8.1 dev enp3s0 proto static
10.211.80.0/22 dev enp4s0 proto kernel scope link src 10.211.80.22

Suggested Fix

In netcfg-netplan, the gen_routes() function should check GATEWAY_IFACE before adding a 0.0.0.0/0 route:

  # Only add default route if this interface is the designated gateway interface
  if [ -n "$gateway" ]; then
      if [ -z "$GATEWAY_IFACE" ] || [ "$(echo $GATEWAY_IFACE | tr '[:upper:]' '[:lower:]')" = "eth${index}" ]; then
          # add default route
      fi
  fi

Same fix should be applied to netcfg-networkd.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions