Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenRC how to make OpenVPN start after any network interface
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
mayride
n00b
n00b


Joined: 21 Oct 2019
Posts: 8

PostPosted: Mon Nov 25, 2019 10:30 pm    Post subject: OpenRC how to make OpenVPN start after any network interface Reply with quote

Hello community,

In OpenRC, how can I make OpenVPN start after any network interface?
The goal is to make it restart after resuming from sleep mode and after restarting net.wlp3s0 for example.

I've tried using rc_after in /etc/conf.d/openvpn without success.
Using rc_want in /etc/conf.d/net makes it start when net.wlp3s0 service is started, but not when I resume from sleep mode. And if for any reason, openvpn is started but has a connection failure with the server, it wont restart as well.

Thanks
Back to top
View user's profile Send private message
papas
Tux's lil' helper
Tux's lil' helper


Joined: 01 Dec 2014
Posts: 112
Location: Athens

PostPosted: Tue Nov 26, 2019 2:22 pm    Post subject: Reply with quote

Ooops misunderstanding sorry :oops:
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1847

PostPosted: Wed Nov 27, 2019 7:13 pm    Post subject: Reply with quote

OpenVPN is able to reconnect after connection drops - if configured properly.
Which can be somewhat tricky, if you have multiple gateways on the other side, since you may get rerouted to a new gateway through - now broken - tunnel.

Suspending does not cause net service to restart, so openvpn will not be restarted by openrc because of dependencies. However, you can track other events too. E.g. I have defined a hook in /etc/pm/sleep.d to restart some services after resuming from suspend.
Since those hooks are executable programs, you can just throw a simple shell script there.
Back to top
View user's profile Send private message
axl
l33t
l33t


Joined: 11 Oct 2002
Posts: 908
Location: Romania

PostPosted: Wed Nov 27, 2019 8:43 pm    Post subject: Reply with quote

Me personally I use this sort of stuff. I call it my network hypervisor.

Network can be in more than one state. I as an operator I know in which state it is by using ping. If the host replies... figure out logic... bla bla.

But could be any other kind of test. Ping, traceroute, maybe some service test. Whatever it is, it is a shell command which you run. You get some output of the command or read the $? return and figure out if it's ok or not. Do logic, make decision.

Me personally I run a continuously self aware daemon that reads the logs. But before it was that, it was a cron script that executed every minute. if ping wrong... logic... make decision.

OpenRC doesn't have a way to follow events on the system. OpenRC is unaware of what the system is doing. So you will have to create a ... something to first look for some information every once in a while (cron 1 minute is my suggestion), do some logic, take a decision and then start openvpn or whatever.
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