View previous topic :: View next topic |
Author |
Message |
wichtounet Tux's lil' helper
Joined: 17 Mar 2012 Posts: 122
|
Posted: Thu Sep 25, 2014 5:20 pm Post subject: [systemd] Force network to wait for DHCP |
|
|
Hi,
I'm using systemd-networkd to configure my interfaces:
Code: | [Match]
Name=enp3s0
[Network]
DHCP=v4 |
It works quite well except that at boot, some services are not waiting for DHCP to finish. For instances my NFS-mounted directories and nginx fail because there is no network at the time they boot.
Is there a way to force systemd-networkd to wait for DHCP or another target to wait for in the other service files ?
Thanks |
|
Back to top |
|
|
charles17 Advocate
Joined: 02 Mar 2008 Posts: 3664
|
Posted: Fri Sep 26, 2014 5:38 am Post subject: |
|
|
No idea if it would help solving your problem, as I am not too familiar with systemd.
For dhcpcd with OpenRC I've created an article on https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD and I think a similar solution should be possible also for systemd.
If so, you might possibly be able to go completely without systemd-networkd? |
|
Back to top |
|
|
wichtounet Tux's lil' helper
Joined: 17 Mar 2012 Posts: 122
|
Posted: Wed Oct 01, 2014 6:52 am Post subject: |
|
|
charles17 wrote: | No idea if it would help solving your problem, as I am not too familiar with systemd.
For dhcpcd with OpenRC I've created an article on https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD and I think a similar solution should be possible also for systemd.
If so, you might possibly be able to go completely without systemd-networkd? |
Thanks, but that doesn't really help. I would like to avoid using another DHCP client. The network works, but it just doesn't wait for DHCP.
I've seen now that services should wait for
{After,Wants}=network-online.target
but what about NFS mount for instance ? |
|
Back to top |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
wichtounet Tux's lil' helper
Joined: 17 Mar 2012 Posts: 122
|
Posted: Wed Oct 01, 2014 3:34 pm Post subject: |
|
|
UberLord wrote: | systemd has a something-wait-online service you can use. |
Yes, I saw that.
I tried to override sshd.service with a sshd.service.d folder and add Wants/After=network-online.target, but the result is the same, it doesn't wait for dhcp to obtain an address. network is marked as online directly when network-online starts |
|
Back to top |
|
|
wichtounet Tux's lil' helper
Joined: 17 Mar 2012 Posts: 122
|
Posted: Wed Oct 01, 2014 4:09 pm Post subject: |
|
|
I found a solution
There is systemd-networkd-wait-online service that can be enabled and that will cause network-online to wait. Without that, network-online.target seems to be useless.
Moreover, there seems to be a problem in systemd-215, cause I had to upgrade to systemd-216 for this to work. Now, I have overriden all the necessary service files and targets and everything works |
|
Back to top |
|
|
|