How to make sure OpenVPN is connected?

You can use the down directive in your client configuration to fire off a custom script when the connection drops. In the script, you could do several things for limiting public network connections. Here's my ideas:

  • Setup some iptables that only allow connections to the VPN server, all other connections dropped. Of course, do not forget to remove this restriction when the client comes back up
  • Modify the resolv.conf file to limit or turn off name resolution
  • Incorporate custom routing tables