Cheat Sheets

Netplan VLAN, Bridge and Bond Cheat Sheet for Ubuntu (PDF)

netplan try refuses any bond or bridge that carries a parameters: block, which is exactly the config where a rollback timer would help most. On our test box it printed “reverting custom parameters for bridges and bonds is not supported” and changed nothing, so the bond had to go in with netplan apply. That one behaviour decides how you sequence every remote network change on Ubuntu Server.

Original content from computingforgeeks.com - post 128881

This netplan cheat sheet covers the five subcommands you actually type, from try to status. It also holds the YAML for static IPs, a netplan VLAN, active-backup bonds, bridges for KVM guests and the NetworkManager renderer. Every row was run between two virtual machines on a shared L2 segment that carried 802.1Q tags, and the bond failed over with 1 lost ping out of 30 (December 2026, lab run on Ubuntu 26.04 with netplan 1.2, with Ubuntu 24.04 as the peer).

Netplan Cheat Sheet (Quick Reference)

The tables below are the whole sheet. The netplan subcommands that read or write the config need sudo, while ip, bridge and the /proc reads do not, and every YAML key goes under network: in a file in /etc/netplan/. The sections after the tables show the files we ran and the output they produced.

Apply, test and inspect

CommandWhat it does
sudo netplan tryApply, then revert after 120 s unless you press ENTER
sudo netplan try --timeout 15Same, with a 15 second window
sudo netplan applyApply for good, no rollback
sudo netplan generateValidate YAML and write backend files to /run
sudo netplan status ens4Addresses, routes and DNS of one interface
sudo netplan status --diff-onlyOnly what differs between YAML and the system
sudo netplan ip leases ens3DHCP lease of a networkd interface
netplan infoFeature flags of the installed netplan

Read and edit keys from the shell

CommandWhat it does
sudo netplan get ethernets.ens4Merged config of one device from all files
sudo netplan get bondsEvery bond definition
sudo netplan set --origin-hint 60-static ethernets.ens4.mtu=9000Write a key into 60-static.yaml
sudo netplan set --origin-hint 60-static ethernets.ens4.mtu=nullDelete a key
sudo netplan set --origin-hint 60-bond "vlans.vlan46={id: 46, link: bond0, addresses: [10.0.46.52/24]}"Create a whole device in one call

Static IP keys

YAML keyWhat it does
dhcp4: falseTurn off DHCPv4 on the device
addresses: [10.0.1.51/24]Address with prefix length
routes: [{to: default, via: 10.0.1.1}]Default route (replaces gateway4)
metric: 200Route priority inside a route entry, lower wins
nameservers: {addresses: [10.0.1.1]}DNS servers for the link
search: [lab.example.com]DNS search domain, under nameservers
mtu: 9000Jumbo frames on the device

VLAN

Key or commandWhat it does
vlans: {vlan45: {id: 45, link: ens4}}Tagged sub-interface for VLAN 45 on ens4
link: bond0Put the VLAN on a bond instead of a NIC
ip -d link show vlan45Confirm 802.1Q and the VLAN id
sudo tcpdump -nei ens4 -c 2 vlan 45See tagged frames on the parent NIC
sudo ip link delete vlan45Drop a stale VLAN before apply recreates it

Bond

Key or commandWhat it does
bonds: {bond0: {interfaces: [ens4, ens5]}}Bond two NICs, list them under ethernets too
mode: active-backupOne NIC carries traffic, the other waits
primary: ens4Preferred NIC in active-backup
mii-monitor-interval: 100Check link state every 100 ms
cat /proc/net/bonding/bond0Active slave, MII status, failure counts

Bridge

Key or commandWhat it does
bridges: {br0: {interfaces: [bond0]}}Bridge that VMs attach to; the IP moves here
bridges: {br45: {interfaces: [vlan45]}}One bridge per VLAN for guests
stp: falseNo spanning tree on a host bridge
forward-delay: 0Forward frames as soon as a port joins
bridge linkPorts and the bridge each belongs to

NetworkManager renderer

