Auto Reconnect after disconnection

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
Zibeo
OpenVpn Newbie
Posts: 2
Joined: Thu Apr 21, 2011 8:50 pm

Auto Reconnect after disconnection

Post by Zibeo » Tue May 03, 2011 9:01 pm

I'm having a bit of an issue with my OpenVPN client. If for some reason it loses connectivity, whether it be an ISP issue, cable disconnection, or something else, the client doesn't automatically reconnect to the VPN. I need it to be able to automatically reconnect no matter how long it's been disconnected, or if the PC was booted up while the network was down.

I'm running on Windows and have written a vbs script that gets executed every 5 minutes from within my application.

The vbs file writes an "ipconfig" to a txt file then checks to see if the VPN IP address is in the txt file. If so it stops since it's connected to the VPN. If not, it executes the following:

c:\Program Files\OpenVPN Technologies\OpenVPN Client\core\openvpn --config vpnconfig.ovpn

It's unreliable though.

Is there a better way to make sure a client always tries to reconnect even if the network's gone down (and comes back up), or the client boots up while the network's down?

User avatar
krzee
Forum Team
Posts: 728
Joined: Fri Aug 29, 2008 5:42 pm

Re: Auto Reconnect after disconnection

Post by krzee » Thu May 12, 2011 9:44 am

use a keepalive
--keepalive in the manual
you may also need persist-key and persist-tun

Post Reply