Netplan, Bonding, and VLANs
Example
This is a configuration using from Ubuntu 18.04 LTS. Two Ethernet interfaces are bonded using the active-passive mode. The untagged bond0 interface is for private traffic, while a public IP address is being delivered to a tagged VLAN sub interface using VLAN 262.
The following packages are required: ifenslave and vlan
network:
version: 2
ethernets:
enp1s0:
optional: true
enp2s0:
optional: true
bonds:
bond0:
addresses: [ 192.168.168.115/24 ]
interfaces: [ enp1s0, enp2s0 ]
parameters:
mode: active-backup
primary: enp1s0
mii-monitor-interval: 100
up-delay: 10000 # must be a multiple of mii-monitor-interval
# routes:
# - to: 10.0.0.0/8
# via: 192.168.168.1
# - to: 172.16.0.0/12
# via: 192.168.168.1
# - to: 192.168.0.0/16
# via: 192.168.168.1
vlans:
bond0.262:
id: 262
link: bond0
addresses: [ 1.1.1.123/28 ]
gateway4: 1.1.1.113
nameservers:
search: [ servers.domain.com ]
addresses:
- "8.8.8.8"
- "8.8.4.4"
systemd-networkd-wait-online.service
In Ubuntu 22.04, even though the netplan configuration is correct, the service systemd-networkd-wait-online.service will wait for 120 seconds if one of the network interfaces is not connected.
In order to get around this, one solution is to add the "--any" option to the ExecStart line:
[Unit]
Description=Wait for Network to be Configured
Documentation=man:systemd-networkd-wait-online.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
Requires=systemd-networkd.service
After=systemd-networkd.service
Before=network-online.target shutdown.target
[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online --any --timeout=10
RemainAfterExit=yes
[Install]
WantedBy=network-online.target
References
https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html