Detect VPN connection

677 views
Skip to first unread message

Eric Kruis

unread,
May 11, 2016, 5:31:25 AM5/11/16
to Tasker
Is it possible to detect an active VPN connection with Tasker?

CoolRaoul

unread,
May 13, 2016, 10:33:52 AM5/13/16
to Tasker


Is it possible to detect an active VPN connection with Tasker?

It depends.
If you just want *inside a task* to check if VPN is on or not you may use the following method (replace "flash" commands by you own code)
Vpn
 A1
: Run Shell [ Command:ifconfig Timeout (Seconds):0 Use Root:Off Store Output In:%out Store Errors In: Store Result In: Continue Task After Error:On ]
 A2
: If [ %out ~R (?m)^(ppp|tun) ]
 A3
: Flash [ Text:VPN is on Long:On ]
 A4
: Else
 A5
: Flash [ Text:VPN is off Long:On ]
 A6
: End If
 
But if you want to trigger a profile as soon as VPN is on, I don't have an working solution (unless using a polling approach which would be a very bad thing in term of performance and ressource usage)

Eric Kruis

unread,
May 14, 2016, 5:24:15 AM5/14/16
to Tasker
I wanted to check inside a task. Your solution works. Thanks a lot!
Message has been deleted

G M

unread,
Sep 25, 2016, 2:12:54 PM9/25/16
to Tasker
I was NOT able to make a proper query with this verification however since on VPN at appears "ppp0" I simple checked a match for this when VPN is on foreither wifi and gsm. Hope it helps.. or that I0m not incorrect.

Vpn
 A1
: Run Shell [ Command:ifconfig Timeout (Seconds):0 Use Root:Off Store Output In:%out Store Errors In: Store Result In: Continue Task After Error:On ]
 
 A2
: If [ %out ~ *,P-t-P,* ]

 A3
: Flash [ Text:VPN is on Long:On ] 
 A4
: Else 
 A5
: Flash [ Text:VPN is off Long:On ] 
 A6
: End If 


On Saturday, May 14, 2016 at 1:24:15 PM UTC+4, Eric Kruis wrote:
I wanted to check inside a task. Your solution works. Thanks a lot!

SimonBG

unread,
Mar 30, 2017, 1:11:29 PM3/30/17
to Tasker
And that didn't work for me either (I am not a regex master so I don't quite understand it). For me, just *If [ %out ~ *ppp0* ]* is what worked. Just adding as info for future newbies.

Pent

unread,
Mar 30, 2017, 2:32:23 PM3/30/17
to Tasker
Just FYI, next version of Tasker has a state for this.

Pent
Reply all
Reply to author
Forward
0 new messages