15

I'm using NetworkManager and OpenVPN on linux.

The problem is I get random disconnections, especially when idle.

So I was thinking maybe there was an option to keep it alive. I have seen examples for OpenVPN config files, but I don't think I'm using one. I have set up everything directly from the NetworkManager. I found the NetworkManger config file for my current connection, and it has these sections: [connection], [vpn], and [ipv4]. Does any of those have a keepalive option? What's the syntax, and how does it work?

2
  • You might want to show us the logs of your VPN connection, both server and client. OpenVPN indeed has a keepalive option, but NM GUI has no way to pass the parameters, so you might want to hack into the global OpenVPN configuration, but I didn't find one, so it may be hard coded into NM.
    – Braiam
    Commented Jul 30, 2013 at 3:35
  • If you're using a shell only, I'd suggest the use of screen or tmux so a disconnect doesn't hurt that much anymore.
    – ott--
    Commented Jun 9, 2015 at 16:27

3 Answers 3

21

According to the documentation here, the KeepAlive parameter is probably what you were looking for.

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

This should either be added to the OpenVPN connection profile as a new line, or to the Advanced Configuration on the server (likely /etc/openvpn/openvpn.conf).

-3

Insert on the client:

keepalive 10 60 

This will keep your connection up.

5
  • 6
    Please provide more details for your answer. Where does that get inserted? What does it do?
    – Taegost
    Commented Aug 14, 2013 at 15:11
  • 1
    I didn't downvote you, but seriously, where do I insert that line? Commented Aug 15, 2013 at 17:04
  • 1
    insert into the config file on client side. On linux, located /etc/openvpn/client.conf
    – user476624
    Commented Aug 1, 2015 at 17:31
  • 1
    keepalive is a server side directive, not a client one. Commented Apr 27, 2020 at 21:56
  • 1
    @JamesWhite That is not exactly true. This option can be used on both client and server side, but it is enough to add this on the server side as it will push appropriate --ping and --ping-restart options to the client I pasted this info from here Commented Dec 13, 2021 at 12:03
-3

You have to do it each time you start up but what is wrong with just setting up ping xx - t in a terminal window. Its low overhead and certainly fixes my problems in Windows 10 VPN which is locked down to a 30 minute idle timeout.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .