Netplan says "interface is not defined" when bridge uses "routes" instead of "gateway4"

Bug #2000324 reported by Brian Candler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan.io (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

In netplan, gateway4 and gateway6 have been deprecated, and you're supposed to use "routes" instead. But this fails with a bridge interface.

===== Working configuration =====

network:
    bridges:
        br0:
            accept-ra: false
            addresses:
            - 100.64.0.250/22
            interfaces:
            - ens3
            nameservers:
                addresses:
                - 100.64.0.1
            parameters:
                forward-delay: 0
                stp: false
            gateway4: 100.64.0.1
    ethernets:
        ens3: {}
    version: 2

===== Broken configuration =====

network:
    bridges:
        br0:
            accept-ra: false
            addresses:
            - 100.64.0.250/22
            interfaces:
            - ens3
            nameservers:
                addresses:
                - 100.64.0.1
            parameters:
                forward-delay: 0
                stp: false
            routes:
            - to: 0/0
                via: 100.64.0.1
    ethernets:
        ens3: {}
    version: 2

The only difference is "gateway4" changed to "routes". With the second configuration, Netplan gives the following error:

root@noc:/etc/netplan# netplan generate
/etc/netplan/50-cloud-init.yaml:8:15: Error in network definition: br0: interface 'ens3' is not defined
            - ens3
              ^
root@noc:/etc/netplan#

As a result, the interface is not configured.

WORKAROUND: retain the deprecated gateway4: setting, as well as any additional routes you require. For example, the following is accepted (albeit with noisy deprecation warning):

            gateway4: 100.64.0.1
            routes:
            - to: 128.0.0.0/1
                via: 100.64.0.1

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: netplan.io 0.105-0ubuntu2~22.04.1
ProcVersionSignature: Ubuntu 5.15.0-56.62-generic 5.15.64
Uname: Linux 5.15.0-56-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.3
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Thu Dec 22 15:50:59 2022
ProcEnviron:
 TERM=vt220
 PATH=(custom, no user)
 LANG=C.UTF-8
 SHELL=/bin/bash
SourcePackage: netplan.io
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Brian Candler (b-candler) wrote :
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

Thanks for your bug report.

Using 'to: 0/0' is not really supported by Netplan (although the documentation says it is). It was removed from the docs recently [1] but it wasn't updated yet.

Can you try using 'to: default' or 'to: 0.0.0.0/0' instead? It works for me.

Now, reporting that the ethernet interface is missing because of an invalid value in a non-related field is certainly not the desired behavior. I will look at it.

[1] https://github.com/canonical/netplan/commit/53e33fc716be10498f2fe789114e9339a38b281d

Revision history for this message
Brian Candler (b-candler) wrote :

Ha. Yes, with 0.0.0.0/0 it works. Thank you!

Revision history for this message
Lukas Märdian (slyon) wrote :

You could also be using "default" instead of "0.0.0.0/0".

Thanks for confirming this fixes the problem for you!

Changed in netplan.io (Ubuntu):
status: New → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package netplan.io - 0.106-0ubuntu1

---------------
netplan.io (0.106-0ubuntu1) lunar; urgency=medium

  * New upstream release: 0.106
    - New 'netplan status' CLI (#290)
    - API: implement APIs from the new specification (#298)
    - Check and fix non-inclusive laguange (#303)
    - Documentation improvements (using Diátaxis & RTD)
    - Match by PermanentMACAddress (#278)
    - Netplan api iterator (#306)
    - API: update netplan_delete_connection() (#322)
    - NM 1.40 compat & file permission fixes (#300), LP: #1862600, LP: #1997348
    - Migrate from (deprecated) nose to pytest (#302)
    - parse: Add the filepath to OVS ports netdefs (#295)
    - Check if the interface name is too long (#313), LP: #1988749
    - doc/examples: remove unnecessary route for IPv6 on-link gateways (#312)
    - Memory leak CI action (#321)
    - tests:base:ethernets: Improve stability of autopkgtests (#223)
    Bug fixes:
    - Fix some memory leaks (#297)
    - parser: plug a memory leak (#309)
    - src:parse: plug memory leaks in nullable handling (#319)
    - Fix 'netplan ip leases' crash (#301), LP: #1996941
    - tests: mock calls to systemctl (#314)
    - ctests: fix an integer conversion issue (#315)
    - docs: small fix on netplan-set doc (#316)
    - parser: return the correct error on failure (#308), LP: #2000324
    - apply: Fix crash when OVS is stopped (#307),LP: #1995598
    - networkd: make sure VXLAN is in the right section (#310), LP: #2000713
    - cli:set: update only specific origin-hint if given (#299), LP: #1997467
    - vxlan: convert some settings to tristate (#311), LP: #2000712
    - parser: check for route duplicates (#320), LP: #2003061
  * Update symbols file for 0.106
  * d/patches/: Drop patches, applied upstream
  * d/control: bump Standards-Version to 4.6.2, no changes needed
  * d/t/control: prepare Debian testbed
  * d/control: Add python3-dbus, python3-rich deps, also CMocka and Pytest B-Ds
  * d/watch: fix checking for upstream tags
  * d/copyright: update for 2023
  * d/source/: add lintian-overrides

 -- Lukas Märdian <email address hidden> Thu, 09 Feb 2023 12:10:19 +0100

Changed in netplan.io (Ubuntu):
status: Invalid → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.