systemd-networkd — Network configuration
.netdev Files
Even if you have to create virtual network devices, look no further than networkd. You can use *.netdev
files to configure net devices, which currently means bridges, bonded interfaces, and VLANs. To build a bridge, you create a file named bridge0.netdev
(the file name up to the dot is arbitrary):
[NetDev] Name=bridge0 Kind=bridge
Also, you add the following property to all your network files:
Bridge=bridge0
This defines the device as a member and part of the bridge.
One practical application of such a network bridge is running a virtualization server when the admin needs to open up a path to the physical network for the VMs. For example, I run KVM as a virtualization platform on my computer; it uses a single physical gigabit NIC named enp6s0
(since udev 197) [6]. To add that NIC to a bridge now, I need to perform several steps, starting with static.network
:
[Match] Name=enp6s0 [Network] Bridge=br0
The physical device enp6s0
is assigned a property "part of the bridge named br0
." The bridge is a network device; a file of type netdev
defines it. In my example, the br0.netdev
file looks like this:
[NetDev] Name=br0 Kind=bridge
The bridge now exists, but it still needs a valid IP address. A bridge.network
file takes care of this:
[Match] Name=br0 [Network] Address=172.31.98.12/24 Gateway=172.31.98.250
These three small files complete the configuration, and networkd provides the connection data for the host and the VMs. This is pleasingly simple and easy to understand compared with the previously required systemd service files. For my first KVM setup with systemd on Gentoo Linux, I was forced to do battle with a mile-long service file (/etc/systemd/system/bridge.service
).
At this point, I did two more things to eliminate the need for separate configurations at different locations: First, I enforced full-duplex Gigabit mode. To do so, I needed a line in the local startup script:
ethtool -s enp6s0 speed 1000 duplex fullautoneg on
Second, I enabled Wake-on-LAN (WOL) so I could power on the machine remotely. A separate systemd unit was previously needed, as you can see in Listing 2. Now, both WOL and gigabit connectivity are handled elegantly by a single networkd link file (Listing 3).
Listing 3
/etc/systemd/network/nic1.link
Listing 2
wol@.service
Objectives and Benefits
On most dedicated servers, but also on embedded devices, the network configuration is quite static for the whole service life. Once you have decided on systemd as your init system, networkd covers the entire network setup without a need to install and maintain additional packages.
Moreover, you should see better performance. On my system, the systemd-analyze
tool clocked the start time of systemd-networkd at a fast 3 milliseconds. Retrieving IPs via DHCP is also fast; measurements by the developer show astonishingly short DHCP dialogs – albeit in the laboratory and without checking whether the IP is already in use somewhere else on the subnet.
If you mainly rely on virtualization at the data center, systemd-networkd opens up more options. If a virtual machine is sometimes on one physical host and sometimes on another, it is possible to use LINK files to define the correct network setup within the VM automatically, depending on the current environment.
The network configuration can take place at a very early stage, using initramfs. Combined with the very fast boot and shutdown times that are possible with systemd, networkd makes it easy to switch VMs on and off on demand. You can even manage containers using systemd-nspawn [7].
News and Views
Networkd is increasingly interacting with other systemd subsystems. The systemd-timesyncd daemon added to recent releases and the systemd-resolved daemon (still at an early stage of development) are associated closely with networkd, depending on the status of network connectivity. They ensure the correct synchronization of the system time or set the DNS server. More features are planned, including DNSSEC and M-DNS caching.
When this issue went to press, a DHCPv6 client and a DHCPv4 server were in preparation. The developers have no intention of replacing top dogs like the ISC DHCP server; instead, they are focusing on the special case of container virtualization. A host could use networkd to assign IPs to the containers it operates. Another possible application is running hotspots on mobile devices. These ideas are still under discussion and development.
The systemd-networkd developers are also talking to the maintainers of Gnome NetworkManager and ConnMan to avoid duplication and to create meaningful interfaces.
Infos
- systemd: http://freedesktop.org/wiki/Software/systemd/
- "Init Systems" by Kristian Kißling, Linux Pro Magazine, issue 156, November 2013, p. 42, http://www.linuxpromagazine.com/Issues/2013/156/Init-Systems
- Networkd commits: http://lists.freedesktop.org/archives/systemd-commits/2013-November/004659.html
- systemd-networkd: https://wiki.archlinux.org/index.php/Systemd-networkd#network_files
- Introduction to networkd: https://coreos.com/blog/intro-to-systemd-networkd/
- Predictable network interface names: http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
- systemd-nspawn: https://www.youtube.com/watch?v=s7LlUs5D9p4/
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.