netplan "match macaddress" messes up vlan IP addresses

Bug #1862673 reported by Brian Candler
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Netplan
New
Undecided
Unassigned

Bug Description

Using "match: macaddress:" - which is sometimes necessary (e.g. see #1724895) - causes vlan interfaces to pick up the IP address of the parent instead of the address you have defined.

To reproduce: create /etc/netplan/01-netcfg.yaml

network:
    version: 2
    renderer: networkd
    ethernets:
        ens3:
            dhcp4: false
            addresses:
                - 192.168.6.123/24
            gateway4: 192.168.6.1
            match:
                macaddress: 52:54:00:85:50:32 # << replace with your MAC address
            mtu: 9000
    vlans:
        vlan5:
            id: 5
            link: ens3
            dhcp4: false
            addresses:
                - 192.168.5.123/24

Then "netplan generate; netplan apply" (or reboot). Result:

# ip addr list | grep 192.168
    inet 192.168.6.123/24 brd 192.168.6.255 scope global ens3
    inet 192.168.6.123/24 brd 192.168.6.255 scope global vlan5

Note how vlan5 has been given the same IP address as ens3, instead of the address which was defined for it in the YAML.

WORKAROUND: adding "set-name: ens3" under the "ens3" stanza seems to make it work.

...
    ethernets:
        ens3:
            dhcp4: false
            addresses:
                - 192.168.6.123/24
            gateway4: 192.168.6.1
            match:
                macaddress: 52:54:00:85:50:32
            mtu: 9000
            set-name: ens3 # << NOTE
...

(Aside: this is a workaround to a workaround. I wouldn't have needed to match on MAC address in the first place if applying the MTU had worked without it!)

Reproduced using https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
- image downloaded on Jan 29 2020 - under kvm/libvirt, but originally seen on real hardware.

Revision history for this message
Alex Walender (awalende) wrote :

This is so annoying...

My workaround is to additionally add the driver module to the match list.
VLANs run under a generic module driver, so they don't match with the parent one.

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

@awalende: Can you click 'This bug affects me' at the top? Then it will get marked as a confirmed bug.

Revision history for this message
Marc Gariépy (mgariepy) wrote :

i guess it needs to add the type in the link file if there is a vlan set on top of the interface. to avoird trying to rename the vlan interface because it matches the MAC.

https://github.com/CanonicalLtd/netplan/blob/master/src/networkd.c#L101

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.