OpenVPN Script for Switching VPN Server via Crontab
I currently have a OpenVPN Client configured on the pfsense to connect to my VPN Provider. In my configuration, I have specified the VPN Server that the client/pfsense should connect to (eg: region1.vpn.provider.com). What I would like is to do, via a cron job, is to switch to a set different VPN server (eg: region2, region3, ..) every 4 hours via a script. Logic for the script should be something like:
1. Disable VPN Client Configuration, if not already disabled. 2. Change "***server or host address*** field to reflect a different VPN server 3. Save configuration 4. Enable VPN Client Configuration.
Does anyone already have a similar script and would be willing to share?
Konstanti last edited by Konstanti
@rsaanon You can consider this option
- installed is 1,2.3 .... OpenVPN tunnels
- Firewall / schedules - create a schedule for firewall rules (1,2,3....schedules = openvpn tunnels)
- create a few rules on the lan interface, each of them set the gateway OpenVPN tunnel (rule 1-tunnel 1 schedule 1, rule2-tunnel2-schedule 2,.... )
@konstanti Good idea!, but due to VPN Provider concurrent tunnel limit, I won't be able to create multiple tunnels and keep all the connections alive at the same time. Thanks for the suggestion.
Konstanti last edited by
@rsaanon What vpn provider ? For example , Nordvpn supports up to 6 simultaneous connections
@konstanti I get 3 simultaneous connections; One connection is dedicated to the pfSense box. The other two are used on family laptops when travelling.