Netplan Network Configuration¶
This section provides comprehensive coverage of Netplan, Ubuntu's network configuration abstraction layer. Understanding Netplan is essential for configuring complex network setups involving bridges, bonds, VLANs, and integration with virtualization technologies.
What is Netplan?¶
Netplan is a utility for network configuration on Linux systems using YAML files. It acts as an abstraction layer between you and the underlying network configuration systems.
┌─────────────────────────────────────────────────────────────┐
│ YAML Configuration │
│ /etc/netplan/*.yaml │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Netplan │
│ Parses YAML, generates config │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────┴─────────────┐
▼ ▼
┌─────────────────────────┐ ┌─────────────────────────┐
│ systemd-networkd │ │ NetworkManager │
│ (Server default) │ │ (Desktop default) │
└─────────────────────────┘ └─────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Linux Kernel │
│ Network interfaces configured │
└─────────────────────────────────────────────────────────────┘
Why Netplan?¶
Before Netplan¶
Different tools for different scenarios: - /etc/network/interfaces (ifupdown) - NetworkManager connection files - systemd-networkd .network files - Distribution-specific tools
With Netplan¶
- Single configuration format (YAML)
- Backend-agnostic - same config works with networkd or NetworkManager
- Declarative - describe desired state, not commands
- Cloud-ready - integrates with cloud-init
- Validation - catches errors before applying
Section Overview¶
Fundamentals¶
- Netplan Basics - Configuration files, syntax, commands
- Renderers - systemd-networkd vs NetworkManager
- YAML Syntax - Complete reference for Netplan YAML
- Configuration Workflow - Try, apply, debug
Interface Types¶
- Ethernet - Physical interfaces, DHCP, static IP
- Bridges - Software switches for VMs and containers
- Bonds - Link aggregation for redundancy/performance
- VLANs - Virtual LANs for network segmentation
- Wireless - WiFi configuration
- Virtual Interfaces - Dummy, VXLAN, tunnels
Routing & DNS¶
- Static Routes - Custom routing tables
- Policy Routing - Source-based routing
- DNS Configuration - systemd-resolved integration
- IPv6 - Dual-stack and IPv6-only setups
Advanced Topics¶
- Multiple Addresses - Secondary IPs, aliases
- Wake-on-LAN - Remote power management
- Network Dispatcher - Hooks and scripts
- Performance Tuning - MTU, offloading, buffers
Integration¶
- Docker Integration - Bridge networks for containers
- KVM/libvirt Integration - VM networking with Netplan
- LXD Integration - Container host networking
Troubleshooting¶
- Common Issues - Frequent problems and solutions
- Debugging Tools - networkctl, ip, ss
- Migration Guide - From interfaces file to Netplan
Reference¶
- Complete Examples - Full configuration files
- Property Reference - All Netplan options
- Network Diagrams - Visual architecture examples
Quick Start¶
Minimal Server Configuration¶
Static IP Configuration¶
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
Apply Configuration¶
# Test without applying
sudo netplan try
# Apply configuration
sudo netplan apply
# Generate and show backend config
sudo netplan generate
Key Concepts¶
Declarative Configuration
Netplan uses declarative YAML - you describe the desired end state, not the steps to get there.
Always Use netplan try
The netplan try command applies changes with an automatic rollback timer. Essential for remote administration.
File Naming Matters
Files are processed in alphabetical order. Use numbered prefixes (00-, 01-) to control order.