User Tools

Site Tools


linux:system:systemd-networkd

systemd-networkd

Introduction

Systemd-networkd is a system service that manages networks. Debian conventionally has the networking service networking.service configured as the default network manager. Which uses /etc/network/interfaces file to manage your network interfaces by means of ifup and ifdown commands.

Systemd-networkd is an alternative option to the Debian networking service — networking.service. Since Debian 12 (Bookworm) systemd-networkd is used to configure the network within the lxc container.

Required services

To use systemd-networkd, start/enable systemd-networkd.service. It is optional to also configure systemd-resolved, which is a network name resolution service to local applications, considering the following points:

  • It is important to understand how resolv.conf and systemd-resolved interact to properly configure the DNS that will be used, some explanations are provided in systemd-resolved.
  • systemd-resolved is required if DNS entries are specified in .network files.
  • systemd-resolved is also required if you want to obtain DNS addresses from DHCP servers or IPv6 router advertisements.
  • (by setting (DHCP= and/or IPv6AcceptRA= in the [Network] section, and UseDNS=yes (the default) in the corresponding section(s) [DHCPv4], [DHCPv6], [IPv6AcceptRA], see systemd.network(5)).
  • Note that systemd-resolved can also be used without systemd-networkd.

Configuration files

Systemd-networkd reads files from the following locations:

  • /usr/lib/systemd/network ←- Default files shipped with systemd. Lowest priority if filename matches
  • /run/systemd/network ←- Second Highest Priority. Overrules above files with same name
  • /etc/systemd/network ←- Highest Priority. Overrules above files with same name

Network Adapter naming

Systemd/udev automatically assigns predictable, stable network interface names for all local Ethernet, WLAN, and WWAN interfaces. e.g. enp1s0 is the wired adapter and wlp2s0 is the wireless adapter. Use networkctl list to list the devices on the system.

# networkctl list
--------------------------------------------
IDX LINK TYPE     OPERATIONAL SETUP     
  1 lo   loopback carrier     unmanaged
  2 eth0 ether    routable    configured

2 links listed.
--------------------------------------------

Configuration

All configurations in this section are stored as *.network in /etc/systemd/network/. For a full listing of options and processing order, see #Configuration files and systemd.network(5). There are three types of configuration files. They all use a format similar to systemd unit files.

  • .network files. They will apply a network configuration for a matching device
  • .netdev files. They will create a virtual network device for a matching environment
  • .link files. When a network device appears, udev will look for the first matching .link file

They all follow the same rules: If all conditions in the [Match] section are matched, the profile will be activated an empty [Match] section means the profile will apply in any case (can be compared to the * wildcard) all configuration files are collectively sorted and processed in lexical order, regardless of the directory in which they live files with identical name replace each other

After making changes to a configuration file, restart systemd-networkd.service.

linux/system/systemd-networkd.txt · Last modified: by oscar