Netplan YAML — Network renderer configuration
Netplan translates YAML configuration into backend definitions for systemd-networkd or NetworkManager. It is not a universal Linux network configuration format. Files from /lib/netplan, /etc/netplan and /run/netplan are merged lexicographically; same-name files in /run override /etc, which overrides /lib. Later scalar values override, sequences may concatenate and mappings merge. Renderer default is networkd unless configured otherwise; dhcp4 defaults false. YAML indentation and value types matter. Use routes and nameservers under appropriate device; avoid copying fictional device names to real systems. Protect YAML containing credentials. netplan generate writes backend configuration, so use an alternate root for offline validation. Real network changes can sever remote access; use console and approved netplan try where supported, then verify connectivity and routing. Restore previous YAML, regenerate and reconcile backend state if needed.
Formal Syntax & Structure
network: version: 2 renderer: networkd ethernets: enp0s1: dhcp4: trueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| network.version | directive | Schema version 2 |
| renderer | directive | Backend selection |
| ethernets | directive | Ethernet device definitions |
| dhcp4 | directive | IPv4 DHCP selection |
| routes | directive | Route declarations |
| nameservers | directive | Resolver settings |
Return Value
Generated backend configuration, not active network state.
Working Example
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITmkdir -p "$d/etc/netplan"cat > "$d/etc/netplan/90-bm.yaml" <<'EOF'network: version: 2 renderer: networkd ethernets: bm-demo0: dhcp4: trueEOFchmod 0600 "$d/etc/netplan/90-bm.yaml"netplan generate --root-dir "$d"test -d "$d/run/systemd/network"printf 'private backend configuration generated\n'