VPN status check trigger

I want to launch an application (actually a website) when my VPN is connected. How can I monitor that with Keyboard Maestro? Any suggestions? Any script to check for example the IP address?
I am using Cisco AnyConnect.

Some thoughts:

The preferable and cleanest way would be to have the Cisco client run a script when the connection is established. The results of a web search suggest that this is possible.

If this doesn’t work, then you could set up a KM macro that runs periodically (e.g. every 5 minutes):

  • The macro then could query the AnyConnect app via AppleScript.
  • If the app is not scriptable, perhaps you can query the system’s Network Preferences (see an example script here).
  • Another idea would be to ping a server, and assume that when the ping takes longer than usual you are connected to the VPN.

Hi Fabio,

thanks for ticking the “Solution” checkbox.

I’m curious: Which one of my proposals has lead to the solution?

Especially if the solution involves KM you might consider posting it here (if you have the time). This way other users of AnyConnect could benefit from your effort.

Tom
I have actually used another approach. I considered the “perfect path” - I
mean always connected. My knowledge did not allow me to go further.