[Nix-dev] [systemd] ip-up target params

Eelco Dolstra eelco.dolstra at logicblox.com
Thu Sep 13 01:06:51 CEST 2012


Hi,

On 12/09/12 11:12, Mathijs Kwik wrote:

> Currently (with upstart), network interfaces tigger ip-up once dhcpcd
> assigns them an ip-address.
> Upstart triggers had an option to supply extra params, and dhcpcd's
> hook used this to supply information on which interface got connected,
> and - if on wireless - to which AP a connection was made.
> 
> I have a somewhat complicated networking setup, so I use these features a lot.
> Depending on which wifi AP (trusted/untrusted), I enable different
> firewall rules, openvpn tunnels and routes.
> 
> Now, I think I should just define systemd targets for these
> environments (trusted/untrusted/home) and add the services I want to
> these.
> However, I need a way to tell upstart which of these targets to (de)activate.
> Currently, "ip-up" is hardcoded in dhcpcd's hook, "ip-down" is
> disabled (used to trigger when disconnecting wifi), and if multiple
> interfaces come up, nothing will happen if the ip-up target was
> already reached.

Systemd units have a template instantiation mechanism which might be useful
here.  We can have units "if-up at .target" and "if-down at .target" that get
instantiated when a specific interface goes up or down.  So if wlan0 appears, we
can instantiate "if-up at wlan0.target", which in turn can pull in other dependencies.

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list