Ubuntu server 20.04 - OpenVPN Client does not reconnect after internet connection goes down and up again. Help?

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
User avatar
Danran
OpenVPN User
Posts: 28
Joined: Tue Jun 29, 2021 9:21 am

Ubuntu server 20.04 - OpenVPN Client does not reconnect after internet connection goes down and up again. Help?

Post by Danran » Wed Aug 04, 2021 4:35 am

I'm running openvpnclient on Ubuntu Server 20.04.
I placed my openvpn.conf file in /etc/openvpn/client/myovpn.conf
I placed my auth file ine /etc/openvpn/client/auth.txt
On my server side of the VPN, is an openVPN-AS instance on Amazon.

On my openvpnas instance (the vpn server) my user inputed server directives are as follows:

Code: Select all

resolv-retry infinite
persist-key
persist-tun
keepalive 10 120
explicit-exit-notify 1
push "keepalive 10 120"
On my Ubuntu 20.04 client, my user inputed server directives are as follows:

Code: Select all

resolv-retry infinite
persist-key
persist-tun
keepalive 10 120
auth-user-pass /etc/openvpn/client/auth.txt
# OPENVPN UP/DOWN SCRIPT FOR PI SERVER
script-security 2
up /etc/openvpn/update-systemd-resolved
up-restart
down /etc/openvpn/update-systemd-resolved
down-pre
I cannot find any of the openvpn logs in /var/log/openvpn. It's just an empty folder so I don't know where to find the logs.

I have run the command

Code: Select all

sudo systemctl enable openvpn-client@myovpn
and

Code: Select all

sudo systemctl start openvpn-client@myovpn
to succesfully start the client connection on boot, and to immediately start the client connection. Both connections work just fine.

The PROBLEM is that if I unplug the internet from the client for 15 seconds (simulating an internet outage), the ubuntu client is unable to recover or reconnect after I plug the internet cable back in. It doesn't get any internet whatsoever after pluging it back in, and I wait for well over 10 minutes. What I need, is my client to automatically reconnect to the openvpn-as instance (the vpn server) automatically when the internet gets plugged back in.

How do I go about accomplishing this and what am I doing wrong?

kojo1984
OpenVpn Newbie
Posts: 3
Joined: Thu May 11, 2023 8:04 pm

Re: Ubuntu server 20.04 - OpenVPN Client does not reconnect after internet connection goes down and up again. Help?

Post by kojo1984 » Fri May 12, 2023 6:35 am

I know it is an old post, but I just found a solution and before I answer my own post, I'll drop the answer here.

What helped me is that I added this directive into OpenVPN config file:

Code: Select all

push "nobind"
Also, I've set

Code: Select all

keepalive 2 10
directive to lower values so client reconnect faster.

Now, after I restart OpenVPN service, client can reconnect again, without intervention from user.

Post Reply