Single openVPN client restart with cron

Started by MartinsZB, July 25, 2019, 01:39:42 PM

Previous topic - Next topic
Hi!

I did read a lot of information, but can not figure out the following. I have two openVPN clients running. I would like to restart one of them using cron.

I find that I can restart whole openVPN service, but can not figure out, how to restart single client? It can be nicely done manually from GUI, but is it possible to schedule the restart?

Thanks,
Martins

As far as I know OpenVPN runs on virtual interfaces. You could make an up/down script that restarts that interface.

Thanks! I tried the following.
My openVPN client is ovpnc3. If I do the "ifconfig ovpnc3 down" - under the interfaces it shows it as inactive. Although the client connection to VPN server seems still active. "ifconfig ovpnc3 up" brings the interface back up, but still with the same VPN connection.

What I want is to reconnect the openVPN client as I have multiple VPN servers defined with "select random server" activated.

July 26, 2019, 06:05:03 PM #3 Last Edit: July 26, 2019, 06:08:06 PM by birdpark
What about using something like screen. Are you familiar with the screen command? I dont have other ideas
If it works, give me some karma or applause

Don't know if it helps but I found when the OPENVPN interface went down they just start using the standard gateway. I got around this by creating a new vlan only for the VPN clients and not OUTBOUND natting this vlan (all the rest of the setup was normal). Could this be what you are seeing when you down the interface, them flicking to another gateway to get out?

August 01, 2019, 07:56:07 PM #5 Last Edit: August 01, 2019, 08:46:11 PM by johnw230873
opps - wrong topic ;)