Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[systemd] Force network to wait for DHCP
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
wichtounet
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2012
Posts: 122

PostPosted: Thu Sep 25, 2014 5:20 pm    Post subject: [systemd] Force network to wait for DHCP Reply with quote

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
View user's profile Send private message
charles17
Advocate
Advocate


Joined: 02 Mar 2008
Posts: 3664

PostPosted: Fri Sep 26, 2014 5:38 am    Post subject: Reply with quote

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
View user's profile Send private message
wichtounet
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2012
Posts: 122

PostPosted: Wed Oct 01, 2014 6:52 am    Post subject: Reply with quote

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
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Oct 01, 2014 7:01 am    Post subject: Reply with quote

systemd has a something-wait-online service you can use.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
wichtounet
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2012
Posts: 122

PostPosted: Wed Oct 01, 2014 3:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
wichtounet
Tux's lil' helper
Tux's lil' helper


Joined: 17 Mar 2012
Posts: 122

PostPosted: Wed Oct 01, 2014 4:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum