Getting older, not necessarily wiser!
In this post, the area of systemd we want to explore is networking. Specifically networkd and resolved. Networking in systemd works, but in many cases it can be somewhat more manual and clunky to setup than other methods.
Like other parts of systemd, networking is installed by default with the rest of systemd. If one is using other networking software, systemd networking is still installed. This is starting to sound like a broken record but systemd should be modular as far as the various parts that are not used, parts not used should not be installed by default.
We will be discussing how to setup and configure systemd-networkd. We will also be discussing systemd-resolved in its default configuration, as a discussion of DNS in any depth is beyond the scope of this post.
Before using systemd networking, we should look at shutting down other network services/managers that might interfere. To use systemd networking we need to start it with our old friend systemctl. We can use all the standard options like start, enable, stop, and restart.
$ sudo systemctl enable systemd-networkd $ sudo systemctl start systemd-networkd $ sudo systemctl status systemd-networkd
Configuration of systemd-networkd is done by in a configuration file located at /etc/systemd/network. Each configuration file has .network extension. These are sorted alpha-numericly, and executed in that order. Generally, in many distributions, the names start with numeric values that is basically used to order them. For example; 30-dhcp-eth0.network.
DHCP Setup: On a laptop, for example, we probably do not want a static IP address. Below is an example of a wired DHCP network connection.
$ sudo vi /etc/systemd/network/30-dhcp-enp3s0.network [Match] Name=enp3s0 [Network] DHCP=yes
The Match section contains the name of the network adapter. The Network section specifies the type of network connection, in this case DHCP.
If we are using a wireless connection, this involves some additional software like iwd, as systemd does not have wireless drivers, and needs additional software.
Static Network: If we are running a server, we might want a static IP address. Below is an example of a configuration file for a static IP address.
$ sudo vi /etc/systemd/network/40-static-enp3s0.network
[Match] Name=enp3s0 [Network] Address=192.168.1.50/24 Gateway=192.168.1.1 DNS=192.168.1.1
Match is the same as the above. In Network we need to define our IP address and Network Mask, Gateway, and DNS.
Once the configuration files are setup, we need to restart the service or reboot the computer.
$ sudo systemctl restart systemd-networkd
The systemd-resolved service is a little harder to quantify. It provides DNS services, which most users do not use by default, whether via systemd or another app (broken record again; modularity
). In our example we will use the default configuration of systemd-resolved, which works as a caching DNS server. Like other systemd services we need to start it with systemctl.
$ sudo systemctl enable systemd-resolved $ sudo systemctl start systemd-resolved $ sudo systemctl status systemd-resolved
Configuration can be handled with the /etc/systemd/resolved.conf file. However there is not a lot of configuration one should be doing without a basic understanding of how DNS works (which is out of scope here).
In the basic setup, systemd-resolved should cache recent DNS queries, increasing responsiveness . If DNS information is held in the cache, then the computer does not have to make an external DNS query, as the information is already stored locally.
It is also possible to setup global DNS servers. However these will not be used by a connection using DHCP (see systemd-networkd above), which supplies a DNS server to use. One cannot change this behavior which is a problem (you can do this in other Operating Systems and DNS apps). There are ways to override this behavior, but it is convoluted and out of scope.
If one is an average user, then systemd networking is fairly easy to setup. You basically write your systemd-networkd configuration file, and turn on systemd-networkd and systemd-resolved if desired. And everything should just work.
When it comes to custom configurations, you will probably need to do a little research. Lets face it, while installed by default, it is no where close to something like the network-manager application.
This has been a brief look at systemd networking, that come with systemd. The basic purpose is to get the user up and running with networkd. While there is a lot more to talk about, this should get the majority of users connected.
This has been an interesting road with systemd. I can see the value in light weight installations, however there is to much included that can be handled better by other programs. One of the Unix philosophies is to do one thing and do it well. Another one is user choicer. And while you do have a choice about using the systemd subsystems, you do not have one about installing them if you are using systemd for your init.