The use case is that I need a particular VPN connected at all times on one of my servers which runs macOS. It's set up with Tunnelblick. And I know how to re-connect to it manually using Tunnelblick GUI. But I noticed that sometimes due to network sometimes disconnecting due to instability or some such, Tunnelblick could get into a state of repeatedly trying to reconnect to the previously connected VPN but would never succeed. Therefore, I'm hoping I can create a cron job to periodically check if the VPN is connected (probably by pinging an URL only accessible via the said VPN), and if not, reconnect to it by restarting Tunnelblick and reconnect to the VPN. What should the command line be? I intend to add the command line into my crontab.
1 Answer
You should have a look at this Answer (comments are interesting too): How to start Tunnelblick VPN connection via Terminal
This will guide you to create an AppleScript and then you may launch it by command line or crontab.
-
How to add a check to verify that the Internet is accessible to the computer before letting Tunnelblick blindly attempting to connect?– qazwsxCommented Jan 21, 2017 at 20:42
-
You can just analyse the return of one ping command on external address for example. Commented Feb 14, 2017 at 15:29