auto restart openvpn client after network disconnect

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
User avatar
Danran
OpenVPN User
Posts: 28
Joined: Tue Jun 29, 2021 9:21 am

auto restart openvpn client after network disconnect

Post by Danran » Thu Jul 22, 2021 8:49 pm

I am running openvpn client sucessfully on ubuntu server 20.04 on a raspberry pi. However, when I unplug my raspberry pi's ethernet connection, and then replug it in, it DOES NOT Automatically reconnect to openvpn. Infact, in order to get openvpn to reconnect after plugging in my ethernet cable, I must run the command

Code: Select all

sudo service openvpn restart
.

After I run this command, Openvpn client connects and works properly, again.

My question is, How can I automatically reconnect to openvpn as a client on ubuntu server 20.04, after the network cable gets disconnected and reconnected, without having to manually run the command

Code: Select all

sudo service opepnvn restart
?

Is there some sort of script I can use or some way to instruct ubuntu to run the above command as soon as the network finds a connection again, after being disconnected?

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

Re: auto restart openvpn client after network disconnect

Post by TinCanTech » Thu Jul 22, 2021 8:58 pm

Openvpn does not know you pulled out the plug until it times out, probably 60~120 seconds ..

User avatar
Danran
OpenVPN User
Posts: 28
Joined: Tue Jun 29, 2021 9:21 am

Re: auto restart openvpn client after network disconnect

Post by Danran » Fri Jul 23, 2021 6:36 am

even after 120 seconds, the vpn client does not restart.

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

Re: auto restart openvpn client after network disconnect

Post by TinCanTech » Fri Jul 23, 2021 11:49 am


Post Reply