
Ever since I read about
sytemd-networkd being in the making I was looking forward to try it out. I kept watching for the package to appear in Debian, or at least ITP bugs. A few days ago, by accident, I noticed that I already have systemd-networkd on my machine: It is simply shipped with
the systemd package!
My previous setup was a combination of
ifplugd to detect when I plug or unplug the ethernet cable with a plain DHCP entry in
/etc/network/interface. A while ago I was using
guessnet to do a static setup depending on where I am, but I don t need this flexibility any more, so the very simple approach with
systemd-networkd is just fine with me. So after stopping
ifplugd and
$ cat > /etc/systemd/network/eth.network <<__END__
[Match]
Name=eth0
[Network]
DHCP=yes
__END__
$ systemctl enable systemd-networkd
$ systemctl start systemd-networkd
I was ready to go. Indeed,
systemd-networkd, probably due to the integrated dhcp client, felt quite a bit faster than the old setup. And what s more important (and my main motivation for the switch): It did the right thing when I put it to sleep in my office, unplug it there, go home, plug it in and wake it up.
ifplugd failed to detect this change and I often had to manually run
ifdown eth0 && ifup eth0; this now works.
But then I was bitten by what I guess some people call the viral nature of
systemd:
sytemd-networkd would not update
/etc/resolve.conf, but rather relies on
systemd-resolved. And that requires me to change
/etc/resolve.conf to be a symlink to
/run/systemd/resolve/resolv.conf. But of course I also use my wireless adapter, which, at that point, was still managed using
ifupdown, which would use
dhclient which updates
/etc/resolve.conf directly.
So I investigated if I can use
systemd-networkd also for my wireless account. I am not using NetworkManager or the like, but rather keep
wpa_supplicant running in roaming mode, controlled from
ifupdown (not sure how that exactly works and what controls what, but it worked). I found out that this setup works just fine with
systemd-networkd: I start
wpa_supplicant with this service file (which I found in the
wpasupplicant repo, but not yet in the Debian package):
[Unit]
Description=WPA supplicant daemon (interface-specific version)
Requires=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=simple
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -i%I
[Install]
Alias=multi-user.target.wants/wpa_supplicant@%i.service
Then
wpa_supplicant will get the interface up and down as it goes, while
systemd-networkd, equipped with
[Match]
Name=wlan0
[Network]
DHCP=yes
does the rest.
So suddenly I have a system without
/etc/init.d/networking and without
ifup. Feels a bit strange, but also makes sense. I still need to migrate how I manage my UMTS modem device to that model.
The only thing that I m missing so far is a way to trigger actions when the network configuration has changes, like I could with
/etc/network/if-up.d/ etc. I want to run things like
killall -ALRM tincd and
exim -qf. If you know how to do that, please tell me, or answer over at
Stack Exchange.