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.targetto block until network is up.networkctl: CLI tool for status and control.- Configuration files:
.networkfiles for interface settings.netdevfiles for virtual devices.linkfiles for hardware settings
Configuration Files
Located in:
/etc/systemd/network/(user configs)/run/systemd/network/(runtime)/lib/systemd/network/(default configs)
Link Files
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=1500Network 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=falseNetDev Files
Create virtual devices like bridges, VLANs, bonds, tunnels.
Example: 10-br0.netdev
[NetDev]
Name=br0
Kind=bridgeConfiguration Examples
Static IP Address
[Match]
Name=eth0
[Network]
Address=10.0.0.5/24
Gateway=10.0.0.1
DNS=1.1.1.1DHCP Client
[Match]
Name=enp3s0
[Network]
DHCP=yesBridge Interface
Create the bridge:
# 10-br0.netdev
[NetDev]
Name=br0
Kind=bridgeAttach interfaces:
# 10-eth0.network
[Match]
Name=eth0
[Network]
Bridge=br0Assign 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.1VLAN Interface
# 10-vlan10.netdev
[NetDev]
Name=vlan10
Kind=vlan
[VLAN]
Id=10
# 10-vlan10.network
[Match]
Name=vlan10
[Network]
Address=192.168.10.1/24Bonding
# 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=bond0Usage
# 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-networkdIntegration with systemd-resolved
To handle DNS:
[Network]
DNS=1.1.1.1
Domains=~example.comThen enable:
sudo systemctl enable --now systemd-resolvedIntegration with systemd-timesyncd
To enable automatic NTP time sync:
sudo systemctl enable --now systemd-timesyncdIn network config:
[Network]
NTP=ntp.example.com