OPNsense Forum

Archive => 18.1 Legacy Series => Topic started by: PimB on July 02, 2018, 08:10:30 PM

Title: Cron to reset OpenVPN client
Post by: PimB on July 02, 2018, 08:10:30 PM
I have multiple servers in my OpenVPN client config with 'random server' turned on. I'd like to reset the connections automatically (via cron?) so it switches between these servers. Can and if so, how can I do that?

Thanks for helping
Title: Re: Cron to reset OpenVPN client
Post by: franco on July 03, 2018, 09:55:26 PM
If you go to /usr/local/opnsense/service/conf/actions_service.conf and add the following line to [reload.all] :

description:Reload all services

It should bring up the service in the Cron GUI to be used.

This is lost on firmware updates. Maybe it does what you want, so we can use that as a base for discussion. :)


Cheers,
Franco
Title: Re: Cron to reset OpenVPN client
Post by: PimB on July 03, 2018, 10:24:09 PM
Thank you, that does the trick! It see it reloads all connections. Is it possible to narrow it down to just VPN?
Title: Re: Cron to reset OpenVPN client
Post by: franco on July 04, 2018, 08:06:57 PM
Yes, it's possible to narrow it down to VPN.

Create a new file e.g. /usr/local/opnsense/service/conf/actions.d/actions_custom.conf and add the following:

[vpn]
command:pluginctl vpn
parameters:
type:script_output
message:Reloading VPN subsystem
description:Reload VPN subsystem

You can test it using:

# configctl custom vpn

And it should output something like this:

Configuring IPsec VPN...done.
Syncing OpenVPN settings...done.


Cheers,
Franco