You are not logged in.

#1 2018-02-16 06:39:54

ava1ar
Member
From: NYC
Registered: 2009-10-20
Posts: 24

Watchdog for OpenVPN using systemd

Hi!

I am trying to create a watchdog to restart the OpenVPN connection if it get dropped. Desided to user systemd timers for this and here what I got so far:

openvpn-watchdog.timer

[Unit]
Description=OpenVPN Watchdog timer

[Timer]
OnCalendar=*-*-* *:*:00

[Install]
WantedBy=timers.target

openvpn-watchdog.service

[Unit]
Description=OpenVPN Watchdog service
ConditionPathExists=!/proc/sys/net/ipv4/conf/tun0

[Service]
ExecStart=/bin/systemctl restart openvpn@VPN.service

[Install]
WantedBy=multi-user.target

Timer triggers the service every minute. Service checks for /proc/sys/net/ipv4/conf/tun0 directory existence (and this directory only exists when tun0 network interface is up) and restart the VPN connection service if directory doesn't exists (I don't have ipv6 enabled, so the path is valid for me).

Wanted to share my approach - may be somebody will find it useful. Any suggestions / ideas are welcome as well.

Offline

Board footer

Powered by FluxBB