I recently found myself regularly traveling, and I wanted to ensure that no matter when I opened my laptop, that my wifi connection would be secure. However, there’s no way using built-in OSX VPN client to connect on boot or wake-from-sleep, nor is there any way retry after the failure of your VPN connection. Good thing that Apple made AppleScript!
I have a personal VPN server running on a 5$/mo Digital Ocean server which is configured with this amazing script: https://github.com/hwdsl2/setup-ipsec-vpn. I’ve got my VPN configured in the MacOS Network settings as
vpn-evan and I’ve got "all network traffic" going though it. That should keep me safe…
Script Editor and paste in the following:
Let’s break dow this script:
Be sure to replace "vpn-evan" above with the name of your VPN connection
So if this program is always running in the background, every minute, you will try to connect to your VPN!
Now, we want to turn this little script into a program.
1. In `Script Editor`, go to "export" and save your script as an "application". Click "Stay open after Run Handler"
2. Open up `System Preferences` and then navigate to "Users" and "Startup Items". Drag and Drop your new application there!