On Android finally you can automatically turn Wireguard tunnel on/off without paid Tasker app

EDIT: this solution has been become obsolete a while ago with the introduction of WG-TUNNEL, it’s the wireguard app for Android with auto-tunneling capabilities based on network connection and trusted Wifi. Exactly the purpose of the old workaround:

https://play.google.com/store/apps/details?id=com.zaneschepke.wireguardautotunnel

OLD, OBSOLETE WORKAROUND:

When I leave the house, I want my phone to automatically connect to VPN via Wireguard, to ensure ads are blocked via my AdGuardHome+Unbound setup running on my server.

Unfortunately, the Android app is extremely limited and there is no intent to add basic options that other (Open)VPN apps and even the Wireguard iOS apps have.

Devs forward you to Tasker, which is a respectable app. But if you have no use for Tasker, it doesn’t make sense paying for it, for a basic feature that is present in other VPN apps, Wireguard for iOS but not in Wireguard for Android.

Now there is an alternative!

https://play.google.com/store/apps/details?id=com.llamalab.automate

And the magically working flow. I tested all others I could find via the Automate Community, even discussed a few here on Reddit, then decided to create my own with proper description how to get it working:

https://llamalab.com/automate/community/flows/39377

Just open the app, go to “Community” via the menu and search for “Toggle Wireguard WiFi”. Add the flow and follow the 4 instructions.

Enjoy!

I had Tasker before Wireguard blew up. But it’s not the most friendly-UI out there, so I got another automation app.

Coming back to this point, I don’t even disable WG on Android. Neither at home, nor outside. Ever. At first I thought that it having a kind of nested VPN would bring issues, but it’s smooth as butter.

Anyway, nice suggestion! :wink:

Does this still work? I have enabled the wireguard perm in automate and renamed the networks in both spots, but it never seems to notice the network has connected. The log just hangs at “network connected”. I also enabled external apps permission in the wireguard app

Hi. It’s now working for me.

I did an extra steps that’s is not in your instructions which is allowing remote control apps in wireguard settings.

For the rest, I followed everything and it doesn’t work.

Samsung s21 December 22 update
Wireguard v1.0.20220516

01-31 15:42:12. 740 I 5@22: Network connected?
01-31 15:42:30.074 I 5@22: Stopped by user
01-31 15:42:31.935 I 6@1: Flow beginning
01-31 15:42:31. 937 I 6@22: Network connected?
01-31 15:42:47.107 I 6@22: Network connected?
01-31 15:42:54.824 I 6@21: Ping
01-31 15:42:54.948 I 6@8: Broadcast send
01-31 15:42:54.949 I 6@15: Toast show
01-31 15:42:54.951 I 6@12: Wi-Fi network connected?
01-31 15:43:20.411 I 6@12: Stopped by user

Any ideas? Thanks.

EDIT: this solution has been become obsolete a while ago with the introduction of WG-TUNNEL, it’s the wireguard app for Android with auto-tunneling capabilities based on network connection and trusted Wifi. Exactly the purpose of the old workaround:

You do realize that makes no sense at all? The dev has different mantras per mobile platform?

You call me out for being annoying, calling out a straight fact: a feature that does exists on one platform (iOS) but not on the other (Android)?

Meanwhile you defend it as being by design, while the old Wireguard for Android app (can’t remember the name) did have comparable features?

Going for the by design route and using terms like mantra simply do not correspond with the facts and the history of Android on Wireguard.

You find that annoying and now even threaten with censorship, because history of Wg on Android is not on your side and don’t want to be confronted with it? Where are the rules that day we cannot talk about that?

Go ahead, remove everything. Do know that you can basically delete this whole topic since it was created to provide a workaround after the old app was withdrawn and replaced with an app lacking similar features.

If something is free you are the product. I’d rather pay the $5 for a life time license.

I used Tasker on my old Android phone for wireguard Auto on when not on Wi-Fi, but it was not consistent . Moreover it no longer works and is not stable on the pixel 9 Pro XL. Tasker repeatedly force closes and the profiles don’t work consistently. Why can’t the Android OS have options like the IOS, where you can natively specify the wireguard VPN to Auto enable when not on specific Wi-Fi?

You never needed Taskar to turn this on or off, not on any android test systems I’ve used. Not for ages.

Thanks! I will give it a try. I have already paid for tasker a long time ago, but I am curious on how well Automate works. Tasker is rock solid turning VPN off and on for me though. I don’t have to even think about it. If I leave my house WiFi, VPN is automatically turned on.

Why disable wiregaurd when you at home? Do you trust your WiFi ? My biggest problem with wiregurd app that tunnel need to be turned on manually after each reboot.

And thanks for App you linked. It is very useful outside of WireGuard.

Thank you for this it’s a tool I wasn’t aware of and Tasker was opening the Tunnel successfully but not allowing data transfer. Annoying.

Took me a while to understand the instructions to set this up but got there in the end. Early days but seems to work perfectly. :+1:

Does this still work?

I tried three separate flows, I understand the theory behind how it’s supposed to work.

I set the “tunnel” = “name” even trying to lowercase the name, checked and unchecked the button in wireguard app, but nothing seems to work.
The flows are working fine looking at the log, the problem is somewhere in the broadcast and I have no idea where.

And I am not paying for Tasker just to find out it doesn’t work there either.

If Wireguard is not active, I’ll get an error:

“Not allowed to start service Intent {cmp=com.wireguard.android/.backend.GoBackend$VpnService }: app is in background”

Is there a way to fix this?

What kind of battery usage would running this in the background cause? Is that comparable to just leaving the tunnel active 24/7?

Great idea, though it doesn’t work on my device a Samsung galaxy S9 with Android 12 with a fork from Nexus I believe?
URL here though https://evolution-x.org/

It cannot find the WiFi.

What kind of power consumption do you see over night?

How do you do that? My phone has no internet access when I’m connected to home wifi and have Wireguard enabled.

Unfortunately, with every update of the Automate app it stopped working. Now I am clueless how to make it work again.

I am really annoyed the Wireguard developers don’t build this functionality in the Android app while it does exist in the iOS app AND the developer of a unofficial Wireguard app withdrew his app to join the official team years ago. But his app did support conditions to start the tunnel!
Really bad devteam that doesn’t even commmunicate about these facts.

Sorry can’t help, I actually tried it on a S22 and it worked, this was June last year. Different version of the flow. But it should work. You might need to figure out why Automate works differently with latest Samsung devices.

Also, you do not write what doesn;t work exactly… No way I can help.