Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #206274 > unrolled thread
| Started by | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| First post | 2019-03-16 12:50 +0100 |
| Last post | 2019-03-18 21:00 +0100 |
| Articles | 10 — 6 participants |
Back to article view | Back to linux.debian.user
systemd: how to start a service (kea DHCP4) after all network interfaces are up? Markus Schönhaber <debian-user@list-post.mks-mail.de> - 2019-03-16 12:50 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? john doe <johndoe65534@mail.com> - 2019-03-16 14:40 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Markus Schönhaber <debian-user@list-post.mks-mail.de> - 2019-03-16 19:40 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Sven Joachim <svenjoac@gmx.de> - 2019-03-16 21:30 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Markus Schönhaber <debian-user@list-post.mks-mail.de> - 2019-03-17 17:20 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Greg Wooledge <wooledg@eeg.ccf.org> - 2019-03-18 13:50 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Markus Schönhaber <debian-user@list-post.mks-mail.de> - 2019-03-18 14:30 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Curt <curty@free.fr> - 2019-03-18 18:50 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Henning Follmann <hfollmann@itcfollmann.com> - 2019-03-18 20:30 +0100
Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? Markus Schönhaber <debian-user@list-post.mks-mail.de> - 2019-03-18 21:00 +0100
| From | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| Date | 2019-03-16 12:50 +0100 |
| Subject | systemd: how to start a service (kea DHCP4) after all network interfaces are up? |
| Message-ID | <xCfZ7-3w0-3@gated-at.bofh.it> |
Hi, I have installed the kea DHCP4 server on a machine running recent stretch and two ethernet interfaces. kea is configured to answer DHCP requests on one of the interfaces. On boot, the kea-dhcp4-server.service is started but doesn't work. It logs this: > DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface enp3s0 is down or has no usable IPv4 addresses configured After manually restarting the service it works fine. 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? What I've tried: 1 Copied /lib/systemd/system/kea-dhcp4-server.service to /etc/systemd/system and added Wants=networking.service After=networking.service to the [Unit] section of the copy. The problem remained. 2 Created a shell script that does a sleep 5 before exec'ing the original /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf and replaced the unit's ExexStart line with the path to this script. 2 does indeed help: the dhcp server works as it should after a reboot. Well, this is a workaround at best, a terrible mess at worst, but it's definitely not a solution. So I hope someone can answer my question above. -- Regards mks
[toc] | [next] | [standalone]
| From | john doe <johndoe65534@mail.com> |
|---|---|
| Date | 2019-03-16 14:40 +0100 |
| Message-ID | <xChHz-4DC-1@gated-at.bofh.it> |
| In reply to | #206274 |
On 3/16/2019 12:31 PM, Markus Schönhaber wrote: > Hi, > > I have installed the kea DHCP4 server on a machine running recent > stretch and two ethernet interfaces. kea is configured to answer DHCP > requests on one of the interfaces. > On boot, the kea-dhcp4-server.service is started but doesn't work. It > logs this: >> DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface enp3s0 is down or has no usable IPv4 addresses configured > After manually restarting the service it works fine. > > 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? > > What I've tried: > 1 Copied /lib/systemd/system/kea-dhcp4-server.service to > /etc/systemd/system and added > Wants=networking.service > After=networking.service > to the [Unit] section of the copy. > The problem remained. > 2 Created a shell script that does a > sleep 5 > before exec'ing the original > /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf > and replaced the unit's ExexStart line with the path to this script. > > 2 does indeed help: the dhcp server works as it should after a reboot. > Well, this is a workaround at best, a terrible mess at worst, but it's > definitely not a solution. So I hope someone can answer my question above. > If your interface is configured by 'systemd', you could try: $ systemctl enable systemd-networkd-wait-online -- John Doe
[toc] | [prev] | [next] | [standalone]
| From | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| Date | 2019-03-16 19:40 +0100 |
| Message-ID | <xCmnU-7CO-7@gated-at.bofh.it> |
| In reply to | #206275 |
John Doe, 16.3.2019 14:18 +0100: > If your interface is configured by 'systemd', you could try: > > $ systemctl enable systemd-networkd-wait-online Thanks, but no, my network configuration is done through /etc/network/interfaces. Therefore this won't help. -- Regards mks
[toc] | [prev] | [next] | [standalone]
| From | Sven Joachim <svenjoac@gmx.de> |
|---|---|
| Date | 2019-03-16 21:30 +0100 |
| Subject | Re: systemd: how to start a service (kea DHCP4) after all network interfaces are up? |
| Message-ID | <xCo6l-k0-3@gated-at.bofh.it> |
| In reply to | #206276 |
On 2019-03-16 19:20 +0100, Markus Schönhaber wrote:
> John Doe, 16.3.2019 14:18 +0100:
>
>> If your interface is configured by 'systemd', you could try:
>>
>> $ systemctl enable systemd-networkd-wait-online
>
> Thanks, but no, my network configuration is done through
> /etc/network/interfaces. Therefore this won't help.
Try "systemctl enable ifupdown-wait-online.service" then.
See bug #912112[1].
Cheers,
Sven
1. https://bugs.debian.org/912112
[toc] | [prev] | [next] | [standalone]
| From | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| Date | 2019-03-17 17:20 +0100 |
| Message-ID | <xCGFX-6aM-3@gated-at.bofh.it> |
| In reply to | #206277 |
Sven Joachim, 16.3.2019 21:11 +0100: > On 2019-03-16 19:20 +0100, Markus Schönhaber wrote: > >> John Doe, 16.3.2019 14:18 +0100: >> >>> If your interface is configured by 'systemd', you could try: >>> >>> $ systemctl enable systemd-networkd-wait-online >> >> Thanks, but no, my network configuration is done through >> /etc/network/interfaces. Therefore this won't help. > > Try "systemctl enable ifupdown-wait-online.service" then. > See bug #912112[1]. Thanks for the info! But alas, since I'm on stretch, it isn't that easy, since the ifupdown package there provides neither the ifupdown-wait-online.service file nor the wait-online.sh script. I've downloaded the .deb for buster and tried to extract the relevant files from there and install them on my system, but I didn't manage to get that working in a way that the DHCP server was kept from starting too early. Due to the lack of time I'll refrain from trying to find out what I may have done wrong. And since there seems to be no out-of-the-box solution for this problem on stretch anyway, I'll stick to my ugly workaround for now and hope this will be sorted out in buster. That said, thanks again for pointing me in the right direction! -- Regards mks
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2019-03-18 13:50 +0100 |
| Message-ID | <xCZSi-1wW-1@gated-at.bofh.it> |
| In reply to | #206274 |
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. Don't forget the daemon-reload.
[toc] | [prev] | [next] | [standalone]
| From | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| Date | 2019-03-18 14:30 +0100 |
| Message-ID | <xD0v0-1Zg-5@gated-at.bofh.it> |
| In reply to | #206302 |
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. -- Regards mks
[toc] | [prev] | [next] | [standalone]
| From | Curt <curty@free.fr> |
|---|---|
| Date | 2019-03-18 18:50 +0100 |
| Message-ID | <xD4yB-4pz-1@gated-at.bofh.it> |
| In reply to | #206306 |
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
[toc] | [prev] | [next] | [standalone]
| From | Henning Follmann <hfollmann@itcfollmann.com> |
|---|---|
| Date | 2019-03-18 20:30 +0100 |
| Message-ID | <xD67n-5v4-1@gated-at.bofh.it> |
| In reply to | #206274 |
On Sat, Mar 16, 2019 at 12:31:50PM +0100, Markus Schönhaber wrote: > Hi, > > I have installed the kea DHCP4 server on a machine running recent > stretch and two ethernet interfaces. kea is configured to answer DHCP > requests on one of the interfaces. > On boot, the kea-dhcp4-server.service is started but doesn't work. It > logs this: > > DHCPSRV_OPEN_SOCKET_FAIL failed to open socket: the interface enp3s0 is down or has no usable IPv4 addresses configured > After manually restarting the service it works fine. > > 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? > > What I've tried: > 1 Copied /lib/systemd/system/kea-dhcp4-server.service to > /etc/systemd/system and added > Wants=networking.service > After=networking.service > to the [Unit] section of the copy. > The problem remained. > 2 Created a shell script that does a > sleep 5 > before exec'ing the original > /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf > and replaced the unit's ExexStart line with the path to this script. > > 2 does indeed help: the dhcp server works as it should after a reboot. > Well, this is a workaround at best, a terrible mess at worst, but it's > definitely not a solution. So I hope someone can answer my question above. > > -- > Regards > mks > I am coming late to this thread. Have you considered to switch from /e/n/i to systemd-networkd? I think that would solve the problem. -H -- Henning Follmann | hfollmann@itcfollmann.com
[toc] | [prev] | [next] | [standalone]
| From | Markus Schönhaber <debian-user@list-post.mks-mail.de> |
|---|---|
| Date | 2019-03-18 21:00 +0100 |
| Message-ID | <xD6Ap-5FF-5@gated-at.bofh.it> |
| In reply to | #206331 |
Henning Follmann, 18.3.2019 20:07 +0100: > Have you considered to switch from /e/n/i to systemd-networkd? > I think that would solve the problem. No, I'm not considering to switch the entire way of configuring the network just to (maybe) get something working which I'd call a pretty basic feature. I don't even know what else might be affected by such a switch (scripts in if-up.d, whatever...). -- Regards mks
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web