I use OpenVPN to connect to a VPN service. I will often use it unattended and on occasion I have come back to find the service disconnected and GUI asking for login credentials. If the connection is disconnected by the service, and not me, I'd like it to attempt to reconnect automatically with no intervention from me, and ideally, if the reconnection attempt initially fails, keep attempting to do so at regular intervals until a connection is successfully.

Is there anyway to configure OpenVPN to do this? If not, can someone suggest a way of doing it with scripting (I use Windows)? Failing that, can anyone suggest a VPN solution that does this? The VPN provider supports PPTP as well as OpenVPN.

I have configured OpenVPN to read login credentials from a file. Below is my config script. I have censored any details specific to the VPN provider.

dev tun
proto tcp
remote ???.???.??? 0000
resolv-retry infinite
ca ???.???.???
verb 3
reneg-sec 0
auth-user-pass auth.conf

Thanks for your help.


Have you tried removing the auth-nocache option? This option disables caching of your login credentials. If your login credentials are not cached, then the system cannot attempt to re-establish a session, after a disconnection.

  • I think IAmAI is try to do the opposite of what you are suggesting...?
    – David
    Dec 10 '12 at 19:51
  • @Jikag, the question is vague, but I am choosing to interpret this statement as the main question. I'd like it to attempt to reconnect automatically with no intervention from me. AFAIK, re-connections cannot happen without cached credentials.
    – Zoredache
    Dec 10 '12 at 19:55
  • Ah, my mind skipped one of the negatives in your reply, so I thought you were telling them to remove cached credentials became confused. Thanks,
    – David
    Dec 10 '12 at 19:57
  • Thanks Zoredache, that makes sense. Not suse how to test is works without waiting for to disconnect by itself. Dec 10 '12 at 21:26
  • Connect the VPN, then temporarily pull your network cable out?
    – Zoredache
    Dec 10 '12 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.