How do you restart OpenVPN service when internet connection drops?

I have an OpenSUSE server that I want to always be using a VPN. I have openvpn running as a service in /etc/init.d/openvpn. It is setup to run at boot and everything works properly. My issue arrises when I lose network connectivity for a bit or when a network cable is unplugged. After this the network is just down. If I restart OpenVPN everything works properly.

I’ve tried adding ‘/etc/init.d/openvpn restart’ to the end of ‘/etc/init.d/network’. However this doesn’t seem to work properly.

What is the best way to restart OpenVPN if the network connectivity drops and is regained? Or am I approaching this all wrong?

And the openSUSE version is … ?

Sorry that is essential 12.2.

Are you using network manager to control your network connectivity? If so, this how to may be useful:

It uses a little script to periodically check the network connection status and restart the VPN if necessary.
See the modified script at the by samson. It checks that the VPN is working with a ping test, and will restart it if necessary.