The Evolution of Ubuntu Networking
Historically, configuring network interfaces on an Ubuntu server involved editing the legacy /etc/network/interfaces file. While sufficient for assigning a simple static IP address, this architecture became incredibly convoluted when deploying enterprise configurations like LACP link aggregation (bonding), VLAN tagging, and bridge networks for KVM hypervisors.
To modernize and standardize network configuration, Canonical introduced Netplan. Netplan acts as a centralized, YAML-based configuration abstraction layer. The administrator writes a human-readable YAML file defining the desired network state (including complex bonds and VLANs). During the boot process, Netplan parses this file and automatically translates it into the backend-specific configuration for either systemd-networkd (standard on Ubuntu Server) or NetworkManager (standard on Ubuntu Desktop).
Understanding how to leverage Netplan’s YAML structure is mandatory for configuring robust, high-availability networking in modern Ubuntu environments.
Step 1: Understanding the Netplan Directory Structure
Netplan configuration files are stored in /etc/netplan/. They must end with the .yaml extension.
On a fresh Ubuntu Server installation, you will typically find a default file named something like 00-installer-config.yaml or 50-cloud-init.yaml.
Before making enterprise changes, always back up the original configuration:
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak
Warning: Because Netplan relies on YAML, strict indentation (using spaces, never tabs) is absolutely required. A single misplaced space will cause the parser to fail, potentially dropping your server off the network.
Step 2: Configuring Network Bonding (LACP)
Network bonding (or Link Aggregation) combines two or more physical network interface cards (NICs) into a single logical interface. This doubles your available bandwidth and provides instant failover if a switch port dies or a cable is unplugged.
The industry standard for bonding is 802.3ad (LACP), which requires a corresponding configuration on the physical network switch.
Assume your server has two physical interfaces: enp3s0 and enp4s0. You want to bond them into a logical interface named bond0.
Edit your Netplan YAML file:
sudo nano /etc/netplan/00-installer-config.yaml
Configure the bond like this:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
enp4s0:
dhcp4: no
bonds:
bond0:
interfaces:
- enp3s0
- enp4s0
parameters:
mode: 802.3ad
mii-monitor-interval: 100
transmit-hash-policy: layer2+3
In this block, we explicitly disable DHCP on the raw physical interfaces and declare them as slaves to bond0. We define the bonding mode as LACP (802.3ad) and set a monitoring interval of 100ms to detect physical link failures rapidly.
Step 3: Adding VLAN Tagging to the Bond
In a segmented enterprise network, a single server often needs to communicate across multiple subnets (e.g., the Management network on VLAN 10 and the Database network on VLAN 20).
Instead of running multiple physical cables, the switch port is configured as a “Trunk,” passing multiple VLANs over the same bonded connection. You must instruct Netplan to create virtual VLAN interfaces on top of your bond0 interface.
Append the vlans: block to your existing YAML file:
vlans:
vlan10:
id: 10
link: bond0
addresses: [10.0.10.50/24]
routes:
- to: default
via: 10.0.10.1
nameservers:
addresses: [10.0.10.11, 8.8.8.8]
vlan20:
id: 20
link: bond0
addresses: [10.0.20.50/24]
# No default route here; a server can only have one default gateway.
This creates two virtual interfaces (vlan10 and vlan20). vlan10 receives the default gateway, ensuring all generic internet traffic routes through the management subnet, while vlan20 simply exists as a layer-2 leg in the database subnet.
Step 4: Testing the Configuration (The Fail-Safe)
Applying network changes via SSH is terrifying; a single typo will permanently sever your connection to the server, requiring a trip to the physical data center.
Netplan includes a brilliant fail-safe mechanism: netplan try.
sudo netplan try
When you execute this, Netplan parses the YAML, applies the new network configuration, and starts a 120-second countdown timer. It will ask you to press ENTER to confirm the changes.
If you made a typo (e.g., set the wrong gateway IP), your SSH session will freeze. However, because you cannot press ENTER, the 120-second timer will expire. Netplan will automatically revert to the previous, working network configuration, instantly restoring your SSH access.
Step 5: Applying the Configuration Permanently
If netplan try succeeds and your SSH session remains active, you press ENTER to confirm.
If you ever need to forcefully apply a known-good configuration without the timer, you use:
sudo netplan apply
You can then verify that your complex bonding and VLAN architecture is actively running using standard Linux networking commands:
ip addr show
cat /proc/net/bonding/bond0
Conclusion
Netplan replaces archaic, script-based network configuration with a deterministic, declarative YAML architecture. By defining physical NICs, high-availability LACP bonds, and segmented VLAN interfaces in a single, readable file—and protecting deployments with the netplan try fail-safe—Ubuntu administrators can confidently build complex, enterprise-grade network topologies without fear of catastrophic misconfiguration.