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.

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.

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
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: "**********"

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.

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

Testing

To ensure that whether our machine is managing by “systemd-networkd”, all we have to do is using this command:

networkctl
IDX LINK    TYPE  OPERATIONAL   SETUP _______________________________________
1 enp3s0 ether routable configured
2 wlp2s0b1 wlan routable configured

Network Menu

While the NetworkManager is disabled, its GUI shows an error message that is totally okay and should be ignored.

Image for post
Image for post
Screenshot of the Network Menu on Settings (Ubuntu)

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