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?

  • zzzzzz@lemmy.ml
    link
    fedilink
    arrow-up
    8
    ·
    8 months ago

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

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

    Here is an example docker-compose.yml:

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

      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@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        8 months ago

        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!

        • Mr. Forager@lemmy.worldOP
          link
          fedilink
          arrow-up
          3
          ·
          8 months ago

          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.

  • robotfriend@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    8 months ago

    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 - https://www.aapelivuorinen.com/blog/2022/09/12/transparent-mitmproxy-tailscale-vm/

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

  • cheet@infosec.pub
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    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.

    • Mr. Forager@lemmy.worldOP
      link
      fedilink
      arrow-up
      1
      ·
      8 months ago

      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.

  • maggio@discuss.tchncs.de
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    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

  • mFat@lemdro.id
    link
    fedilink
    English
    arrow-up
    1
    ·
    8 months ago

    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