A New Year Project - Debian Networking
Spending the Holidays in the stack
LinuxChristmas is a time of year for family, friends, presents, Turkey and yes, Linux networking.
It’s a strange holiday tradition to have. But I like to brush up on various Linux skills over Christmas when things calm down. Work starts to take it easy and the kid is old enough to lap up hours of Minecraft and YouTube. It’s a perfect time to get stuck into a simple and useful project.
This year I’m going to take a look at systemd-networkd
because quite frankly, it’s not going anywhere and will probably become the default Network Manager in the future. But there are others that dominate the Linux world, so I wanted to brush up on the basics and see what, if any, would be a good enough reason to switch.
Debian History - ifupdown
Long before we ever needed a Network Manager, things were managed with a simple interfaces
file and a handful of common network tools. In fact, this all still works perfectly today in Debian 12 and is still arguably the quickest way to get a static IP configured when you’re using a system without a GUI.
Things took a turn for the worse when Wi-Fi came along. ifupdown
had to rely on a second package, wpasupplicant
which enabled the use of pre-shared keys in the interfaces
config. This worked, but caused a few headaches for administrators who forgot to either hash the key, or lock down the permissions so that users couldn’t read it.
Still, it worked quite well.
Enter NetworkManager
Things got even better when NetworkManager came onto the scene in the mid 200’s. No need to edit configuration files! Instead you could create profiles for each interface and have NetworkManager
handle all the details. It’s main purpose was to fix issues with roaming between networks, something Linux was terrible at doing in the early 2000’s when users were just starting to switch between Wi-Fi and Wired connections. While it was possible to use NetworkManager
without the GUI elements, it wasn’t ideal. GUI-less servers still had to do things the old fashioned way.
Killing ifconfig
After years of faithful service, ifconfig
was deprecated in Debian and many other distributions in favour of iproute2
. While a sad moment for us old hacks, it made sense to bring multiple network tools together under one package.
This action kicked off a whole modernization era within Linux networking, and we saw the rise of systemd
wanting to expand its already overbearing reach into the network stack.
OK, but it’s really easy
systemd-networkd
brings a lot of sense to network configuration (including the frustrating yet true to form case-sensitivity!). For example, to configure a basic wired ethernet adapter, we simply create the following:
[Match]
Name=eth0
[Network]
DHCP=ipv4
Saved as /etc/systemd/network/10-eth0.network
, this sets our Ethernet adapter to use DHCP. Easy eh?
It’s important to make sure you move any existing interfaces
out of the way, otherwise they may override the systemd-networkd
settings during boot. This can be easily done by moving the file to interfaces.old
or something similar.