Introduction
As the letter ‘d’ in the name of “systemd-networkd” infers for “daemon” mode, this service is meant to manage all network stuff in the background rather than “NetworkManager” is for setting network graphically up with the help of its GUI.
I wanted to switch to “systemd-networkd” in my Ubuntu Linux machine for the sake of getting some kind of Linux experience and also getting rid of the distracting message of the “NetworkManager” — alerting about its failure on registering the network. For that reason, after searching, I came up with a set of relatively easy commands to handle.
Approach
The core concept of this transition is very basic, and you need just turn off one service and turn on another service by using “systemctl” — this is for controlling and managing “systemd” services.
Meanwhile, we can use “netplan” — I already used this helper, even so, we could simply write the instruction of our network configuration manually, which should be in “/etc/systemd/network” and be named whatever your preference is, with a mandatory extension as “.network”.
Commands
Firstly, we need to turn off the current service, which is “NetworkManager” with the following commands.
sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager
sudo systemctl mask NetworkManager
So, we should make “systemd-networkd” turned on along the following commands.
sudo systemctl unmask systemd-networkd
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
Netplan
Now, our helper, “netplan” will come to action. The “netplan”as a facilitator uses a “.yaml” file to generate an appropriate configuration for the “systemd-networkd” and also force it to use that instruction. This file should be inside the “/etc/netplan” and a quick sample of that for a machine with both “Ethernet” and “WiFi” is as follows:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: true
dhcp6: true
wifis:
wlp2s0b1:
dhcp4: yes
dhcp6: yes
access-points:
"network_ssid_name":
password: "**********"
This file might be available at this address “/etc/netplan” and what you have to do is just edit it!
In this link, “netplan.io/examples”, you can find various examples of “.yaml” file instructions for several scenarios.
Suggestions
Please consider a backup, as it is highly recommended to provide a backup of this file to avoid any possible trouble and make the confidence of having a restore point.
Notice that two keywords in this “.yaml” sample file — “enp3s0” and “wlp2s0b1” — are hardware id’s and for your case, you should find and bring your device’s networks’ id’s which are easily achievable by these commands:
ip a
# or
ip addr
Last Commands
As it is mentioned, we need to produce instruction to “systemd-networkd” which is basically could be provided by these commands successively:
sudo netplan generate
sudo netplan apply
Note that, you are not going to have any change in your system at this moment, and in fact, upon the first restart of the machine, your “systemd-networkd” service will take control and manage your machine’s network.
Testing
To ensure that whether our machine is managing by “systemd-networkd”, all we have to do is using this command:
networkctl
And in case of success, we should receive a response like this:
IDX LINK TYPE OPERATIONAL SETUP _______________________________________
1 enp3s0 ether routable configured
2 wlp2s0b1 wlan routable configured
That means we are all set and ready to go.
Network Menu
While the NetworkManager is disabled, its GUI shows an error message that is totally okay and should be ignored.