[Ubuntu] Keeping a OpenVPN Connection Alive


On some occassions, you may be using , OpenVPN to VPN to a server to perform some maintenance work. In some cases (such as the nature of my job), we have to connect to an acknowledged server via VPN to connect to a server if there are IP restrictions.

By doing so, you may experience timeout errors upon connecting to a server. This may occur if you left the connection idle for some time (typically, 10 minutes), and you would have to wait for some time for the VPN connection to be re-establish.

There’s a configuration fix that you can perform to avoid such timeouts from occuring, in which a simple line can prevent frustrations.

Open up your .ovpn file via terminal:

vi test.ovpn

Input this line between comp-lzo and # Set log file verbosity.:

keepalive 10 600

This would ping the instance every 10 seconds if there was a timeout period within 600 seconds.

Save the file, and test your OpenVPN connection again. Go make your coffee to simulate the timeout process, and notice that your connection will not be dropped.

Final Words

Alternatively, if you are performing server maintenance, you can always use screen to perform long running tasks in case your connection becomes unstable.

You can read more of OpenVPN configurations from the OpenVPN Documentation.

Have fun!

Was That a Good Read? Rate It!

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *

Current day month ye@r *

CommentLuv badge