Switching from NetworkManager to systemd-networkd

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 managingsystemdservices.

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.

So, we should make “systemd-networkd” turned on along the following commands.

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:

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:

Last Commands

As it is mentioned, we need to produce instruction to “systemd-networkd” which is basically could be provided by these commands successively:

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:

And in case of success, we should receive a response like this:

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.

Graduate Alumni from AUA

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store