I'm running an OpenVPN client on opnsense to a VPN provider for all my network devices to share. I would like to reconnect daily to refresh the IP. Looking at the standard Cron options there is 'Periodic interface reset' which doesn't seem to create a new IP when used on the VPN interface. I see there is also 'Restart Wireguard'. But nothing for OpenVPN by default.
Can anyone offer a suitable command and parameters to cron an OpenVPN disconnect / reconnect? Any help greatly appreciated.
Got what I needed working. Instead of leaving this as a worthless empty post for someone to trip over while searching for a solution (be handy if we could delete posts?), here's what I did in summary:
1. SSH into OPNsense as root or a user with su
2. Go to: /usr/local/opnsense/service/conf/actions.d/
3. Create a new file called something like: actions_custom.conf
4. File should contain:
[stop]
command:/usr/local/sbin/pluginctl -s openvpn stop
parameters:
type:script_output
message:stop openvpn service
description:Stop OpenVPN Service
[start]
command:/usr/local/sbin/pluginctl -s openvpn start
parameters:
type:script_output
message:start openvpn service
description:Start OpenVPN Service
[restart]
command:/usr/local/sbin/pluginctl -s openvpn restart
parameters:
type:script_output
message:restart openvpn service
description:Restart OpenVPN Service
5. Once saved, load the new template using: # service configd restart
6. In OPNsense GUI go to: System > Settings > Cron
7. Click + to add a new job and under the 'Command' lookup you should see the new Stop, Start and Restart OpenVPN options listed.
Hey, it worked perfectly on my setup. Thanks a lot for sharing, i created an account to thank you lol
Good to know it was useful!