unbraid

Guides · Published

Multiple WireGuard tunnels at the same time on Android

By default, turning on a second tunnel in the official WireGuard app for Android switches off the first. To keep several tunnels up in that app you need root, a kernel with WireGuard in it, and two settings turned on. A second WireGuard app doesn’t get around it either, because Android allows one VPN service per profile.

If you need your home network and one internet exit, two peers in a single tunnel can do it without root. If you want different apps to use different servers, look at the kernel backend, a work profile, or a VPN app that runs several tunnels itself.

Why the WireGuard app runs one tunnel

On a phone without root, the app builds its tunnel on Android’s VPN service, and its default backend keeps one tunnel open. When you switch another one on, it takes the current one down first. If the new tunnel can’t start, it tries to restart the old one (GoBackend.java). A tunnel that starts but whose server never answers doesn’t make the app switch back.

Android has a limit of its own. Its VPN documentation says there is one active VPN service per user or profile, and that starting a new one stops the one that was running. The WireGuard app and a provider’s app both use that service, so connecting the second normally disconnects the first. If one of them is set as Always-on VPN, Android can refuse the switch. Why Android runs only one VPN at a time goes through the rule.

The rule counts VPN services. One service can still manage several WireGuard tunnels behind its single interface, and some apps do.

Several peers in one config

A tunnel can have more than one [Peer]. This example sends your home network to a router and other IPv4 traffic to a VPS:

[Interface]
PrivateKey = (your key)
Address = 10.8.0.2/32

