Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently asked a question Auto connect vpn upon login/boot which got answered well using apple script .

I want to extend this question to the following problem:

The vpn connection should be activated automatically when not connected to my home wifi. (e.g. i'm surfing in Starbucks) The default state would be vpn activated but it includes an "opt-out" for my home wifi.

share|improve this question
up vote 2 down vote accepted

Perhaps something like ControlPlane would do the job for you?

share|improve this answer

Here is another option:

I created a script and launch agent to accomplish this. The agent calls a shell script every 30 seconds and tries to ping an IP address that is static on the vpn network. If it cannot ping that IP it enables your vpn connection. If you are home, the script will be able to ping that address and will not connect to the vpn.

Clone the project below and follow the directions in the readme. The end result is an installer package that will place a launch agent plist file in /Library/LaunchAgents/ and a shell script in /Library/Application Support/melonsmasher/.

Be sure to edit the shell script(auto-vpn) with your VPN connection name and an IP address that is on the VPN network. You can change the run interval in the plist file(com.melonsmasher.autovpn.plist).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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