systemd-networkd

systemd-networkd is a system daemon that manages network configurations for Linux systems. It is part of the systemd suite and is especially well-suited for headless servers, embedded systems, containers, and systems where declarative, minimal configuration is desired.

Components of systemd-networkd

  • systemd-networkd: The core daemon that applies network configurations.
  • systemd-networkd-wait-online: Utility .target to block until network is up.
  • networkctl: CLI tool for status and control.
  • Configuration files:
    • .network files for interface settings
    • .netdev files for virtual devices
    • .link files for hardware settings

Configuration Files

Located in:

  • /etc/systemd/network/ (user configs)
  • /run/systemd/network/ (runtime)
  • /lib/systemd/network/ (default configs)

Set hardware-specific settings like MTU, MAC address, name policy.

Example: 10-eth0.link

[Match]
MACAddress=de:ad:be:ef:00:01
 
[Link]
Name=lan0
MTUBytes=1500

Network Files

Configure IP settings, DHCP, DNS, routes.

Example: 10-lan0.network

[Match]
Name=lan0
 
[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
DNS=1.1.1.1
 
[DHCP]
UseDNS=false

NetDev Files

Create virtual devices like bridges, VLANs, bonds, tunnels.

Example: 10-br0.netdev

[NetDev]
Name=br0
Kind=bridge

Configuration Examples

Static IP Address

[Match]
Name=eth0
 
[Network]
Address=10.0.0.5/24
Gateway=10.0.0.1
DNS=1.1.1.1

DHCP Client

[Match]
Name=enp3s0
 
[Network]
DHCP=yes

Bridge Interface

Create the bridge:

# 10-br0.netdev
[NetDev]
Name=br0
Kind=bridge

Attach interfaces:

# 10-eth0.network
[Match]
Name=eth0
 
[Network]
Bridge=br0

Assign IP to bridge:

# 10-br0.network
[Match]
Name=br0
 
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=1.1.1.1

VLAN Interface

# 10-vlan10.netdev
[NetDev]
Name=vlan10
Kind=vlan
 
[VLAN]
Id=10
 
# 10-vlan10.network
[Match]
Name=vlan10
 
[Network]
Address=192.168.10.1/24

Bonding

# 10-bond0.netdev
[NetDev]
Name=bond0
Kind=bond
 
[Bond]
Mode=active-backup
 
# 10-bond0.network
[Match]
Name=bond0
 
[Network]
DHCP=yes
 
# 10-eth0.network
[Match]
Name=eth0
 
[Network]
Bond=bond0
 
# 10-eth1.network
[Match]
Name=eth1
 
[Network]
Bond=bond0

Usage

# Start and enable
sudo systemctl enable --now systemd-networkd
 
# Restart
sudo systemctl restart systemd-networkd
 
# Reload configs without restart
sudo networkctl reload
 
# View status
networkctl status
 
# Show all interfaces and their states
networkctl list
 
# Detailed status of one interface
networkctl status eth0
 
# Show address assignments
ip addr
 
# Show routes
ip route
 
# Journal logs
journalctl -u systemd-networkd

Integration with systemd-resolved

To handle DNS:

[Network]
DNS=1.1.1.1
Domains=~example.com

Then enable:

sudo systemctl enable --now systemd-resolved

Integration with systemd-timesyncd

To enable automatic NTP time sync:

sudo systemctl enable --now systemd-timesyncd

In network config:

[Network]
NTP=ntp.example.com