Skip to content

Instantly share code, notes, and snippets.

@thanhtunguet
Last active October 17, 2022 21:13
Show Gist options
  • Save thanhtunguet/095a9a44be447df54ddbee603aeb8e0c to your computer and use it in GitHub Desktop.
Save thanhtunguet/095a9a44be447df54ddbee603aeb8e0c to your computer and use it in GitHub Desktop.
Auto reconnect OpenVPN
#!/bin/bash
function getStatus () {
ifconfig | grep $1 && return 1
return 0
}
getStatus tun0
if [[ $? == 0 ]];
then
nmcli con up id vpn-connection-name
fi
@thanhtunguet
Copy link
Author

thanhtunguet commented Sep 20, 2022

sudo nano /usr/local/bin/autovpn

sudo chmod a+x /usr/local/bin/autovpn

Add this line to crontab:

* * * * * /usr/local/bin/autovpn >/dev/null 2>&1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment