Using systemd-networkd on Ubuntu as networking backend

Recently I came across a use case where on a product-line, we needed to use systemd-networkd as networking back-end. The product in question was using a very old networking back-end and the newer version of Linux was going along with systemd.
So along came some thoughts on netplan which is a tool developed by canonical which abstracts both NetworkManager and systemd-networkd. Basically user provides network configuration via yaml configuration files and netplan creates back-end configuration automatically depending on whichever back-end is in use.

Now, the version of Ubuntu I was using (22.04) had NetworkManager enabled and it also had systemd-networkd available but disabled. So my first step was to stop and disable NetworkManager.
#systemctl stop NetworkManager
#systemctl disable NetworkManager

Next enable systemd-networkd and observe it's status if there is a successful startup:
#systemctl enable systemd-networkd
#systemctl start systemd-networkd
#systemctl status systemd-networkd

No errors observed.

Below command lists all systemd-services available on the system.
#systemctl --type=service

Next step was to check in /etc/netplan directory for existing configuration.
There 01-network-manager-all.yaml file was present

#cat 01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager

As we can see, all interfaces are managed by NetworkManager.

Next we set networkd configuration in /etc/netplan and restart systemd-networkd.

To list all networking links
# ip link show

To list all link address info
#ip address show

New configuration file 01-networkd-all.yaml as below:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: yes

Now we apply new configuration
#netplan apply

Restart networkd
systemctl stop systemd-networkd
systemctl start systemd-networkd

Then check ethernet address using:
#ip address show

Everything seemed to be in order and ethernet was up.

Next I tried to configure static interface:
#cat 01-networkd-static.yaml
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: no
addresses: [192.168.1.222/24]
nameservers:
addresses: [8.8.8.8,8.8.4.4]
routes:
- to: default
via: 192.168.1.1

This also worked fine.

Comments

Popular posts from this blog

Morning Quotes

QCalendarWidget CSS Stylesheeting