What is the best way to automatically reconnect client if something worng with the network? Ubuntu 16 and 20

This forum is for admins who are looking to build or expand their OpenVPN setup.

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
glorsh66
OpenVpn Newbie
Posts: 18
Joined: Tue Mar 10, 2020 11:17 am

What is the best way to automatically reconnect client if something worng with the network? Ubuntu 16 and 20

Post by glorsh66 » Fri Mar 04, 2022 1:56 pm

I have two servers and two clients that are using OpenVPN.
What is the best option for the client to ensure that it will try to reconnect if something wrong with the network or server?


Right now I am using

sudo nano /etc/default/openvpn
AUTOSTART="all"

option to run the client at the startup. It seems to be working, but I don't know if a client will try to reconnect.
Because after I changed some settings on the server, and restarted the OpenVPN daemon the connection on the client stayed in the operational state.

Does OpenVPN check the connection status and try to reconnect if something wrong?
Does it ping the server? How is it implemented?
What configuration options are available?


What are the best options to ensure that the connection is up? (for ubuntu 16 and ubuntu 20, because I suppose there could be some differences in nmcli functionality)?

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: What is the best way to automatically reconnect client if something worng with the network? Ubuntu 16 and 20

Post by TinCanTech » Fri Mar 04, 2022 2:29 pm

Use systemd.

glorsh66
OpenVpn Newbie
Posts: 18
Joined: Tue Mar 10, 2020 11:17 am

Re: What is the best way to automatically reconnect client if something worng with the network? Ubuntu 16 and 20

Post by glorsh66 » Fri Mar 25, 2022 2:55 pm

TinCanTech wrote:
Fri Mar 04, 2022 2:29 pm
Use systemd.
I tried to make my own service, but how will it know if the connection has been lost?

TinCanTech
OpenVPN Protagonist
Posts: 11139
Joined: Fri Jun 03, 2016 1:17 pm

Re: What is the best way to automatically reconnect client if something worng with the network? Ubuntu 16 and 20

Post by TinCanTech » Fri Mar 25, 2022 3:02 pm

Openvpn provide systemd service files, use those.

Post Reply