1
18.7 Legacy Series / Reconnect OpenVPN client
« on: June 08, 2018, 02:11:04 am »
Hi All!
I was having a problem with my openvpn client not reconnecting after a dropped connection and searched around for a simple solution. Not much info (for V18.x) but was able to find all of the info in various places around the net.
Thanks to this site for the basic instructions.
I have a basic OpenVPN client setup that connects to a random server, so this snippet works well with my config.
It would be nice to see a simple feature to click a checkbox to do gateway monitoring in the client settings.
Hope this helps with auto-reconnecting an OpenVPN client or for restarting the OpenVPN service (both well hidden online and in the forums).
I was having a problem with my openvpn client not reconnecting after a dropped connection and searched around for a simple solution. Not much info (for V18.x) but was able to find all of the info in various places around the net.
Thanks to this site for the basic instructions.
Code: [Select]
#!/usr/bin/env sh
VPNSRCIP="$(/sbin/ifconfig ovpnc1 | grep 'inet ' | cut -f1 -d '-' | awk '{ print $2}')"
VPNGWIP="$(/sbin/ifconfig ovpnc1 | grep 'inet ' | cut -d ' ' -f 4)"
if /sbin/ping -S "${VPNSRCIP}" -c 3 "${VPNGWIP}"; then
# Success, Nothing to do
exit 0
else
# Fail, Reconnect VPN
configctl openvpn reload
fi
exit 1
I have a basic OpenVPN client setup that connects to a random server, so this snippet works well with my config.
It would be nice to see a simple feature to click a checkbox to do gateway monitoring in the client settings.
Hope this helps with auto-reconnecting an OpenVPN client or for restarting the OpenVPN service (both well hidden online and in the forums).