Keeping OpenVPN Tunnel Alive
Hi - I'm trying to get a persistent connection to PIA set up on a headless Ubuntu 14.04 server with OpenVPN. It works OK so far, but if the connection is idle for a couple of days, it stops working - tun0 still exists and it has an IP address, but I can't ping anything.
My current config is below. I thought adding the keepalive line would fix it, but it apparently did not.
Any thoughts?
clientdev tunproto udpremote nl.privateinternetaccess.com 1194resolv-retry infinitenobindpersist-keypersist-tunca /etc/openvpn/ca.crttls-clientremote-cert-tls serverauth-user-pass /etc/openvpn/login.confcomp-lzoverb 1reneg-sec 0crl-verify /etc/openvpn/crl.pemscript-security 2up /etc/openvpn/update-resolv-confdown /etc/openvpn/update-resolv-confkeepalive 10 60
Comments
I am thinking of something like this:
"keepalive 3600 65535"
(These numbers are just randomly chosen by me, use whatever you think should work and see if it helps.)
Nonetheless it is your config to play with as you want. If it works for you as you configure it, I am certainly not thinking it should be changed.
3600 would in this case mean that it only bothers to ping the server every hour. So that may be a bad idea upon thinking some more. But every ten seconds is likely to be too often to maintain a connection. (Meaning lots of wasted data.)
Perhaps 60 3600 would be a better ratio?
Before I did that, once or twice a day there was reconnect - even when I used a static IP address in the config (downloaded from here https://www.privateinternetaccess.com/openvpn/openvpn-ip.zip). But after deleting "persist-tun", the connection stays online for several days! And I didn't add the "keepalive" command to the config, I just deleted "persist-tun".
Ses also this page regarding persist-key/persist-tun: https://openvpn.net/index.php/open-source/documentation/howto.html:
Interestingly, there aren't restarts when NOT having "persist-tun" in the config, whereas the description says that restarts are tried to be avoided when there are the persist-commands in the config.
I am experiencing the same issue. I would like to try your solution. However, I am experiencing troubles creating a new VPN connection. Is there a way to modify an existing, working VPN connection to turn off persist-tun via the network-manager-gnome interface?
I don't think this is correct, as the server should continue to "keep-alive" the connection indefinitely.