Translation(s): English - Español - Français - српски
?Discussion
This page describes the usage of Netplan in Debian.
Netplan
Netplan allows writing declarative network configuration for various backends, such as SystemdNetworkd or NetworkManager.
Website: https://netplan.io
Upstream documentation: https://netplan.io/reference
Questions & Answers: Netplan/FAQ
Introduction
Netplan configuration files use the YAML format. All /{usr/lib,etc,run}/netplan/*.yaml are considered. Lexicographically later files (regardless of which directory they are in) amend (new mapping keys) or override (same mapping keys) previous ones. A file in /run/netplan completely shadows a file with the same name in /etc/netplan, and a file in either of those directories shadows a file with the same name in /usr/lib/netplan.
The top-level node in a Netplan configuration file is a network: & version: 2 mapping, and then device definitions grouped by their type, such as ethernets:, modems:, wifis: or bridges:.
Sysadmins, distribution installers, cloud instantiation, image builds for particular devices, or any other way to deploy an operating system can put its desired network configuration into YAML configuration file(s) in /etc/netplan/. During early boot, the netplan generator (network renderer) runs, reads /{lib,etc,run}/netplan/*.yaml and writes configuration to /run to hand off control of devices to the specified backend networking daemon.
Configured devices get handled by systemd-networkd by default, unless explicitly marked as managed by a specific backend renderer (NetworkManager)
- Devices not covered by the network configuration do not get touched at all and can be configured using a different tool.
When the Netplan runtime components are installed from the netplan.io package, the CLI can be used to introspect the current network state & configuration, using the netplan status [--diff] command.
Example
A Netplan configuration file could look like this /etc/netplan/00-installer.yaml example:
# This is the network config written by debian-installer. # For more information, see netplan(5). network: version: 2 ethernets: enp0s1: nameservers: addresses: - 5.1.66.255 - 2001:678:e68:f000:: ipv6-privacy: true ipv6-address-generation: stable-privacy dhcp4: true dhcp6: true
NetworkManager
If we want to hand over control to NetworkManager, we can place a configuration file in /etc/netplan/01-network-manager-all.yaml:
# Let NetworkManager manage all devices on this system. # For more information, see netplan(5). network: version: 2 renderer: NetworkManager
This way, additional Netplan configuration from /etc/netplan/*.yaml would automatically be translated to ephemeral NetworkManager configuration in /run/NetworkManager/system-connections/, while letting NetworkManager control and configure all the interface that are not described in Netplan.
Cloud-Images
As of Debian 12 "Bookworm" Netplan is the default network configuration tool for Debian cloud-images, see Debian-Reference 5.4: The modern network configuration for cloud
Debian-Installer
Debian-Installer supports writing Netplan configuration in the target system as of netcfg v1.190. This functionally gets triggered automatically, whenever the netplan-generator package is detected to be installed in the target system.
A preeseed file can be used to have Netplan installed in the target system, e.g.:
d-i preseed/late_command string in-target apt-get -y install netplan-generator netplan.io systemd-resolved