LinuxCommandLibrary

netplan

Configure network interfaces on Linux systems

TLDR

Apply a network configuration and make it persistent

$ sudo netplan apply
copy

Generate backend configuration files
$ sudo netplan generate
copy

Configure a network interface to use DHCP
$ sudo netplan set ethernets.[interface_name].dhcp4=true
copy

Try configuration changes without applying them permanently
$ sudo netplan try --timeout=[seconds]
copy

Return to previous working configuration after failed apply
$ sudo netplan --debug apply
copy

Display the current netplan configuration status
$ netplan status
copy

SYNOPSIS

netplan [command] [options]

PARAMETERS

apply
    Apply the network configuration. This command reads the YAML configuration files and generates the necessary configuration for the renderer. This command requires root privileges.

generate
    Generate network configuration. Usually automatically called by the apply command but can be run manually to pre-generate configuration files for debugging purposes. This command requires root privileges.

try
    Attempt to apply the configuration, but revert if there are errors. Prompts for confirmation and then applies the configuration. If no answer is provided within a defined timeout, the changes are reverted. Useful for remote systems.

--debug
    Enable debugging output, providing more verbose information about the configuration process.

--version
    Display the netplan version number.

--help
    Display help text about netplan and its subcommands.

DESCRIPTION

Netplan is a YAML network configuration abstraction for various renderer daemons on Linux. It allows you to describe network interfaces and their configuration in a declarative YAML file. Netplan then generates the necessary configuration files for the chosen renderer backend, such as NetworkManager or systemd-networkd. This provides a consistent interface for network configuration across different distributions and environments, abstracting away the complexities of specific renderer configurations. Netplan simplifies network setup, especially in cloud environments and during system provisioning.
It handles interface naming, IP addressing (IPv4 and IPv6), routing, DNS configuration, and more. Configuration files are typically located in `/etc/netplan/`, and the configuration is applied using the `netplan apply` command.

CAVEATS

Netplan requires a suitable renderer backend (systemd-networkd or NetworkManager) to be installed and running. Errors in the YAML configuration can prevent the network from starting correctly. YAML files must have proper syntax and indentation.

CONFIGURATION FILE STRUCTURE

Netplan configuration files are written in YAML format. The top-level element is typically `network`. Within `network`, you define `version` (usually 2), and then specify your network interfaces under the `ethernets` (for wired interfaces) or `wifis` (for wireless interfaces) sections. Example: `network: version: 2 renderer: networkd ethernets: eth0: dhcp4: yes`

RENDERER SELECTION

The `renderer` key in the Netplan configuration file specifies which backend to use for applying the network configuration. Common options are `networkd` (for systemd-networkd) and `NetworkManager`. If the `renderer` is not explicitly specified, netplan tries to automatically determine it based on installed packages.

HISTORY

Netplan was introduced to provide a consistent network configuration interface across different Linux distributions, particularly Ubuntu. It aimed to simplify network setup in cloud and server environments by abstracting away the complexities of different network management tools. It gained popularity for its declarative configuration approach and ease of use.

SEE ALSO

systemd-networkd(8), NetworkManager(8)

Copied to clipboard