[systemd-devel] starting/stopping network interfaces with systemd

Mirco Tischler mt-ml at gmx.de
Sun Oct 9 04:52:11 PDT 2011


2011/10/9 Cliff Brake <cliff.brake at gmail.com>:
> On Sat, Oct 8, 2011 at 11:09 AM, Cliff Brake <cliff.brake at gmail.com> wrote:
>>> and a service file like this:
>>>
>>> cat networl at .service:
>>> [Service]
>>> Type=oneshot
>>> RemainAfterExit=yes
>>> ExecStart=/sbin/ifup %i
>>> ExecStop=/sbin/ifdown %i
>>> StandardOutput=syslog+console
>>
>> I'm still not successfull in getting ifup to run on boot (after the
>> NIC is detected) or on NIC insertion.
>
> This is actually working for me now on bootup, or first NIC insertion.
>  I'm not sure what I did wrong earlier -- perhaps missed reloading the
> systemd config files or something ...
Cool

> However, it does not work for subsequent NIC insertions.  It appears
> that stop is not getting executed when the device is removed, as
> network at eth0.service is always listed as active after the NIC is
> installed, and then removed.
Hmm, true. I wonder if the ExecStop line is really necessary, as it
doesn't make sense to execute this after the device is plugged out. So
if you drop this, you can drop the RemainAfterExit as well and it
should work for subsequent insertions.

Another way that comes to mind might be to add
ENV{SYSTEMD_ALIAS}="/$name" to the udev rule and add
"BindTo=%i.device" in the unit section of the service file.

> Cliff
>
Mirco


More information about the systemd-devel mailing list