Jump to content
Not connected, Your IP: 18.222.167.85
Sign in to follow this  
nexsteppe

ANSWERED Automatically Restarting OpenVPN Connection after Disconnection (or Outage)?

Recommended Posts

My home Linux desktop connects to Air using a straight OpenVPN (2.4.8) config and openresolv.  Results are good: my ISP offers me a decent line so I can usually keep a VPN connection up for days.
But there are infrequent outages.  And, of course, sometimes the connection to the VPN server itself drops for reasons unrelated to my home connection (e.g., maintenance by data center).  When I'm home I can simply restart the connection as needed.
However as I spend more time away from home, manually restarting isn't an option.  If the VPN connection should fully drop for any reason and gets stuck in an infinite retry loop then public-facing services (e.g., ssh, ftp) become inaccessible.

Is there a way to have OpenVPN automatically reconnect following outages or disconnections?

Share this post


Link to post
@hawkflights

Hello!

OpenVPN tries to re-connect by default, as you have noticed. To make it rotate VPN servers when a connection fails, you can consider to add multiple remote lines in your profile. When a connection attempt fails, OpenVPN will pass to the next remote line, trying the next server in the "remote" list.

Should you wish to start with a random server, add also remote-random directive; OpenVPN will rotate servers in sequence as usual, but it will start from a random server at startup.

Kind regards
 

Share this post


Link to post

(Apologies for missing this reply!)  I had already setup my OpenVPN config to rotate servers as suggested.
The problem — I think — is that my desktop was being assigned a new address by my router after the outage, and so would get stuck in the endless connection retry loop until I manually stopped OpenVPN and started it again.
By configuring static DHCP address leases on my router, the problem seems to have gone away and now OpenVPN recovers from dropped connections without issue.

Share this post


Link to post
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...