It works great.
However, if I put my laptop into airplane mode by hitting the airplane mode button (which I presume turns off all radios), when I hit the airplane mode button again to turn the radios back on, I need to manually restart openvpn using the above command.
Is there a way to have the above systemd service run after re-enabling the radios? Is this the correct approach?
I think that what you really want is for the vpn to reconnect when access to its endpoint becomes available. Why endpoint access went away should be irrelevant. But I do not know systemd well enough to find a suitable target.
Does systemd send a notification when a network link goes up or down? How about when an interface gets an IP address? These would be useful triggers.
networking.networkmanager.dispatcherScripts runs a script when link status changes. If you use NetworkManager, maybe you can use such a script to signal openvpn-reconnect.
Hopefully someone else has a better solution. I’ve wanted to solve a similar problem with Nebula VPN but I’ve never taking the time to really dig into it.