I honestly can’t get my head around this. I have a machine with Linux (endeavouros), and docker with a few containers. Since I want all the traffic from this system to go through the VPN, do I need to set up gluetun? I think not, but I am not 100% sure…

    • Polite_Crocodile@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      4 months ago

      I simply enable the killswitch in mullvad settings and get all the Linux isos I need. But I’m thinking to keep gluetun enabled since I’ve already configured it

    • TCB13@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      4 months ago

      You can force all outgoing traffic to use the VPN interface via iptables/routes (meaning if it doesn’t exist or doesn’t work nothing will be able to access the internet) OR use systemd globally hide the non-VPN network interface from all services except for the VPN client.

        • TCB13@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          4 months ago

          but without nix it’s a pita to maintain through restores/rebuilds.

          No it isn’t. You can even define those routing polices in your systemd network unit alongside the network interface config and it will manage it all for you.

          If you aren’t comfortable with systemd, you can also use simple “ip” and “route” commands to accomplish that, add everything to a startup script and done.

          major benefit to using a contained VPN or gluetun is that you can be selective on what apps use the VPN.

          Systemd can do that for you as well, you can tell that a certain service only has access to the wg network interface while others can use eth0 or wtv.

          More classic ip/route can also be used for that, you can create a routing table for programs that you want to force to be on the VPN and other for the ones you want to use your LAN directly. Set those to bind to the respective interface and the routing tables will take place and send the traffic to the right place.

          You’re using docker or similar, to make things simpler you can also create a network bridge for containers that you want to restrict to the VPN and another for everything else. Then you set the container to use one or the other bridge.

          There are multiple ways to get this done, throwing more containers, like gluetun and dragging xyz dependencies and opinionated configurations from somewhere isn’t the only one, nor the most performant for sure. Linux is designed to handle this cases.

          • Chewy@discuss.tchncs.de
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            4 months ago

            Yes, there’s many ways to make programs unable to use other network interfaces. E.g. I’m creating a network namespace with a single wg0 interface, which I make services use through systemd NetworkNamespacePath.

            That said, I’d argue gluetun is pretty much foolproof, especially with most people using docker which messes with iptables (edit: although I don’t know if this’d be an issue for this use case).

  • gravitas_deficiency@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    8
    ·
    edit-2
    4 months ago

    It’s convenient if you want to see gluetun up as the only way a container (say, your torrenting container) can get to the open net, in the interest of avoiding getting directly pinged by DMCA rats. That way, if the VPN goes down, your torrent client isn’t just downloading stuff nakedly. Also, if you want to set up different VPN connections for different containers, it’s pretty easy to set a handful of replica containers for that too.

    • kitnaht@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      4 months ago

      That way, if the VPN goes down, your torrent client isn’t just downloading stuff nakedly.

      You always just bind the torrent client to the VPN adapter so this doesn’t happen. Most modern clients have this (qBittorrent certainly does)

    • TCB13@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      4 months ago

      All of that can be achieved with simple systemd or iptables/routes tweaks. You can force all outgoing traffic to use the VPN interface via routes (meaning if it doesn’t exist or doesn’t work nothing will be able to access the internet) OR use systemd globally hide the non-VPN network interface from all software except for the VPN client.

      • gravitas_deficiency@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        4 months ago

        Well sure, but the question was about gluetun, so I was trying to focus on that and the applications thereof. In terms of homelab stuff, I know a lot of people appreciate the containerized approach.

        • TCB13@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          4 months ago

          In terms of homelab stuff, I know a lot of people appreciate the containerized approach.

          What I said applies to containerized setups as well. Same logic, just managed in a slightly different way.