0

I need to bring up an OpenVPN connection on the condition that a site is not reachable (on numerous devices spread over several heterogeneous networks). I did not find any such feature in OpenVPN directly so I ended up with a few possibilities:

  • within /etc/rc.local: make a connectivity check and systemctl start openvpn

    • problem: /etc/rc.local is a systemv feature, not systemd (where it is optional and therefore there are probably better ways)
  • create a /etc/systemd/system/checkconnect.service which would Exec a script with the same actions as above

    • systemd provides a set of conditions on the start of a service but there is nothing related to networking.

Is there a standard way to conditionally start OpenVPN?

WoJ
  • 3,365
  • 8
  • 46
  • 75
  • Maybe your monitoring software should fire such an action? – neutrinus Sep 21 '16 at 07:53
  • You could use a shell script that pings the host and if it's down, start the service, and vice versa. Then cron it to run every minute. – mzhaase Sep 21 '16 at 07:58
  • @neutrinus: the machines are not reachable until they bring up the VPN (except if they do not need to, of course). – WoJ Sep 21 '16 at 08:41

0 Answers0