Is it possible to automatically connect to a VPN when one is connected to a WIFI access point?

To manually connect to a VPN after connecting to a WIFI access point works, but it is so easy to forget.

I am using Mavericks on a Macbook Pro Retina.

  • This is how you can do it on iPhone/iOS. Commented Jan 17, 2022 at 7:22

1 Answer 1



You want to have an automated action after you connect to a certain WiFi point. An easy way to do this, is using ControlPlane (formally known as MarcoPolo). This software makes your computer context aware and can execute scripts and programs when your location changes. Some examples that ControlPlane is aware of:

  • Current Audio Output device (headphones/internal speakers)
  • Discoverable Bluetooth devices
  • Advertised Bonjour (Zeroconf) services
  • Attached FireWire devices
  • Assigned IP addresses
  • Ambient Light level
  • Attached Monitors
  • Active Network Links
  • Power source (power adapter/battery)
  • Running Applications
  • Current Time Of Day
  • Attached USB devices
  • Visible WiFi networks

edit (21 aug 2014, thanks to @Rainer): Marcopolo is now ControlPlane. ControlPlane was created using code from version 2.5.1 of the MarcoPolo project still available at http://www.symonds.id.au/marcopolo/. ControlPlane is a direct port of MarcoPolo and in fact, much of the configuration from MarcoPolo still works with ControlPlane, just better!

ControlPlane supports 32 and 64bit Intel based Macs running Snow Leopard through Lion.

  • That's an idea! But it seems that Marcopolo is it maintained anymore and the author suggests using controlplne instead controlplaneapp.com I will look at it again. Thanks.
    – Rainer
    Commented Aug 20, 2014 at 14:12
  • 1
    Ok - got it working with using ControlPlane, Tunnelblick for the VPN connection and AppleScript to connect and disconnect the VPN.
    – Rainer
    Commented Aug 20, 2014 at 20:30
  • @Rainer can you post that script?
    – henry
    Commented Dec 8, 2016 at 17:09
  • Sorry - Not usine it anymore and lost it.
    – Rainer
    Commented Dec 8, 2016 at 17:11
  • The applescript to connect to Tunnelblick tell application "Tunnelblick" connect ("pfwtracs01-udp-1194-config") end tell
    – Hvisage
    Commented Aug 19, 2017 at 20:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .