ethernets:
wifis:
bridges:
bonds:
vlans:
Distribution installers, cloud instantiation, image builds for particular devices, or any other way to deploy an operating system put its desired network configuration into YAML configuration file(s). During early boot, the netplan "network renderer" runs which reads /{lib,etc,run}/netplan/*.yaml
and writes configuration to /run
to hand off control of devices to the specified networking daemon.
virbr0
, lxdbr0
), or to change the global default policy to use NetworkManager for everything.netplan's configuration files use the YAML format. All /{lib,etc,run}/netplan/*.yaml
are considered. Lexicographically later files (regardless of in which directory they are) amend (new mapping keys) or override (same mapping keys) previous ones. A file in /run/netplan
completely shadows a file with same name in /etc/netplan
, and a file in either of those directories shadows a file with the same name in /lib/netplan
.
The top-level node in a netplan configuration file is a network:
mapping that contains version: 2
(the YAML currently being used by curtin, MaaS, etc. is version 1), and then device definitions grouped by their type, such as ethernets:
, wifis:
, or bridges:
. These are the types that our renderer can understand and are supported by our backends.
Each type block contains device definitions as a map where the keys (called "configuration IDs") are defined as below.
The key names below the per-device-type definition maps (like ethernets:
) are called "ID"s. They must be unique throughout the entire set of configuration files. Their primary purpose is to serve as anchor names for composite devices, for example to enumerate the members of a bridge that is currently being defined.
There are two physically/structurally different classes of device definitions, and the ID field has a different interpretation for each:
(Examples: ethernet, wifi) These can dynamically come and go between reboots and even during runtime (hotplugging). In the generic case, they can be selected by match:
rules on desired properties, such as name/name pattern, MAC address, driver, or device paths. In general these will match any number of devices (unless they refer to properties which are unique such as the full path or MAC address), so without further knowledge about the hardware these will always be considered as a group.
It is valid to specify no match rules at all, in which case the ID field is simply the interface name to be matched. This is mostly useful if you want to keep simple cases simple, and it's how network device configuration has been done for a long time.
If there are match
: rules, then the ID field is a purely opaque name which is only being used for references from definitions of compound devices in the config.
(Examples: veth, bridge, bond) These are fully under the control of the config file(s) and the network stack. I. e. these devices are being created instead of matched. Thus match:
and set-name:
are not applicable for these, and the ID field is the name of the created virtual device.
match
(mapping)This selects a subset of available physical devices by various hardware properties. The following configuration will then apply to all matching devices, as soon as they appear. All specified properties must match.
name
(scalar)match:
at all and just using the ID (see above). Note that currently only networkd supports globbing, NetworkManager does not.
macaddress
(scalar)driver
(scalar)DRIVER
udev property. Globs are supported. Matching on driver is only supported with networkd.
Examples:
all cards on second PCI bus:
match:
name: enp2*
fixed MAC address:
match:
macaddress: 11:22:33:AA:BB:FF
first card of driver ixgbe
:
match:
driver: ixgbe
name: en*s0
set-name
(scalar)When matching on unique properties such as path or MAC, or with additional assumptions such as "there will only ever be one wifi device", match rules can be written so that they only match one device. Then this property can be used to give that device a more specific/desirable/nicer name than the default from udev’s ifnames. Any additional device that satisfies the match rules will then fail to get renamed and keep the original kernel name (and dmesg will show an error).
wakeonlan
(bool)Enable wake on LAN. Off by default.
renderer
(scalar)Use the given networking backend for this definition. Currently supported are networkd
and NetworkManager
. This property can be specified globally in networks:
, for a device type (in e. g. ethernets:
) or for a particular device definition. Default is networkd
.
dhcp4
(bool)Enable DHCP for IPv4. Off by default.
dhcp6
(bool)Enable DHCP for IPv6. Off by default. This covers both stateless DHCP - where the DHCP server supplies information like DNS nameservers but not the IP address - and stateful DHCP, where the server provides both the address and the other information.
If you are in an IPv6-only environment with completely stateless autoconfiguration (SLAAC with RDNSS), this option can be set to cause the interface to be brought up. (Setting accept-ra alone is not sufficient.) Autoconfiguration will still honour the contents of the router advertisment and only use DHCP if requested in the RA.
Note that rdnssd
(8) is required to use RDNSS with networkd. No extra software is required for NetworkManager.
critical
(bool)(networkd backend only) Designate the connection as "critical to the system", meaning that special care will be taken by systemd-networkd to not release the IP from DHCP when it the daemon is restarted.
dhcp-identifier
(scalar)When set to 'mac'; pass that setting over to systemd-networkd to use the device's MAC address as a unique identifier rather than a RFC4361-compliant Client ID. This has no effect when NetworkManager is used as a renderer.
accept-ra
(bool)Accept Router Advertisement that would have the kernel configure IPv6 by itself. When enabled, accept Router Advertisements. When disabled, do not respond to Router Advertisements. If unset use the host kernel default setting.
addresses
(sequence of scalars)Add static addresses to the interface in addition to the ones received through DHCP or RA. Each sequence entry is in CIDR notation, i. e. of the form addr/prefixlen
. addr
is an IPv4 or IPv6 address as recognized by inet_pton
(3) and prefixlen
the number of bits of the subnet.
Example: addresses: [192.168.14.2/24, "2001:1::1/64"]
gateway4
, gateway6
(scalar)Set default gateway for IPv4/6, for manual address configuration. This requires setting addresses
too. Gateway IPs must be in a form recognized by inet_pton
(3).
Example for IPv4: gateway4: 172.16.0.1
Example for IPv6: gateway6: "2001:4::1"
nameservers
(mapping)Set DNS servers and search domains, for manual address configuration. There are two supported fields: addresses:
is a list of IPv4 or IPv6 addresses similar to gateway*
, and search:
is a list of search domains.
Example:
ethernets:
id0:
[...]
nameservers:
search: [lab, home]
addresses: [8.8.8.8, "FEDC::1"]
macaddress
(scalar)Set the device's MAC address. The MAC address must be in the form "XX:XX:XX:XX:XX:XX".
Example:
ethernets:
id0:
[...]
macaddress: 52:54:00:6b:3c:59
optional
(boolean)An optional device is not required for booting. Normally, networkd will wait some time for device to become configured before proceeding with booting. However, if a device is marked as optional, networkd will not wait for it. This is only supported by networkd, and the default is false.
Example:
ethernets:
eth7:
# this is plugged into a test network that is often
# down - don't wait for it to come up during boot.
dhcp4: true
optional: true
routes
(mapping)Configure static routing for the device; see the Routing
section below.
routing-policy
(mapping)Configure policy routing for the device; see the Routing
section below.
Complex routing is possible with netplan. Standard static routes as well as policy routing using routing tables are supported via the networkd
backend.
These options are available for all types of interfaces.
routes
(mapping)The routes
block defines standard static routes for an interface. At least to
and via
must be specified.
For from
, to
, and via
, both IPv4 and IPv6 addresses are recognized, and must be in the form addr/prefixlen
or addr
.
from
(scalar)to
(scalar)via
(scalar)on-link
(bool)metric
(scalar)type
(scalar)scope
(scalar)table
(scalar)table
parameter. Allowed values are positive integers starting from 1. Some values are already in use to refer to specific routing tables: see /etc/iproute2/rt_tables
.
routing-policy
(mapping)The routing-policy
block defines extra routing policy for a network, where traffic may be handled specially based on the source IP, firewall marking, etc.
For from
, to
, both IPv4 and IPv6 addresses are recognized, and must be in the form addr/prefixlen
or addr
.
from
(scalar)to
(scalar)table
(scalar)table
parameter. Allowed values are positive integers starting from 1. Some values are already in use to refer to specific routing tables: see /etc/iproute2/rt_tables
.
priority
(scalar)fwmark
(scalar)type-of-service
(scalar)ethernets:
Ethernet device definitions do not support any specific properties beyond the common ones described above.
wifis:
Note that systemd-networkd
does not natively support wifi, so you need wpasupplicant installed if you let the networkd
renderer handle wifi.
access-points
(mapping)This provides pre-configured connections to NetworkManager. Note that users can of course select other access points/SSIDs. The keys of the mapping are the SSIDs, and the values are mappings with the following supported properties:
password
(scalar)mode
(scalar)infrastructure
(the default), ap
(create an access point to which other devices can connect), and adhoc
(peer to peer networks without a central access point). ap
is only supported with NetworkManager.
bridges:
interfaces
(sequence of scalars)All devices matching this ID list will be added to the bridge.
Example:
ethernets:
switchports:
match: {name: "enp2*"}
[...]
bridges:
br0:
interfaces: [switchports]
parameters
(mapping)Customization parameters for special bridging options. Unless otherwise specified, parameter values for time intervals should be expressed in milliseconds, but can also be expressed in seconds using a time suffix (such as "s" for seconds, "ms" for milliseconds).
ageing-time
(scalar)priority
(scalar)0
and 65535
. Lower values mean higher priority. The bridge with the higher priority will be elected as the root bridge.
port-priority
(scalar)0
and 63
. This metric is used in the designated port and root port selection algorithms.
forward-delay
(scalar)hello-time
(scalar)max-age
(scalar)path-cost
(scalar)stp
(bool)bonds:
interfaces
(sequence of scalars)All devices matching this ID list will be added to the bond.
Example:
ethernets:
switchports:
match: {name: "enp2*"}
[...]
bonds:
bond0:
interfaces: [switchports]
parameters
(mapping)Customization parameters for special bonding options. Unless otherwise specified, parameter values for time intervals should be expressed in milliseconds, but can also be expressed in seconds using a time suffix (such as "s" for seconds, "ms" for milliseconds).
mode
(scalar)balance-rr
(round robin). Possible values are balance-rr
, active-backup
, balance-xor
, broadcast
, 802.3ad
, balance-tlb
, and balance-alb
.
lacp-rate
(scalar)slow
(30 seconds, default), and fast
(every second).
mii-monitor-interval
(scalar)0
; which disables MII monitoring. This is equivalent to the MIIMonitorSec= field for the networkd backend.
min-links
(scalar)transmit-hash-policy
(scalar)layer2
, layer3+4
, layer2+3
, encap2+3
, and encap3+4
.
ad-select
(scalar)stable
, bandwidth
, and count
. This option is only used in 802.3ad mode.
all-slaves-active
(bool)false
. If they should be delivered, set this option to true
. The default value is false, and is the desirable behavior in most situations.
arp-interval
(scalar)0
, which disables ARP monitoring. For the networkd backend, this maps to the ARPIntervalSec= property.
arp-ip-targets
(sequence of scalars)arp-interval
is set to a value other than 0
. At least one IP address must be given for ARP link monitoring to function. Only IPv4 addresses are supported. You can specify up to 16 IP addresses. The default value is an empty list.
arp-validate
(scalar)none
, active
, backup
, and all
.
arp-all-targets
(scalar)active-backup
mode when arp-validate
is enabled. Possible values are any
and all
.
up-delay
(scalar)0
. This maps to the UpDelaySec= property for the networkd renderer.
down-delay
(scalar)0
. This maps to the DownDelaySec= property for the networkd renderer.
fail-over-mac-policy
(scalar)none
, active
, and follow
.
gratuitious-arp
(scalar)1
. The default value is 1
and valid values are between 1
and 255
. This only affects active-backup
mode.
packets-per-slave
(scalar)balance-rr
mode, specifies the number of packets to transmit on a slave before switching to the next. When this value is set to 0
, slaves are chosen at random. Allowable values are between 0
and 65535
. The default value is 1
. This setting is only used in balance-rr
mode.
primary-reselect-policy
(scalar)always
, better
, and failure
.
resend-igmp
(scalar)In modes balance-rr
, active-backup
, balance-tlb
and balance-alb
, a failover can switch IGMP traffic from one slave to another.
This parameter specifies how many IGMP membership reports are issued on a failover event. Values range from 0 to 255. 0 disables sending membership reports. Otherwise, the first membership report is sent on failover and subsequent reports are sent at 200ms intervals.
learn-packet-interval
(scalar)1
and 0x7fffffff
. The default value is 1
. This option only affects balance-tlb
and balance-alb
modes. Using the networkd renderer, this field maps to the LearnPacketIntervalSec= property.
primary
(scalar)active-backup
, balance-alb
, and balance-tlb
modes.
vlans:
id
(scalar)VLAN ID, a number between 0 and 4094.
link
(scalar)netplan ID of the underlying device definition on which this VLAN gets created.
Example:
ethernets:
eno1: {...}
vlans:
en-intra:
id: 1
link: eno1
dhcp4: yes
en-vpn:
id: 2
link: eno1
address: ...
Configure an ethernet device with networkd, identified by its name, and enable DHCP:
network:
version: 2
ethernets:
eno1:
dhcp4: true
This is a complex example which shows most available features:
network:
version: 2
# if specified, can only realistically have that value, as networkd cannot
# render wifi/3G.
renderer: NetworkManager
ethernets:
# opaque ID for physical interfaces, only referred to by other stanzas
id0:
match:
macaddress: 00:11:22:33:44:55
wakeonlan: true
dhcp4: true
addresses:
- 192.168.14.2/24
- 192.168.14.3/24
- "2001:1::1/64"
gateway4: 192.168.14.1
gateway6: "2001:1::2"
nameservers:
search: [foo.local, bar.local]
addresses: [8.8.8.8]
routes:
- to: 0.0.0.0/0
via: 11.0.0.1
table: 70
on-link: true
metric: 3
routing-policy:
- to: 10.0.0.0/8
from: 192.168.14.2/24
table: 70
priority: 100
- to: 20.0.0.0/8
from: 192.168.14.3/24
table: 70
priority: 50
lom:
match:
driver: ixgbe
# you are responsible for setting tight enough match rules
# that only match one device if you use set-name
set-name: lom1
dhcp6: true
switchports:
# all cards on second PCI bus unconfigured by
# themselves, will be added to br0 below
# note: globbing is not supported by NetworkManager
match:
name: enp2*
mtu: 1280
wifis:
all-wlans:
# useful on a system where you know there is
# only ever going to be one device
match: {}
access-points:
"Joe's home":
# mode defaults to "infrastructure" (client)
password: "s3kr1t"
# this creates an AP on wlp1s0 using hostapd
# no match rules, thus the ID is the interface name
wlp1s0:
access-points:
"guest":
mode: ap
# no WPA config implies default of open
bridges:
# the key name is the name for virtual (created) interfaces
# no match: and set-name: allowed
br0:
# IDs of the components; switchports expands into multiple interfaces
interfaces: [wlp1s0, switchports]
dhcp4: true