Topic: tech myref prev next
tech myref > systemd-networkd
There are a number of benefits to using systemd-networkd
, as an alternative
to Debian’s networking scripts. Providing networking for virtual machines
using systemd-networkd
is comparable to providing networking for virtual
machines using Ubuntu’s netplan
.
Enable systemd-networkd
;
systemctl enable systemd-networkd
Move the interfaces
file to stop Debian reading from it;
mv /etc/network/interfaces /etc/network/interfaces.moved_to_systemd-networkd
Do the same for the /etc/network/interfaces.d
directory if required.
Create a file for each bridge in /etc/systemd/network
as a .netdev
file. For instance, /etc/systemd/network/br4.netdev
;
[NetDev]
Name=br4
Kind=bridge
The name does not need to be in a specific format. br4
was chosen here because the configuration was migrated from an old /etc/network/interfaces
configuration.
Physical network devices do not need to be created in systemd-networkd
. The
names of physical devices can be discovered with the ip link
command.
Internet Protocol can be added to a network device as in the following example
file, /etc/systemd/network/br4-ip.network
;
[Match]
Name=br4
[Network]
Address=172.27.4.13/24
Gateway=172.27.4.1
DNS=172.27.4.1
VLANs are defined as network devices, each in their own .netdev
file. The following example is /etc/systemd/network/vlan4.netdev
;
[NetDev]
Name=vlan4
Kind=vlan
[VLAN]
Id=4
The following file, /etc/systemd/network/vlan4.network
, binds VLAN 4 (defined
above as a network device) to the bridge;
[Match]
Name=vlan4
[Network]
Bridge=br4
The following file, /etc/systemd/network/eno1.network
, binds both a bridge
(untagged, also called a native VLAN), to a physical port.
[Match]
Name=eno1
[Network]
Bridge=br3
VLAN=vlan4