[Peer]
# home router
PublicKey = (router's key)
Endpoint = home.example.net:51820
AllowedIPs = 192.168.1.0/24

[Peer]
# VPS
PublicKey = (server's key)
Endpoint = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0

The app adds a route for every range, and WireGuard sends each packet to the peer whose AllowedIPs matches the destination most closely. Addresses in 192.168.1.0/24 go to the router, and every other IPv4 address goes to the VPS.

Both servers need the phone’s public key as a peer, with 10.8.0.2/32 allowed for it. The router has to forward traffic to the LAN, and the VPS has to be set up as an internet exit. AllowedIPs on the phone can’t make a server forward anything.

  • App lists. The list in the tunnel’s settings (apps to exclude, or the only apps to include) applies to the whole tunnel. You can’t give each peer its own apps, so this splits by destination address only.
  • Overlapping ranges. Ranges of different sizes can overlap, and the closest match wins. An identical range can belong to one peer only: write 0.0.0.0/0 under two peers and the second takes it from the first. WireGuard AllowedIPs explained covers the matching.
  • Client key. The interface has one private key, so both servers see the same public key of yours. If your two servers need different client keys, the configs have to stay separate tunnels.

With more than one peer, the app stops blocking the traffic the config leaves out. IPv6 goes through the tunnel where a peer’s range covers it. The rest of it can use your normal network, unless Android’s Block connections without VPN is on.

Root and the kernel backend

The app can also run tunnels as ordinary kernel interfaces. It offers this when it finds WireGuard in the phone’s kernel and gets root access. In the app’s settings, tap Enable kernel module backend. The app disconnects its tunnels and restarts. Then turn on Allow multiple simultaneous tunnels, which is off by default and reads “Turning on one tunnel will turn off others” until you do. Without root you see neither setting.

In this mode the Android version of wg-quick sets the tunnels up with root. Android’s VPN service isn’t involved, so the one-service rule doesn’t apply (WgQuickBackend.java). Each tunnel keeps its own app list. For a list of included apps, wg-quick adds those apps to the tunnel’s network, and for a list of excluded apps it adds every app except those (android.c).

Give each tunnel its own list of included apps. We haven’t tested this setup, and we don’t know which tunnel carries an app that two of them list. The app’s own text calls the kernel module experimental.

A work profile

Each user or work profile can run a different VPN app. Install the WireGuard app a second time inside a work profile, along with the apps that need the second tunnel, and that copy keeps its own tunnel up while the first one runs in your personal profile.

The profile an app is installed in decides which of the two tunnels it can use, and each tunnel’s app list and AllowedIPs still apply. The copies in the work profile have their own data and sign-in. With the default backend that makes two tunnels, one per profile. Pausing the work profile stops its apps and its VPN. On a phone managed by an employer, the work profile is the admin’s to configure.

One VPN app with several tunnels inside

A VPN app can run several tunnels in one profile and choose one for each connection it handles. Since Android 10, a VPN app can ask the system which app owns a TCP or UDP connection (getConnectionOwnerUid), so the choice can follow the app. It needs no root, because Android still sees a single VPN service.

Open source tools that work this way, in alphabetical order:

  • Rethink DNS + Firewall. In its Advanced WireGuard mode, several configs run at once and you choose the apps for each (Rethink’s docs). Rethink DNS vs unbraid compares the two.
  • sing-box. A JSON profile can define several WireGuard endpoints and rules that send an Android package to one of them.
  • unbraid. Built on sing-box. You import each config as a server and assign apps on a screen. The next section has the steps.
Way Root Running at once What picks the server
Several peers in one config No One tunnel, several servers Destination address
Kernel backend in the WireGuard app Yes Several, with Allow multiple simultaneous tunnels on Each tunnel’s app list and ranges
Work profile No One tunnel per profile with the default backend The app’s profile, then that tunnel’s rules
One VPN app with several tunnels inside No Several tunnels Rules in the VPN app, such as the app’s package name

Several WireGuard tunnels in unbraid

In unbraid, each WireGuard file becomes a server, a route uses one server, and you choose which apps go on each route.

  1. Import the first config. On a new installation, tap Import a config file under Choose your VPN and pick the .conf file. Keep or change the name under Name this server and tap Import. This creates your default route.
  2. Import the others. Go to Settings, Providers & servers, Add connection, WireGuard or OpenVPN file. If unbraid is already set up, the first config goes in this way too.
  3. Make a route for each. In Routes, tap +, then Route. Under Own servers, tap the server’s name. To change which route is the default, tap a route and choose Make default.
  4. Assign apps. In Apps, tap an app and choose its route. Direct leaves it on your normal connection. unbraid doesn’t read the app lists from your old tunnels, so set these again.
  5. Connect with the power button on Routes, and approve Android’s VPN request if it appears. Each active route then shows the public address of its exit.

While unbraid is connected, the default route stays active. Another route is active when an app or a website is assigned to it, even while that app is idle. Two routes that use the same config share one tunnel.

For an internet exit, the file has to meet these requirements:

  • One peer. A config must have exactly one [Peer].
  • An IPv4 address under [Interface]. A file with IPv4 and IPv6 works, but unbraid uses only its IPv4 addresses and ranges.
  • All of IPv4 in AllowedIPs: 0.0.0.0/0, or ranges that add up to it. A config that only reaches your home network goes under Settings, Local & home access, Home WireGuard tunnel. Apps routed through unbraid then reach the private home networks in that config and keep their own exit for the internet.
  • No AmneziaWG settings, a file of at most 64 KB, and at most 16,384 characters of config.

You can import two files that share a client key, server key and endpoint. If two active routes use them, their addresses, preshared key and keepalive must match as well. Otherwise unbraid blocks the conflicting route and asks you to use one config for both. A route also can’t reuse the keys and endpoint of the home tunnel.

WireGuard import needs the .conf file. There is no QR import for it. unbraid tunnels IPv4 and blocks IPv6 for apps that go through it. It doesn’t move an imported config to another server. If the server stops answering, traffic on that route stops until it answers again, and unbraid doesn’t send it over your normal connection while it’s connected.

unbraid uses Android’s VPN service, so the WireGuard app’s default backend can’t be connected in the same profile while unbraid is on. If your configs come from a provider, check its limits for devices and simultaneous connections. WireGuard split tunneling on Android has more on DNS and keepalive, and two VPNs at the same time on Android shows configs running next to provider exits.

Questions

Where is “Allow multiple simultaneous tunnels” in the WireGuard app? In the app’s settings, once the kernel module backend is on. The app offers that backend only when it finds WireGuard in the kernel and gets root access. Otherwise the setting is removed from the list.

Can I run the WireGuard app and my VPN provider’s app together? Not in the same profile, if both use Android’s VPN service. Connecting the second normally disconnects the first. A work profile has its own VPN, for the apps installed inside it.

Can two tunnels both have 0.0.0.0/0? Two separate tunnels can. Something then chooses which one carries each connection: an app list, a profile, or a rule in the VPN app. Inside one tunnel, only one peer can have that exact range.

Bring your own VPN

unbraid is a VPN client with no servers of its own. You sign in with an account you already have, or add your own server. It has built-in support for AirVPN, ExpressVPN, IVPN, Mullvad, NordVPN (affiliate link), Private Internet Access, Proton VPN (Free included), Surfshark (affiliate link) and Windscribe. For CyberGhost, you import config files from your account, with step-by-step help in the app.

We earn a commission if you subscribe through a link marked (affiliate link). It helps keep unbraid free. If you're about to subscribe to a VPN service, thank you for considering doing it through one of them.