How to run Tailscale and Proton VPN at the same time

A colleague runs two VPNs that do different jobs. Tailscale connects his devices to each other and to his server. Proton VPN lets his traffic leave from almost any country in the world. A phone runs one VPN at a time, so his day went: Tailscale off, Proton on, forget which is active, wonder why the server has vanished, toggle back.

We fixed it so he never toggles. The idea is simple and the details are where everyone gets stuck, so here they are. You need standard Tailscale on your devices, a commercial VPN subscription with WireGuard support, and any always-on Linux box that runs Docker. It's an evening's work.

Move the VPN off the phone, onto an exit node

Move the commercial VPN off your phone and onto the box. The box holds the Proton tunnel permanently. Tailscale on the box advertises it as an "exit node", which is Tailscale's name for "send all my internet traffic through this device". Your phone keeps Tailscale on, always, as its only VPN. When you want to look like Proton, pick the exit node from Tailscale's menu. When you don't, unpick it. One slot, both jobs, and the server never disappears.

With the exit node on, the path is: phone, encrypted over Tailscale to the box, then out through Proton to the internet. Your ISP sees Tailscale traffic to the box. The sites you visit see Proton. Proton sees the box's connection, which is what it saw anyway whenever you ran it there.

What you need

  • A Tailscale account with your devices on it. Free tier is fine.
  • A VPN subscription that gives you a WireGuard private key. Proton does, on a paid plan: Downloads, WireGuard configuration, pick any server, download the .conf. The only lines you need from it are PrivateKey and Address.
  • A Linux box that stays on and runs Docker Compose: at home, in the office, or a VPS. A Pi, a NUC, an old laptop, an Umbrel, a NAS that allows Docker. It needs /dev/net/tun, which nearly everything has.

The stack: Gluetun, Tailscale and a fixup loop

Three containers in one Compose file, sharing one network namespace so they see the same interfaces and routing table.

Gluetun is a VPN client in a box. Give it your provider name, country and key; it connects, holds the tunnel up, picks a new server if one dies, and runs a firewall that drops anything trying to leave outside the tunnel. It supports most commercial providers, so "Proton" in this post is a variable.

Tailscale runs inside Gluetun's network namespace with --advertise-exit-node. Give it a hostname that says what it is, something like proton-exit, and a state directory on disk so it keeps its identity across restarts. This is a separate node from any Tailscale you already run on the box for ordinary access; leave that one alone.

Give the Gluetun container its own address on the box's LAN with a Docker macvlan network, rather than Docker's default bridge. On the bridge, the only addresses Tailscale can advertise are an internal 172.x one your phone can't reach and the site's public IP, which most routers won't loop back to from inside the same network. So devices on that network end up on a Tailscale relay even though the box is ten metres away. With macvlan the node advertises a real 192.168.x.x:41641, your phone connects to it directly, and the port no longer collides with the Tailscale you already run on the host. Pin the container's MAC address in the compose file and reserve the IP on your router so DHCP never hands it to something else.

A fixup loop, which is the part no guide tells you about. Gluetun puts the VPN route in its own routing table and leaves the main table pointing at the box's own connection, by design. Traffic arriving from your phone on tailscale0 doesn't know to use the VPN table, so you tell it: a policy rule for "if it came in on tailscale0, use the VPN table", a return route for Tailscale's address range, a NAT rule on the tunnel, and a TCP MSS clamp so packets fit inside the tunnel. Gluetun rewrites firewall rules whenever it reconnects, so these get reapplied every few seconds, forever. The script is sixty lines and idempotent.

That's the whole thing. Compose file, .env with the key, one script. docker compose up -d, approve the exit node in the Tailscale admin console, pick it on your phone, open an IP checker and watch your city change.

Why your exit node might be slow

Tailscale marks its own packets, the encrypted link between the box and your phone, with a firewall mark. If your fixup routes marked packets into the VPN table too, Tailscale's connection to the phone travels inside Proton. My colleague's did, and I'd bet most of these setups share it.

The exit node's address, as your phone sees it, becomes a Proton address with no reachable port. The phone can't connect directly and falls back to a Tailscale relay. Every packet goes phone, relay, Proton, the box, back out through Proton, internet. Every time Proton moves servers, the link drops and rebuilds. Pages eventually load, and it's miserable.

The rule is one word different. Tailscale's own marked traffic uses the main table, out the box's own connection, like any other traffic from it. Only forwarded traffic from tailscale0 goes into the VPN. Your phone then connects to the box directly, stays connected when Proton changes servers, and the exit node feels like a normal VPN. Nothing new is exposed: the box already spoke Tailscale from that connection.

Two details that bit me. Tailscale installs its own low-priority copy of that "marked traffic, main table" rule, after Gluetun's catch-all, so it never wins; a script that checks for the rule by text will see Tailscale's and skip. Match on the priority. And tailscale netcheck can't verify this, because the CLI's sockets aren't marked; ask the kernel with ip route get 1.1.1.1 mark 0x80000 and expect dev eth0.

Keeping it updated

Use floating image tags and a fourth small container that runs nightly: pull, recreate if anything changed, verify the stack (Proton egress differs from the box's own IP, Tailscale is Running and advertising, routing rules present, forwarding fail-closed), and roll back to the previous images if verification fails. Tailscale falls behind fast otherwise, and the admin console will nag you about it.

Limits

The kill switch is rule-level: forwarding drops anything that isn't Tailscale-to-tunnel, and Gluetun's own firewall drops output that isn't the tunnel. I haven't yanked the tunnel under live traffic and watched the packets, so I won't call it tested. Gluetun picks a server at random within the country, not by load; if you get a slow one, recreate the stack. On mobile data, a carrier's NAT can still force a relay no matter what the box does. And with the exit node on, your phone can't reach printers and the like on local Wi-Fi unless you turn on Tailscale's "allow local network access".

If the box's network is split into VLANs, one more. Tailscale's "allow local network access" only exempts the subnet your phone or laptop is actually on. A server on a different VLAN is, to Tailscale, just another remote address, so it goes through the exit node and out via Proton, where it means nothing. Use the server's Tailscale address instead; that path bypasses the exit node by design and works the same from the couch or a café.

Sanitised compose, fixup script and updater are in the repo. Country, paths, hostname, LAN address and MAC are variables. The key lives in a .env on the box and nowhere else.

If you run both and you're still toggling, you've got a problem a Raspberry Pi can solve.

#tailscale #vpn #selfhosting #docker #privacy

View on Nostr