[systemd-devel] Launching a unit when a network interface is configured?
Mantas Mikulėnas
grawity at gmail.com
Sun Jul 12 15:18:18 PDT 2015
On Mon, Jul 13, 2015 at 12:50 AM, Toke Høiland-Jørgensen <toke at toke.dk>
wrote:
> Hi
>
> I'm trying to port a set of traffic shaping scripts (sqm-scripts) from
> OpenWrt to Arch Linux. I would like to be able to have a systemd unit
> be run when an interface is configured (by systemd-networkd). Kinda like
> the if-up.d facility in some distros, I guess...
>
> I figured out that I can depend on the interface *appearing* by using
>
> BindsTo=sys-subsystem-net-devices-%i.device
> After=sys-subsystem-net-devices-%i.device
>
> ...but is there also a way to get a unit to run when an interface is
> configured?
>
Systemd doesn't know when an interface is /finally/ configured (e.g. maybe
the configurator added one address but is still about to add more; maybe it
added an IPv6 address but is still waiting for DHCPv4; maybe it finished
with addresses but is still configuring routes...)
So you really need this to be part of the configurator itself. As a direct
equivalent to if-up.d, NetworkManager has dispatcher.d, but
systemd-networkd doesn't yet have anything such.
However, both NM and networkd have "is-online" tools, for example,
*systemd-networkd-wait-online.service*, which your unit can depend on. Note
that by default it waits for *all* interfaces to be configured; if you only
need a specific one, you can create your own (instanced/templated) version
that would use "--interface=%i". See also `man
systemd-networkd-wait-online`.
--
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150713/43834641/attachment.html>
More information about the systemd-devel
mailing list