Network setup is performed by systemd-networkd(8).
Network files must have the extension .network; other extensions are ignored. Networks are applied to links whenever the links appear.
The .network files are read from the files located in the system network directory /lib/systemd/network, the volatile runtime network directory /run/systemd/network and the local administration network directory /etc/systemd/network. All configuration files are collectively sorted and processed in lexical order, regardless of the directories in which they live. However, files with identical filenames replace each other. Files in /etc have the highest priority, files in /run take precedence over files with the same name in /lib. This can be used to override a system-supplied configuration file with a local file if needed; a symlink in /etc with the same name as a configuration file in /lib, pointing to /dev/null, disables the configuration file entirely.
The network file contains a "[Match]" section, which determines if a given network file may be applied to a given device; and a "[Network]" section specifying how the device should be configured. The first (in lexical order) of the network files that matches a given device is applied.
A network file is said to match a device if each of the entries in the "[Match]" section matches, or if the section is empty. The following keys are accepted:
The hardware address.
The persistent path, as exposed by the udev property "ID_PATH". May contain shell style globs.
The driver currently bound to the device, as exposed by the udev property "DRIVER" of its parent device, or if that is not set the driver as exposed by "ethtool -i" of the device itself.
The device type, as exposed by the udev property "DEVTYPE".
The device name, as exposed by the udev property "INTERFACE". May contain shell style globs.
Matches against the hostname or machine ID of the host. See "ConditionHost=" in systemd.unit(5) for details.
Checks whether the system is executed in a virtualized environment and optionally test whether it is a specific implementation. See "ConditionVirtualization=" in systemd.unit(5) for details.
Checks whether a specific kernel command line option is set (or if prefixed with the exclamation mark unset). See "ConditionKernelCommandLine=" in systemd.unit(5) for details.
Checks whether the system is running on a specific architecture. See "ConditionArchitecture=" in systemd.unit(5) for details.
The "[Network]" section accepts the following keys:
A description of the device. This is only used for presentation purposes.
Enables DHCPv4 and/or DHCPv6 support. Accepts "both", "none", "v4" or "v6".
A boolean. Enables a basic DHCPv4 server on the device. Mostly useful for handing out leases to container instances.
A boolean. When true, enables IPv4 link-local support. If "DHCP=" is also true, acquiring DHCP address will deprecate previously acquired IPv4 link-local address or stop acquiring process if one has not been acquired before.
A static IPv4 or IPv6 address and its prefix length, separated by a "/" character. Specify this key more than once to configure several addresses. The format of the address must be as described in inet_pton(3). This is a short-hand for an [Address] section only containing an Address key (see below). This option may be specified more than once.
If the specified address is 0.0.0.0 (for IPv4) or [::] (for IPv6), a new address range of the requested size is automatically allocated from a system-wide pool of unused ranges. The allocated range is checked against all current network interfaces and all known network configuration files to avoid address range conflicts. The default system-wide pool consists of 192.168.0.0/16, 172.16.0.0/12 and 10.0.0.0/8 for IPv4, and fc00::/7 for IPv6. This functionality is useful to manage a large number of dynamically created network interfaces with the same network configuration and automatic address range assignment.
The gateway address, which must be in the format described in inet_pton(3). This is a short-hand for a [Route] section only containing a Gateway key. This option may be specified more than once.
A DNS server address, which must be in the format described in inet_pton(3). This option may be specified more than once.
The name of the bridge to add the link to.
The name of the bond to add the link to.
The name of a VLAN to create on the link. This option may be specified more than once.
The name of a MACVLAN to create on the link. This option may be specified more than once.
The name of a VXLAN to create on the link. This option may be specified more than once.
The name of a Tunnel to create on the link. This option may be specified more than once.
An "[Address]" section accepts the following keys. Specify several "[Address]" sections to configure several addresses.
As in the "[Network]" section. This key is mandatory.
The broadcast address, which must be in the format described in inet_pton(3). This key only applies to IPv4 addresses. If it is not given, it is derived from the "Address" key.
An address label.
The "[Route]" section accepts the following keys. Specify several "[Route]" sections to configure several routes.
As in the "[Network]" section. This key is mandatory.
The destination prefix of the route. Possibly followed by a slash and the prefixlength. If ommitted, a full-length host route is assumed.
The "[DHCP]" section accepts the following keys:
When true (the default), the DNS servers received from the DHCP server will be used and take precedence over any statically configured ones.
When true, the interface maximum transmission unit from the DHCP server will be used on the current link. Defaults to false.
When true (the default), the machine's hostname will be sent to the DHCP server
When true (the default), the hostname received from the DHCP server will be used as the transient hostname.
When true (the default), the static routes will be requested from the DHCP server and added to the routing table with metric of 1024.
When true, the connection will never be torn down even if the DHCP lease expires. This is contrary to the DHCP specification, but may be the best choice if, say, the root filesystem relies on this connection. Defaults to false.
Request the server to use broadcast messages before the IP address has been configured. This is necessary for devices that cannot receive RAW packets, or that cannot receive packets at all before an IP address has been configured. On the other hand, this must not be enabled on networks where broadcasts are filtered out.
Example 1. /etc/systemd/network/50-static.network
[Match] Name=enp2s0 [Network] Address=192.168.0.15/24 Gateway=192.168.0.1
Example 2. /etc/systemd/network/80-dhcp.network
[Match] Name=en* [Network] DHCP=yes
Example 3. /etc/systemd/network/bridge-static.network
[Match] Name=bridge0 [Network] Address=192.168.0.15/24 Gateway=192.168.0.1 DNS=192.168.0.1
Example 4. /etc/systemd/network/bridge-slave-interface.network
[Match] Name=enp2s0 [Network] Bridge=bridge0
Example 5. /etc/systemd/network/ipip.network
[Match] Name=em1 [Network] Tunnel=ipip-tun
Example 6. /etc/systemd/network/sit.network
[Match] Name=em1 [Network] Tunnel=sit-tun
Example 7. /etc/systemd/network/gre.network
[Match] Name=em1 [Network] Tunnel=gre-tun
Example 8. /etc/systemd/network/vti.network
[Match] Name=em1 [Network] Tunnel=vti-tun