[systemd-devel] Ensuring that a unit starts before any networking

Simon McVittie smcv at collabora.com
Tue Jun 30 11:13:49 UTC 2020


On Tue, 30 Jun 2020 at 11:27:30 +0200, Lennart Poettering wrote:
> On Sa, 27.06.20 15:54, Mark Rogers (mark at more-solutions.co.uk) wrote:
> > Adding After=network-pre.target to dhcpcd.service seems to have
> > resolved it, and taught me a lesson in the process.
> >
> > Is there an obvious reason I'm missing why these aren't distro
> > defaults? (Is this a "bug" in the network management tools' unit
> > files? Would "fixing" this at the distro level have any likely side
> > effects?)
> 
> Yes, this is a bug in the the distro packaging. Please file a bug
> against your distro, so that they add After=network-pre.target.

I would have expected this to be done in some "larger" network management
component that is responsible for bringing up network interfaces according
to your configuration, rather than necessarily dhcpcd.service itself.

You mentioned Raspbian, which is a Debian derivative? On Debian systems,
network device management is typically provided by either ifupdown (the
traditional/historical network management component in Debian),
systemd-networkd, NetworkManager or wicd. If those aren't After
network-pre.target, then they should be.

Typically server-class systems will use either ifupdown or
systemd-networkd, which are ideal for relatively static network
configurations that are set up by a sysadmin. Portable/roaming systems
like laptops will typically use either NetworkManager or wicd, which
are ideal for dynamic network configuration through a GUI (and in
particular, some desktop environments like GNOME have built-in support
for NetworkManager). Desktop and embedded systems could go either way.

In ifupdown, the networking.service and ifup at .service units are ordered
After=network-pre.target, which I think should be sufficient.
NetworkManager.service and systemd-networkd.service also look correct.
However, wicd does not currently appear to have implemented this (I've
opened a Debian bug).

If Raspbian does its own thing rather than recycling Debian components
for this, then it might need a separate bug report.

    smcv


More information about the systemd-devel mailing list