Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up?
On 2019-03-18, Markus Schönhaber <debian-user@list-post.mks-mail.de> wrote:
> Greg Wooledge, 18.3.2019 13:30 +0100:
>
>> On Sat, Mar 16, 2019 at 12:31:50PM +0100, Markus Schönhaber wrote:
>>> It seems that the DHCP server is started while the interface it is
>>> configured to listen on is not yet up and therefore refuses to work.
>>> How can I make sure that the kea-dhcp4-server.service is started no
>>> sooner than after all network interfaces are up?
>>
>> 1) Make sure the interface is marked "auto" and NOT "allow-hotplug"
>> in /etc/network/interfaces.
>>
>> Interfaces that are marked "auto" are required to be up before systemd
>> will consider network-online.target to be satisfied. Interfaces that
>> are marked "allow-hotplug" are NOT required to be up.
>>
>> Note that the Debian installer marks all interfaces except loopback
>> as "allow-hotplug" because it assumes you're using a laptop with a
>> Wifi or removable USB network interface, even if the interface is
>> actually PCI and internal, or even soldered to the motherboard, even
>> if the machine you're installing on is a desktop PC or a rack-mounted
>> server.
>>
>> 2) Make sure your service has
>>
>> [Unit]
>> Wants= network-online.target
>> After= network-online.target
>>
>> either in the native unit file, or in a local drop-in directory.
>>
>> Services with these options will wait for all network interfaces that
>> are marked "auto" to be brought up, before these services can be
>> started.
>
> 1) and 2) was already the case on my machine. Nevertheless the service
> was started before the needed interface was up.
> That's why I asked in the first place.
>
> Judging from the info in the other answers I got, it's obviously known
> that 1) and 2) are *not* enough to make sure the start of such a service
> is delayed until the required interfaces are up.
>
Workaround help perhaps in this thread:
https://unix.stackexchange.com/questions/209832/debian-systemd-network-online-target-not-working/217768
--
“Let us again pretend that life is a solid substance, shaped like a globe,
which we turn about in our fingers. Let us pretend that we can make out a plain
and logical story, so that when one matter is despatched--love for instance--
we go on, in an orderly manner, to the next.” - Virginia Woolf, The Waves
Reply to: