Finally: systemd-networkd to the rescue

People like me, working with different Linux distributions and automation, are always looking for ways to simplify and bridge the different configuration styles of system configuration into a unified way. Up to a point where it does not matter if you prefer Ubuntu, Debian, RedHat, CentOS or what ever your choice of Linux OS is. Finally systemd comes to the rescue to solve the network configuration issue using the systemd-networkd manager.

So how can you manage network configuration using systemd-networkd ?

First check if you actually have it installed and running with

systemctl status systemd-network

If the service is not enabled, just enable it after you have added your interfaces.

To configure interfaces, or more precisely networks in systemd, you only need to add a config file with a .network suffix. In my case /etc/systemd/network/ens33.network:

[Match]
Name=ens33

[Network]
DHCP=ipv4

[Address]
Address=10.0.2.15/24

[Address]
Address=10.0.3.15/24

The example above enables DHCP (v4) on the network interface ens33, a VMWare interface and yes I run VMWare on my MacBook, while additionally adding secondary IP addresses for haproxy testing purposes.

Once the configuration is completed, enable and restart the systemd-networkd service:

systemctl enable systemd-network
systemctl restart systemd-network

The networkctl command can now be used to monitor the lifecycle of an network:

Pretty cool, right! Finally one network manager to rule them all.

More information can be found at the systemd-networkd man page, documenting many more available options via http://man7.org/linux/man-pages/man5/systemd.network.5.html