Cron to reset OpenVPN client

Started by PimB, July 02, 2018, 08:10:30 PM

Previous topic - Next topic
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

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

July 03, 2018, 10:24:09 PM #2 Last Edit: July 03, 2018, 10:27:33 PM by PimB
Thank you, that does the trick! It see it reloads all connections. Is it possible to narrow it down to just VPN?

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