Key or commandWhat it does
renderer: NetworkManagerHand one device to NetworkManager; directly under network: it applies to all
nmcli -f NAME,TYPE,DEVICE,FILENAME connection showProfiles named netplan-<device>
ls -l /etc/netplan/nmcli edits land in 90-NM-<uuid>.yaml
sudo netplan get vlans.vlan46.addressesMerged result of your file and the 90-NM file

Errors and fixes

MessageFix
expected mapping (check indentation)Indent keys two spaces under the device name
vlan46: missing 'link' propertyAdd link: with the parent NIC or bond
`gateway4` has been deprecatedUse routes: with to: default
Permissions ... are too opensudo chmod 600 /etc/netplan/*.yaml
reverting custom parameters for bridges and bonds is not supportedReview the YAML, then sudo netplan apply

Read the last error row before you change a bond or bridge over SSH. Once any bond or bridge in the merged config has a parameters block, netplan try refuses every change on that host, so the console or out-of-band access has to be ready first. In our lab four changes went through try with its rollback window: the static address on ens4, the VLAN on ens4, the plain bridge without parameters and the NetworkManager file. The bond, the bridges with parameters, the extra default route and the set mapping went in with apply.

Step 1: Check the netplan version and the lab layout

Two virtual machines ran every command: bench01 on Ubuntu 26.04 and bench02 on Ubuntu 24.04. Each has three NICs. ens3 holds the management address from DHCP and the default route, while ens4 and ens5 sit on a host bridge that passes 802.1Q tags, the same job a trunk port on a managed switch does.

Netplan architecture diagram: br0 and br45 on top of bond0 (ens4 primary, ens5 backup) with vlan45 802.1Q id 45, linked to bench02 over the labsw0 trunk

That is the layout Step 6 ends on: the addresses sit on br0 and br45, bond0 and vlan45 carry none, and bench02 answers on both networks through the same trunk. Steps 2 to 6 build it one layer at a time. The test addresses follow.

  • Untagged LAN 10.0.1.0/24: bench01 is 10.0.1.51, bench02 is 10.0.1.52, the gateway in the YAML is 10.0.1.1.
  • VLAN 45, 10.0.45.0/24: .51 and .52, managed by systemd-networkd on both hosts.
  • NetworkManager section, own addressing: bench01 ens5 at 10.0.1.61 and VLAN 46 at 10.0.46.61, kept apart so the two renderers never share a device.

Swap in your own NIC names and subnets, which ip -br link lists. Start by confirming the netplan build, because netplan status and netplan set only exist on recent releases, and a tutorial written for an older build will not match what you see.

dpkg-query -W netplan.io systemd

Ubuntu 26.04 reported netplan 1.2 and systemd 259. Netplan hands most of the work to systemd-networkd, so the systemd version matters as much as the netplan one when a key behaves differently between hosts.

netplan.io	1.2-1ubuntu5.1
systemd	259.9-0ubuntu0.1

Ubuntu 24.04 shipped 1.1.2-8ubuntu1~24.04.3 with systemd 255. Ubuntu 26.04 ran the full sheet. Ubuntu 24.04 ran the static IP peer, the VLAN peer with the tcpdump check, the bond try refusal, netplan get and status and the failed partial netplan set; the comparison table at the end lists what was not repeated there. Before writing anything, look at what cloud-init already put in place, since your new files merge with it.

sudo cat /etc/netplan/50-cloud-init.yaml

Only ens3 is defined, matched by MAC and set to DHCP. The other two NICs show as unmanaged in netplan status until a file names them, so nothing below can collide with the management link.

network:
  version: 2
  ethernets:
    ens3:
      match:
        macaddress: "52:54:00:00:01:00"
      dhcp4: true
      dhcp6: true
      set-name: "ens3"

Leave 50-cloud-init.yaml alone and put each change in its own numbered file. Netplan reads /etc/netplan/*.yaml in lexical order and merges them, so a 60- file overrides keys from the 50- file without editing it, and a cloud-init rerun cannot wipe your work.

Step 2: Set a static IP and test it with netplan try

A static address is the safest change to learn netplan try on, because a mistake costs one interface and the management link stays up. Create the file in its own slot after cloud-init.

sudo vim /etc/netplan/60-static.yaml

This is the file bench01 ran. It sets the address, a static route to a second subnet and DNS for this link only. There is no default route here because ens3 already holds one from DHCP; Step 3 adds a second default with a higher metric.

network:
  version: 2
  ethernets:
    ens4:
      dhcp4: false
      addresses:
        - 10.0.1.51/24
      routes:
        - to: 10.0.20.0/24
          via: 10.0.1.1
      nameservers:
        addresses: [10.0.1.1, 1.1.1.1]
        search: [lab.example.com]

Netplan warns when a file is readable by other users, so lock the mode down before testing. The warning does not stop anything, which is why it is easy to miss in a long apply run.

sudo chmod 600 /etc/netplan/60-static.yaml

Now apply it on a timer. netplan try brings the config up, then waits 120 seconds for ENTER. No ENTER, and it puts the previous runtime state back, which is what saves you when the new address cuts your own SSH session.

sudo netplan try

We pressed ENTER inside the window, then checked the address and pinged the peer. The round trip averaged 0.488 ms across 3 packets.

sudo netplan try accepting a static IP on ens4 on Ubuntu 26.04, then ping to 10.0.1.52 with 0% loss

The static route landed as well. ip route show dev ens4 printed 10.0.20.0/24 via 10.0.1.1 proto static next to the connected 10.0.1.0/24 route, which is the check that matters if your second subnet sits behind a different router.

The revert path is where people get caught. We changed the address to 10.0.1.99 in the file and let a 15 second try run out without pressing anything.

sudo netplan try --timeout 15

Netplan printed Reverting. and ens4 went back to 10.0.1.51. The YAML on disk still said 10.0.1.99.

netplan try --timeout 15 reverting the runtime address while the edited YAML keeps 10.0.1.99 on disk

So try rolls back the running state only. The next netplan apply, or the next reboot, applies the file you thought was rolled back. After a revert, fix or restore the YAML straight away; keeping a copy of the file before you edit it makes that a one-line cp. For the full static IP walkthrough with a default gateway, see our guide to set a static IP on Ubuntu 26.04 with netplan.

Step 3: Read and change keys with netplan get and netplan set

netplan get prints the merged view of every file, which is what the backend actually receives. With three or four files in /etc/netplan/, that merged view is the only reliable answer to which address a device will get. Read the device we just configured.

sudo netplan get ethernets.ens4

Keys come back in the order netplan stores them, with strings quoted, not in the order of your file.

addresses:
- "10.0.1.51/24"
nameservers:
  addresses:
  - 10.0.1.1
  - 1.1.1.1
  search:
  - lab.example.com
dhcp4: false
routes:
- to: "10.0.20.0/24"
  via: "10.0.1.1"

netplan set writes a key without opening an editor, validates the result and refuses anything that would not parse. --origin-hint names the file the change goes into, given without the .yaml suffix. Set jumbo frames on ens4 in our static file:

sudo netplan set --origin-hint 60-static ethernets.ens4.mtu=9000

Reading the key back returned 9000, and the file itself had been rewritten. The flow-style lists from Step 2 became block style, the strings gained quotes, and mtu: 9000 sat between dhcp4 and routes.

network:
  version: 2
  ethernets:
    ens4:
      addresses:
      - "10.0.1.51/24"
      nameservers:
        addresses:
        - 10.0.1.1
        - 1.1.1.1
        search:
        - lab.example.com
      dhcp4: false
      mtu: 9000
      routes:
      - to: "10.0.20.0/24"
        via: "10.0.1.1"

Treat set as the owner of any file it touches: hand formatting does not survive, so a file you curate by hand is better edited with vim. Setting a key to null deletes it, which is how we removed the MTU again.

sudo netplan set --origin-hint 60-static ethernets.ens4.mtu=null

Lists take YAML flow syntax inside quotes, and the value replaces the whole list rather than appending to it. This call wrote a default route at metric 200 plus the original static route, then applied it.

sudo netplan set --origin-hint 60-static "ethernets.ens4.routes=[{to: default, via: 10.0.1.1, metric: 200}, {to: 10.0.20.0/24, via: 10.0.1.1}]"
sudo netplan apply
ip route show | grep -E "default|10.0.20"

The kernel now holds two default routes. The DHCP one on ens3 has metric 100 and wins; ours at 200 only takes over if ens3 loses its lease, which is the setup you want for a backup uplink.

default via 10.0.2.2 dev ens3 proto dhcp src 10.0.2.15 metric 100
default via 10.0.1.1 dev ens4 proto static metric 200
10.0.20.0/24 via 10.0.1.1 dev ens4 proto static 

On a server whose only uplink is ens4, drop the metric and that route becomes the default. The one call set cannot make is a partial new device. We ran this test on bench02 after Step 5, when bond0 and 60-bond.yaml already existed, and tried to create a VLAN key by key. On a host without a bond, use link: ens4 and --origin-hint 70-vlan instead.

sudo netplan set --origin-hint 60-bond vlans.vlan46.id=46

Netplan validates after every call, and a VLAN with an id but no parent is invalid, so the first key of the new device was rejected and nothing was written.

Command failed: Error in network definition: vlan46: missing 'link' property

Pass the whole mapping in one call instead. This created VLAN 46 on the bench02 bond and brought it up with its address. The parent in link must already be defined in some netplan file, or the call fails the same validation.

sudo netplan set --origin-hint 60-bond "vlans.vlan46={id: 46, link: bond0, addresses: [10.0.46.52/24]}"
sudo netplan apply

ip -br addr show vlan46 returned vlan46@bond0 UP 10.0.46.52/24 two seconds later. That interface is the peer for the NetworkManager test in Step 7.

Step 4: Create a netplan VLAN interface

An Ubuntu netplan VLAN needs three keys: a name, the 802.1Q id and the parent in link. The parent keeps its own untagged address, so one NIC serves both networks. The switch port facing the server has to be a trunk that carries VLAN 45 tagged; on an unmanaged switch the tagged frames go nowhere. Create the file.

sudo vim /etc/netplan/70-vlan.yaml

bench01 used the file below, and bench02 the same with 10.0.45.52/24. The VLAN gets its own file so it can be removed later without touching the parent NIC.

network:
  version: 2
  vlans:
    vlan45:
      id: 45
      link: ens4
      addresses:
        - 10.0.45.51/24

Set the mode to 600 as before, then run sudo netplan try and press ENTER once the peer answers. The kernel created vlan45@ens4 with the MAC of its parent, and three pings across the tagged link averaged 0.526 ms.

ip -d link show vlan45 showing 802.1Q id 45 on ens4 created by netplan, with ping across the VLAN

A working ping does not prove the frames are tagged, because a misconfigured lab can pass untagged traffic just as well. Capture on the parent NIC of the peer and filter on the VLAN.

sudo tcpdump -nei ens4 -c 2 vlan 45

bench02 saw an ARP request and reply with ethertype 802.1Q (0x8100) and vlan 45 in every frame, 46 bytes each. On real hardware, run the same capture on the server when a VLAN pings nothing: tagged requests with no replies point at the switch trunk, not at netplan.

tcpdump on the Ubuntu 24.04 peer showing 802.1Q tagged ARP frames on vlan 45

The older version of this page used vlan.45 as the name and put id at the same indent as the name, which netplan rejects; the exact error is in the troubleshooting section. Any name works, but vlan45 keeps the id readable in ip output. Our VLAN interface guide for Ubuntu with netplan adds several VLANs on one NIC and DHCP on a VLAN.

Step 5: Build an active-backup bond with a VLAN on top

An active-backup bond needs no switch configuration, which makes it the default choice for two uplinks to separate switches. The VLAN from Step 4 moves onto the bond so it survives a NIC failure. This step has no rollback timer, so work from the console or a NIC outside the bond. Remove 60-static.yaml and 70-vlan.yaml first, since their ens4 addresses now belong to the bond, then create the bond file.

sudo vim /etc/netplan/60-bond.yaml

The member NICs must appear under ethernets, even empty, or netplan does not know them. The empty {} also keeps any address off the members, which is what a bond expects.

network:
  version: 2
  ethernets:
    ens4: {}
    ens5: {}
  bonds:
    bond0:
      interfaces: [ens4, ens5]
      addresses:
        - 10.0.1.51/24
      parameters:
        mode: active-backup
        primary: ens4
        mii-monitor-interval: 100
  vlans:
    vlan45:
      id: 45
      link: bond0
      addresses:
        - 10.0.45.51/24

Here netplan try stops working. It printed the same refusal for bond0 on both Ubuntu releases, and on 26.04 the old ens4 config stayed in place, so the bond went in with apply. The second gotcha showed on bench02: apply does not move an existing VLAN to a new parent. After the first apply, ip -d link show vlan45 still listed vlan45@ens4, so we deleted it and applied again. On bench01 we deleted the VLAN before the apply, which is the order the screenshot shows and the one to use.

sudo rm -f /etc/netplan/60-static.yaml /etc/netplan/70-vlan.yaml
sudo ip link delete vlan45
sudo netplan apply

Within three seconds bench01 listed bond0 with 10.0.1.51 and vlan45@bond0 with 10.0.45.51, and pings to the peer on both networks came back.

netplan try refusing a bond with custom parameters, then netplan apply bringing up bond0 and vlan45 on bond0

Deleting the VLAN drops its traffic for a moment, so do it from the console or over the management NIC, never over the VLAN itself. Also note the MAC of the bond. netplan status bond0 reported ca:0c:57:18:85:11, a generated address rather than the 52:54:00:00:01:01 of ens4. A DHCP reservation or a switch port-security entry keyed on the NIC’s MAC will not match. Add macaddress: under bond0 if you need it fixed.

To measure failover, we pinged the peer on VLAN 45 every 200 ms and took the primary NIC down two seconds in. Pinging across the VLAN rather than the untagged bond tests the whole stack at once.

(ping -c 30 -i 0.2 10.0.45.52 > /tmp/p.txt &) ; sleep 2
sudo ip link set ens4 down; sleep 5
grep -E "Currently Active|^Slave Interface|MII Status|Link Failure" /proc/net/bonding/bond0
tail -2 /tmp/p.txt
sudo ip link set ens4 up

ens5 took over and 29 of 30 pings came back, a 3.3% loss. That is one lost probe at 200 ms spacing, with the MII check running every 100 ms.

active-backup bond failing over from ens4 to ens5 with one lost ping out of 30

Bringing ens4 back up made it the active slave again within two seconds. The bond reported Primary Slave: ens4 (primary_reselect always), so it returns to the primary whenever that link is up. On a link that flaps, that means a failover each way per flap, and dropping primary removes the preferred NIC the bond returns to. LACP (mode: 802.3ad) needs a matching port channel on the switch; our managed switch picks for a homelab all support LACP and tagged trunks.

Step 6: Bridge a bond and a VLAN for KVM guests

A VM host puts a bridge on each network its guests join. The host IP moves from the NIC to the bridge, and the tap device of each guest becomes another bridge port. We tested the plain bridge first, one bridge on ens4 and one on VLAN 45, with no parameters block. ens4 cannot sit in a bond and a bridge at once. For this test we removed 60-bond.yaml from the console, ran sudo ip link delete vlan45 and sudo ip link delete bond0, and saved the file below as /etc/netplan/60-bridge.yaml with mode 600.

network:
  version: 2
  ethernets:
    ens4: {}
  vlans:
    vlan45:
      id: 45
      link: ens4
  bridges:
    br0:
      interfaces: [ens4]
      addresses:
        - 10.0.1.51/24
    br45:
      interfaces: [vlan45]
      addresses:
        - 10.0.45.51/24

That file went through sudo netplan try and was accepted, and pings across both bridges averaged under 0.57 ms. Adding a single parameter changed that. After netplan set bridges.br0.parameters.stp=false, try printed br0: reverting custom parameters for bridges and bonds is not supported and stopped. The production layout, bridges on top of the bond from Step 5, has parameters on both, so it goes in with apply. From the console, remove 60-bridge.yaml and delete the devices it made, because apply will not re-parent them.

sudo rm /etc/netplan/60-bridge.yaml
sudo ip link delete br0
sudo ip link delete br45
sudo ip link delete vlan45
sudo vim /etc/netplan/60-kvmhost.yaml

The addresses leave bond0 and vlan45 and move to the bridges. STP is off and forward delay is zero, so a new guest port forwards as soon as it joins instead of waiting in the listening state.

network:
  version: 2
  ethernets:
    ens4: {}
    ens5: {}
  bonds:
    bond0:
      interfaces: [ens4, ens5]
      parameters:
        mode: active-backup
        primary: ens4
        mii-monitor-interval: 100
  vlans:
    vlan45:
      id: 45
      link: bond0
  bridges:
    br0:
      interfaces: [bond0]
      addresses:
        - 10.0.1.51/24
      parameters:
        stp: false
        forward-delay: 0
    br45:
      interfaces: [vlan45]
      addresses:
        - 10.0.45.51/24
      parameters:
        stp: false
        forward-delay: 0

After sudo netplan apply, bridge link showed bond0 as a port of br0 and vlan45@bond0 as a port of br45, both forwarding. Pings on each network returned 3 of 3.

netplan bridges br0 and br45 on top of bond0 and vlan45 for a KVM host, shown with bridge link

Point a libvirt guest at br45 and it lands on VLAN 45 untagged, with no VLAN config inside the guest. The older version of this page installed bridge-utils for brctl; netplan does not need it, and bridge link from iproute2 shows the same ports. Our KVM install guide for Ubuntu covers attaching guests to a bridge.

Step 7: Hand a NIC and VLAN to NetworkManager

renderer: NetworkManager works per device, so one host can run networkd on its server NICs and NetworkManager on another. Ubuntu Server does not ship NetworkManager, so install it first. The network-manager package put version 1.54.3 on our 26.04 host, per dpkg-query -W network-manager.

sudo apt update
sudo apt install -y network-manager

This section uses its own addresses on ens5 and VLAN 46, apart from the networkd interfaces above, so a mistake here cannot break the links we already tested. ens5 must be free first. On bench01 we removed 60-kvmhost.yaml, deleted br0, br45, vlan45 and bond0 from the console, and put the Step 2 60-static.yaml back, so ens4 carried the host address and ens5 had none. The peer side, vlan46 on bench02, has to exist before the ping can answer.

sudo vim /etc/netplan/65-nm.yaml

Each device carries its own renderer key. Netplan writes a NetworkManager keyfile per device under /run instead of a networkd unit.

network:
  version: 2
  ethernets:
    ens5:
      renderer: NetworkManager
      addresses:
        - 10.0.1.61/24
  vlans:
    vlan46:
      renderer: NetworkManager
      id: 46
      link: ens5
      addresses:
        - 10.0.46.61/24

This change has no bond or bridge parameters, so sudo netplan try works and we accepted it. NetworkManager then listed netplan-ens5 and netplan-vlan46, and the VLAN reached 10.0.46.52 on bench02 with 0% loss over 3 pings. The screenshot also shows what happens when someone edits the profile with nmcli.

netplan NetworkManager renderer profiles netplan-ens5 and netplan-vlan46 and an nmcli change merged back into netplan

We expected nmcli connection modify ... ipv4.addresses 10.0.46.62/24 to replace the address. It added one. NetworkManager wrote the change to a new file, /etc/netplan/90-NM-c9340c0b-....yaml, and left 65-nm.yaml untouched, so netplan merged both address lists.

  • Result on the wire: vlan46 held 10.0.46.61 and 10.0.46.62, and a netplan apply afterwards kept both.
  • Clean fix: make the change in 65-nm.yaml and delete the 90-NM- file, or manage that device only through nmcli from then on.

Pick one tool per device and stick to it. If NetworkManager is going to own a machine outright, our nmcli cheat sheet has the profile commands, and the NetworkManager setup guide for Ubuntu and Debian covers switching the whole server over.

Step 8: Read netplan status and the generated files

netplan status shows the live state of an interface together with the backend that owns it. On our build it took one interface per call, and given three names it printed only br45. Check one device at a time.

sudo netplan status br45

The header line names the owner (networkd: br45), and the Interfaces line lists the bridge ports. Devices that no netplan file names show unmanaged there instead.

     Online state: online
    DNS Addresses: 127.0.0.53 (stub)
       DNS Search: .

● 13: br45 bridge UP (networkd: br45)
      MAC Address: 86:8f:54:99:a3:22
        Addresses: 10.0.45.51/24
                   fe80::848f:54ff:fe99:a322/64 (link)
           Routes: 10.0.45.0/24 from 10.0.45.51 (link)
                   fe80::/64 metric 256
       Interfaces: vlan45

7 inactive interfaces hidden. Use "--all" to show all.

For drift between the YAML and the running system, --diff-only prints only the mismatches. A + means present on the system but not in netplan, a - the reverse.

sudo netplan status --diff-only

With the bridge config applied, the only differences were the loopback, which netplan never manages, and a DHCPv6 placeholder on ens3.

+ ●  1: lo ethernet UNKNOWN/UP (unmanaged)

  ●  2: ens3 ethernet UP (networkd: ens3)
-           Addresses: ::/0 (dhcp)

The diff compares addresses, routes, DNS, MAC addresses, bond and bridge membership and missing interfaces, but not which parent a VLAN sits on. After moving a VLAN, check the @parent part of ip -d link show vlan45 instead, which is how bench02 showed the stale vlan45@ens4 in Step 5. When you need to see what netplan handed to the backend, read the generated units. netplan ip leases prints a networkd DHCP lease on the same host.

sudo netplan ip leases ens3
ls /run/systemd/network/

The lease came back with a 1 day lifetime from 10.0.2.2, and the directory held one 10-netplan-*.network file per configured device.

# This is private data. Do not parse.
ADDRESS=10.0.2.15
NETMASK=255.255.255.0
ROUTER=10.0.2.2
SERVER_ADDRESS=10.0.2.2
NEXT_SERVER=10.0.2.2
T1=12h
T2=21h
LIFETIME=1d
DNS=10.0.2.3
CLIENTID=ffb55e67ff00020000ab111984acda32799d86
10-netplan-ens3.link
10-netplan-ens3.network
10-netplan-ens4.network
zzzz-dracut-default.network

Those files live in /run and are rebuilt on every boot and every netplan generate, so never edit them. They are the place to confirm what netplan did, while the fix always goes into /etc/netplan/.

Step 9: Fix netplan generate errors

sudo netplan generate parses every file without touching the network, so run it after each edit and before try or apply. Two of the four messages below are hard errors with exit code 1. The other two are warnings with exit code 0 that still let a bad file through, so a script that only checks the exit code misses them.

netplan generate errors: expected mapping, missing link property, gateway4 deprecated and permissions too open

Only the indentation error carries a line and column, and the caret points at the device name whose value netplan expected to be a mapping; the keys that are wrong sit on the lines just below it. Each message has its own fix below, in the order the screenshot shows them.

Error in network definition: expected mapping (check indentation)

This came from the VLAN YAML the old version of this page printed, where the VLAN keys sat at the same indent as the vlan.45 name.

network:
  version: 2
  renderer: networkd
  vlans:
     vlan.45:
     id: 45
     link: ens4
     addresses: [ 10.0.45.51/24 ]

Netplan reported /etc/netplan/80-bad.yaml:5:14 and exited 1. Indent the three keys two spaces deeper than the VLAN name, as in Step 4. We also renamed it vlan45, because a dotted device name reads like the a.b.c key paths that netplan get and set take.

vlan46: missing ‘link’ property

A VLAN without a parent device. netplan generate exits 1, and netplan set refuses the same thing when you build a VLAN one key at a time. Add link: with the NIC or bond name, or create the VLAN with a single mapping as shown in Step 3.

`gateway4` has been deprecated, use default routes instead

Old tutorials still use gateway4: 10.0.1.1. It works and exits 0, but prints this warning on every run. Replace it with a route entry, which also lets you set a metric.

      routes:
        - to: default
          via: 10.0.1.1

Put it at the same indent as addresses under the device, then run netplan generate again to confirm the warning is gone.

Permissions for /etc/netplan/70-vlan.yaml are too open

A file created with mode 644 triggers this warning, and netplan still applies it. The rule exists because netplan files can hold Wi-Fi passwords and 802.1X secrets. Fix every file at once.

sudo chmod 600 /etc/netplan/*.yaml

The 90-NM- file NetworkManager wrote in Step 7 already had mode 600, as did the cloud-init file.

reverting custom parameters for bridges and bonds is not supported

This one comes from netplan try, not generate. It checks the whole configuration, not your latest change: on bench02 the existing bond made try refuse even with nothing new in the files. Once any bond or bridge has a parameters block, try is gone for that host. Validate with netplan generate, keep a console session open, then run sudo netplan apply.

What we measured on Ubuntu 26.04 and 24.04

Ubuntu 26.04 carried most of the tests and 24.04 served as the peer. The table lists each test, where it ran and the result, with “Not run” where we did not repeat it.

TestUbuntu 26.04 (bench01)Ubuntu 24.04 (bench02)
netplan.io package1.2-1ubuntu5.11.1.2-8ubuntu1~24.04.3
Static IP through netplan tryAccepted, 0.488 ms pingApplied as peer
try timeout without ENTERReverted runtime, YAML keptNot run
VLAN 45 on ens4 through tryAccepted, 0.526 ms pingTagged frames seen in tcpdump
Bond with parameters through tryRefusedRefused
VLAN moved to new parent by applyNot observed, deleted before applyStale, needed ip link delete
Active-backup failover, 30 pings at 200 ms29 received, 3.3% lossNot run
Bridge without parameters through tryAcceptedNot run
netplan set on a partial VLANNot runmissing ‘link’ property
netplan get and statusget ethernets.ens4, status br45get bonds, status vlan46
NetworkManager renderer through tryAccepted, nmcli edit mergedNot run

On the rows both releases ran, such as the bond try refusal and netplan get and status, the results matched. What does differ between hosts is drift, and three readings catch it after a change.

  • ip -d link show vlan45: after a parent change, the name after @ must be the new parent, or apply left the old device in place.
  • Link Failure Count in /proc/net/bonding/bond0: it should only climb when someone pulls a cable or a switch port resets.
  • Any 90-NM- file in /etc/netplan/: on a host you thought was pure networkd, it means someone edited a profile with nmcli.

Run all three after every bond, bridge or renderer change, because none of them shows up in a ping test. The upstream netplan YAML reference lists every key for the device types this sheet covers.

Keep reading

Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) Ubuntu Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Free CCNA Practice Test: 600+ Questions for 200-301 v2.0 Networking Free CCNA Practice Test: 600+ Questions for 200-301 v2.0 Build a FHIR MCP Server for MedGemma 2 with Ollama AI Build a FHIR MCP Server for MedGemma 2 with Ollama netsh Commands Cheat Sheet: Wi-Fi, Firewall, Port Proxy (PDF) Cheat Sheets netsh Commands Cheat Sheet: Wi-Fi, Firewall, Port Proxy (PDF) Setup WireGuard and IPsec VPN Server on Ubuntu 22.04 Security Setup WireGuard and IPsec VPN Server on Ubuntu 22.04

Leave a Comment

Press ESC to close