[Solved with Gluetun] Tailscale ExitNode with VPN

I would really really really like to have one device on my tailnet as the exitnode for all other devices on the tailnet. However, most VPNs make this really difficult. Is there any way to do this? I’ve read it’s possible with split-tunnelling, but ProtonVPN (which I use) doesn’t support that. I just installed Alpine Linux on my RPI 4b. And would like to use this as my exit node. Does anyone have any tips for how this could be done?

mzumquadrat,

If you are able to switch away from Proton VPN in the long run you could use the new tailscale/mullvad partnership to use mullvad as an exit node. tailscale.com/kb/1258/mullvad-exit-nodes/

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

I did think about it, but I use all of their services anyway, so for me it’s plenty worth it. I save money on paying for a suit, rather than individual services here an there.

zzzzzz,

I have solved this problem! The trick is to use two Docker containers:

  1. Gluetun (github.com/qdm12/gluetun): set this up to connect to your VPN.
  2. Tailscale (tailscale.com/kb/1282/docker/): set this to use the Gluetun network.

Here is an example docker-compose.yml:


<span style="color:#323232;">version: "3"
</span><span style="color:#323232;">services:
</span><span style="color:#323232;">  gluetun:
</span><span style="color:#323232;">    image: qmcgaw/gluetun
</span><span style="color:#323232;">    container_name: gluetun
</span><span style="color:#323232;">    # line above must be uncommented to allow external containers to connect.
</span><span style="color:#323232;">    # See https://github.com/qdm12/gluetun-wiki/blob/main/setup/connect-a-container-to-gluetun.md#external-container-to-gluetun
</span><span style="color:#323232;">    restart: unless-stopped
</span><span style="color:#323232;">    cap_add:
</span><span style="color:#323232;">      - NET_ADMIN
</span><span style="color:#323232;">    devices:
</span><span style="color:#323232;">      - /dev/net/tun:/dev/net/tun
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - ./gluetun:/gluetun
</span><span style="color:#323232;">    environment:
</span><span style="color:#323232;">      - VPN_SERVICE_PROVIDER=airvpn
</span><span style="color:#323232;">      - VPN_TYPE=wireguard
</span><span style="color:#323232;">      - WIREGUARD_PRIVATE_KEY=xxx
</span><span style="color:#323232;">      - WIREGUARD_PRESHARED_KEY=xxx
</span><span style="color:#323232;">      - WIREGUARD_ADDRESSES=xxx
</span><span style="color:#323232;">      - WIREGUARD_MTU=1320
</span><span style="color:#323232;">      - SERVER_COUNTRIES=United States
</span><span style="color:#323232;">      # See https://github.com/qdm12/gluetun-wiki/tree/main/setup#setup
</span><span style="color:#323232;">      # Timezone for accurate log times
</span><span style="color:#323232;">      - TZ=America/New_York
</span><span style="color:#323232;">      # Server list updater
</span><span style="color:#323232;">      # See https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list
</span><span style="color:#323232;">      - UPDATER_PERIOD=24h
</span><span style="color:#323232;">
</span><span style="color:#323232;">  tailscale:
</span><span style="color:#323232;">    container_name: tailscale
</span><span style="color:#323232;">    cap_add:
</span><span style="color:#323232;">      - NET_ADMIN
</span><span style="color:#323232;">      - NET_RAW
</span><span style="color:#323232;">    volumes:
</span><span style="color:#323232;">      - ./tailscale/var/lib:/var/lib
</span><span style="color:#323232;">      - ./tailscale/state:/state
</span><span style="color:#323232;">      - /dev/net/tun:/dev/net/tun
</span><span style="color:#323232;">    network_mode: "service:gluetun"
</span><span style="color:#323232;">    restart: unless-stopped
</span><span style="color:#323232;">    environment:
</span><span style="color:#323232;">      - TS_HOSTNAME=airvpn-exit-node
</span><span style="color:#323232;">      - TS_AUTHKEY=xxxxxxxx
</span><span style="color:#323232;">      - TS_EXTRA_ARGS=--login-server=https://example.com --advertise-exit-node
</span><span style="color:#323232;">      - TS_NO_LOGS_NO_SUPPORT=true
</span><span style="color:#323232;">      - TS_STATE_DIR=/state
</span><span style="color:#323232;">    image: tailscale/tailscale
</span>
LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Wow! You know what, I was just thinking about using Gleutun for this enefore I went to bed last night, and then I wake up to this gem of a message!! 😅 Well done sir, I’ll be cooking this up ASAP!

zzzzzz,

