A simple bash script for autoreconnect to OpenVPN via NetworkManager command-line (nmcli).
-
Make the script executable "chmod +x /path/to/the/vpn-auto-reconnect.sh"
-
Copy "vpn-config-sample.sh" to "vpn-config.sh". Simply run "cp vpn-config-sample.sh vpn-config.sh".
-
Configure "vpn-config.sh". All the needed info on how to do that, is shown in the config comments.
-
vpn-auto-reconnect.sh start -- starts and monitors VPN connection
-
vpn-auto-reconnect.sh stop -- stops the monitor and also the VPN connection
nmcli: https://wiki.gnome.org/Projects/NetworkManager/nmcli
Source: http://www.gabsoftware.com/tips/automatically-reconnect-to-your-vpn-on-linux/
Fork from: https://gist.github.com/antoniy/f925ae55410a092c9e75/ with changes for nmcli v0.9.10.
Script tested on fedora 21 with airvpn (OpenVPN).
A simple bash script to toggle an OpenVPN connection on and off via NetworkManager command-line (mncli).
-
Make the script executable "chmod +x /path/to/the/vpn-toggle.sh"
-
Copy "vpn-config-sample.sh" to "vpn-config.sh". Simply run "cp vpn-config-sample.sh vpn-config.sh".
-
Configure "vpn-config.sh". All the needed info on how to do that, is shown in the config comments.
-
vpn-toggle.sh -- starts or stops your first set VPN connection