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
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
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?