Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

So far, I've been using the build-in VPN tool of Lion.

I would like to auto connect my VPN whenever I'm connected to the internet.

Is it possible to auto connect my VPN whenever I'm connected to the internet with the build in tool?

If auto connect is not possible with the build in tool, can you provide me with an alternative that is free?

share|improve this question
    
Isn't there an option for this under "Advanced" in Network Settings? I don't have my Mac with me. –  Matt Aug 8 '12 at 15:25
    
Is there a way to do this with Viscocity, the Open VPN client? –  user27065 Aug 8 '12 at 22:09
    
@christian Good question! I don't know. I've asked their support via Twitter and have not yet received an answer. But you can try to get a solution in their forum. So far, I've been using the amazing Shimo VPN client which supports OpenVPN and has this feature build in. However, this does not answer your question :). –  gentmatt Sep 20 '12 at 10:49
    
@christian The latest version of Viscosity has a setting for this. When you select a VPN profile and edit it, there is an option at the bottom to start this VPN service when Viscosity starts. –  gentmatt Sep 20 '12 at 12:55

1 Answer 1

up vote 20 down vote accepted

Apple Script provides a good solution:

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

enter image description here enter image description here enter image description here enter image description here enter image description here

share|improve this answer
1  
Great! Worked like a charm. I'm using Lion 10.7.2. –  gentmatt Nov 28 '11 at 14:26

protected by bmike Aug 9 '12 at 19:18

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.