Community discussions

MikroTik App
 
User avatar
inteq
Member
Member
Topic Author
Posts: 416
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Using Automate on Android for Wireguard on dynamic IP

Wed Feb 14, 2024 3:38 pm

Valid for people connecting to a Wireguard server that is hosted on a dynamic IP/DNS connection.

When using Wireguard client on Android and the IP of the Wireguard server changes, the tunnel will be stuck active but no traffic will pass.
The user needs to deactivate and activate the tunnel to fix it.

To automate this, I am using Automate for Android: https://play.google.com/store/apps/deta ... e&hl=en_US
As I could not find a flow to fix my specific issue, I have wrote a small one that does.

How to get it.
Install Automate, go to Community and search for "Wireguard check. DynDNS & SSID"
Direct link to file: https://llamalab.com/automate/community ... 6+SSID.flo

Features
1. Checks if wireguard tunnel is actually working and retries if not. Useful with wireguard servers behind dynamic IP using dynamic DNS. If the IP changes, the tunnel will get stuck, requiring manual deactivate/activate.
2. Disables the tunnel if on specific SSID.
3. Enables the tunnel if not on specific SSID.

Setup
1. Edit block 1 and set your SSID. Leave empty if you don't need feature 2.
2. Edit blocks 2 and 3 and set your tunnel name.
3. Edit block 5 and input an IP that is only reachable through the tunnel, like the router's private IP. Wireguard must be able to get an icmp reply from the IP.
4. Edit delays in blocks 9, 10 and 13 to suit your needs. In my testing, 60 seconds is fine. Lower it for faster reaction time, but higher battery usage.
5. Disable logging when done testing.
6. In Wireguard client settings, check "Allow remote control apps".
7. Disable app battery usage for Wireguard as well as for Automate.
8. Disable "Pause app activity if unused" for Wireguard and Automate.
9. Make sure to set the permission for Automate app "control WireGuard tunnels" to on, or else it won't be able to activate/deactivate the tunnel.
perm.png


How the flow looks
flow.jpg
As this is my first ever flow in Automate, I am sure there is room for improvement.
Please share your ideas if you have some.
You do not have the required permissions to view the files attached to this post.
 
Mesquite
Member
Member
Posts: 420
Joined: Tue Jan 23, 2024 9:16 pm

Re: Using Automate on Android for Wireguard on dynamic IP

Thu Feb 22, 2024 1:30 pm

What does this have to do with Mikrotik?

Who is online

Users browsing this forum: No registered users and 2 guests