ads' corner

if-up and if-down scripts with systemd

Everybody likes systemd, right? Well, not everybody. Who thought it might be a good idea to replace existing init systems with something which is big, monolithic, and not even feature complete?

A simple task: execute a script when an interface comes up, or goes down.

In the old days, on Debian or Ubuntu, one just added pre-up and post-down scripts in /etc/network/interfaces. But now, that file is gone, or empty. Ubuntu comes with netplan, which nobody else seems to use - luckily. NetworkManager is not used all the time, so one can’t depend on that either. And systemd does not have an option to do something simple like taking care of interfaces coming up and down. You can write yourself a target, but that only fires for the first time, not every time.