Let me know how it works out for you! I’m happy to be able to share this. I was very pleased with myself but had no one to tell haha. I actually have several copies of this set up with each Gluetun instance connected to different countries. Then, changing country is as easy as changing your tailnet exit node!

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Awesome stuff dude! I will totally do this too 😁 Worst thing is I am already using Gleutun and I am ashamed I didn’t think about using it for this before… But honestly gonna have to donate some money to the developer of Gleutun as its just so awesome.

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Hell yeah, got that working in an instant! Appreciate the pointer, have a great weekend! :)

zzzzzz,

Awesome! You too.

robotfriend,

I’ve been trying to accomplish the exact same thing. In the same vein I’ve also been trying to setup a tailscale exit node with mitmproxy so that i can inspect mobile app traffic without having to fiddle with proxy configs on my phone each time. In relation to that i found this - aapelivuorinen.com/…/transparent-mitmproxy-tailsc…

Let me know how you get on as I’m super keen on having both a VPN and mitmproxy setup as exit nodes.

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

A solution was posted in later comments, did you see?

robotfriend,

I did thanks, will be trying it out later today. Cheers.

mfat,

Maybe this can be achieved by doing this: 1.Connect to ProtonVPN on your exit node machine 2.Create a vm inside that machine 3.Install Tailscale on the vm 4.Use it as an exit node

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Interesting, I could try that. Already tried with a docker container, which didn’t work. But could try this too.

mfat,

Use vit-manager and install a minimal ubuntu vm.

cheet,

I’ve read some of the comments and it sounds like you’ve already tried installing proton VPN and tailscale on the same machine, but depending on your setup maybe you could make a “VPN gateway”

Like take your pi, install protonvpn, then enable IP forwarding and use a little nat IP tables script to nat your lan to your proton VPN interface like a home router would with the wan and lan ports.

Then on your tailscale gateway set the default route to be that box instead of your normal router. Then just use the tailscale node as the exit node on your client and check your IP.

In theory this would be similar to a qubes type setup which is what I tend to use for this kind of work.

cheet,

This also adds the benefit that any other devices that wanna VPN can just use the gateway

lemmyvore,

Have you read this article? tailscale.com/kb/1105/other-vpns/

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Jupp 😅

maggio,

Yes you can do this, you can use ANY device/node as an exit-node among your tailscale nodes.

You do need a server to setup the nodes though. Tailscale offer this as a paid service I believe, or you could run your own headscale (open source project) server yourself, this requires a lot more knowledge

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

I am aware I can run a tailscale exit node. But want to know if it is possible do so with the same node running protonvpn…

BaalInvoker,

With Tailscale you have only to declare this device as exit node. It’s just one single command, pretty simple

Edit:

Here’s how: tailscale.com/kb/1103/exit-nodes/-2-advertis…

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Right that is pretty much clear, but I want this exit node to be running ProtonVPN as well. This however does not seem to be possible (to my knowledge). Edit: This is also why Tailscale added support for Mullvad VPN i assume.

BaalInvoker,

Ok… I think I didn’t get what you’re trying to say. Do you wanna run a VPN through a VPN?

I mean, you have your RPI 4b as a Tailscale exit node, but the RPI 4b itself connects to the ProtonVPN?

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Right, so I’ve got Alpine on the RPI, and have installed/configured protonvpn with wireguard. However, if I then start Tailscale, the already running ProtonVPN connection goes down. Same happens if Tailscale is already running, and I try to start the ProtonVPN connection it will just refuse the connection.

I want it to connect to both services, as then this can act as the exitnode for all other devices on the tailnet. Whilst also giving the benefit of ““being in a different location”” with protonvpn.

So essentially, both services wants to use /dev/net/tun, but only one can.

BaalInvoker,

Well, I found this article saying that theoretically is possible, however not so much. It says that depends on how the other VPN works. They even suggest some workarounds, so take a look

Anyway, have you tried to create another tun/tap service to run both VPN?

LunchEnjoyer,
@LunchEnjoyer@lemmy.world avatar

Yeah already scoured their documentation for this, but no luck with any of the workarounds sadly.

Have not tried to do the latter you mentioned though? Not sure how to do that, but I will look into it asap.

BaalInvoker,

I never had to create a new TUN/TAP interface before, so I’m on the same boat as you. I’m brainstorming here with you and hoping for the best

But here is how to create a new tun interface:

baeldung.com/…/create-check-network-interfaces

You’ll have to manually set some parameters to make it work, I guess

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • [email protected]
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • oklahoma
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • SuperSentai
  • feritale
  • KamenRider
  • All magazines