enricorossi.org

Enrico Rossi


Systemd network easy configuration

Examples of systemd network configurations.

These are some collection of systemd network configuration. It does not require anything installed but systemd, not even ifupdown.

note: Debian 9 aka Stretch

Simple DHCP ethernet setup

Interface: eth0, file name is not important, but it must have the .network suffix.

/etc/systemd/network/wired.network

[Match]
Name=eth0

[Network]
DHCP=ipv4

fixed address

[Match]
Name=eth0

[Network]
Description="My fancy network configuration"
Address=10.10.10.20/24
Gateway=10.10.10.1
DNS=10.10.10.2
DNS=10.10.10.3
Domains=fancynetwork.internal
NTP=ntp.fancynetwork.internal

wireless interface

Authentication are managed by wpasupplicant and wpagui.

/etc/systemd/network/wireless.network

[Match]
Name=wlp3s0

[Network]
DHCP=ipv4

activate systemd networkd and resolved.

systemctl start systemd-networkd
systemctl enable systemd-networkd

systemctl start systemd-resolved
systemctl enable systemd-resolved

rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/

systemctl status systemd-timesyncd

virtual bridge for VMs

/etc/systemd/network/bridge.netdev

[NetDev]
Name=br0
Kind=bridge

/etc/systemd/network/bridge.network

[Match]
Name=br0

[Network]
Address=10.123.45.1/24

VLAN interface

When your network is a particular vlan you receive on a tagged interface (trunk). Suppose eno1 is an interface you have connected to a trunk with many vlans and you want to use the vlan id 20.

/etc/systemd/network/eno1.network

[Match]
Name=eno1

[Network]
VLAN=eno1.20

/etc/systemd/network/eno1.20.netdev

[NetDev]
Name=eno1.20
Kind=vlan

[VLAN]
Id=20

/etc/systemd/network/eno1.20.network

[Match]
Name=eno1.20

[Network]
Description="My fancy network configuration"
Address=10.10.10.20/24
Gateway=10.10.10.1
DNS=10.10.10.2
DNS=10.10.10.3
Domains=fancynetwork.internal
NTP=ntp.fancynetwork.internal