Automatically Reconnect Your Mac To VPN

Mac: A Virtual Private Network (VPN) is a great way to browse the web securely, and Mac OS X has a VPN option built in. The problem is that it doesn't always automatically connect when you boot up your computer or after it disconnects. A simple Applescript over on Stack Exchange solves this problem.

To enable this function, open up Applescript (Applications > Utilities) and paste in this code (replace "VPN University" with the service name you use):

on idle
    tell application "System Events"
        tell current location of network preferences
            set myConnection to the service "VPN University"
            if myConnection is not null then
                if current configuration of myConnection is not connected then
                    connect myConnection
                end if
            end if
        end tell
        return 120
    end tell
end idle

Then save the script as an application with the "Stay Open" box checked. Now, when you're browsing with a VPN, say, at a cafe or just at your own house, OS X will automatically reconnect if the connection drops. The Applescript should work in both Mountain Lion and Lion. Head over to StackExchange for the full step-by-step instructions.

Auto connect VPN upon login/boot [StackExchange via One Thing Well]


Be the first to comment on this story!

Trending Stories Right Now