How do you guys use Tailscale (or other VPN) with containers
from lemmyvore@feddit.nl to selfhosted@lemmy.world on 29 Apr 14:32
https://feddit.nl/post/14446883

I wanted to run my VPN/Tailscale setup past you, see if anybody has suggestions on how I could do things better.

Goals for Tailscale:

Goals in general:

How I progresed with Tailscale:

  1. First tried running it directly on the host. Good: tailnet IP (let’s call it 100.64.0.2) available on the host’s default network stack. Containers can use “ports:” to map to 100.64.0.2 (tailscale) and/or 10.0.0.2 (LAN). Bad: tailscale would mess with /etc/resolv.conf on host. Also bad: tailscale0 on host picked up stuff that binds to 0.0.0.0.
  2. Moved tailscale to a container running on the host network stack (network_mode: host). Made it leave /etc/resolv.conf alone. tailscale0 on host stack still picks up everything on 0.0.0.0.

This is kinda where I’m stuck. I can make the tailscale container bridged which would put the tailscale0 interface inside the container. It wouldn’t pick up 0.0.0.0 from host but how would I publish ports to it?

#selfhosted

threaded - newest

zelifcam@lemmy.world on 29 Apr 17:46 next collapse

tailscale.com/blog/docker-tailscale-guide

I used the above link to start on my project. I’m trying to add Tailscale service to my existing docker-compose files to forward all traffic on the primary container to an exit node. It works, but I’m not able to find a way to access the web apps on those containers that are forwarding their traffic. Looks like you are well beyond this guide.

Best of luck.

lemmyvore@feddit.nl on 29 Apr 18:28 collapse

That guide did help me find out about TS_ env vars, which I don’t think are well documented elsewhere. From what I understand they’re container specific? I think they’re set up by containerboot, which is what the tailscale container image uses to boot.

TS_DEST_IP in particular is a game-changer. Docker needs more options for forwarding ports and interfaces. 🙁 “ports:” only forwards to the host and that’s about it.

Best of luck.

You too, what you’re trying to do looks like a challenge as well.

d13@programming.dev on 30 Apr 02:20 next collapse

This doesn’t exactly match your goals, but you may be able to adapt it or take pieces from it.

I have containers running on two subnets:

  1. LAN + Tailscale
  2. LAN only

Subnet 1 has a DNS server, which resolves all of my services to IPs on either subnet.

I have Tailscale set up on a machine as a subnet router (directing to Subnet 1).

Result:

  1. When local, I can access all services on the LAN with local DNS entries, both Subnet 1 and 2.
  2. When remote via Tailscale, I can access all services on Subnet 1 with the same local DNS entries. I cannot access services on Subnet 2.

This is nice because my apps don’t care which network I’m on, they just use the same URL to connect. And the sensitive stuff (usually management tools) are not accessible remotely.

It’s also ridiculously simple: Only one Tailscale service is running at home.

This does not solve your issue of broadcasting vs not broadcasting, though. There’s probably other things missing as well. But maybe it’s a start?

Lifebandit666@feddit.uk on 30 Apr 07:52 next collapse

I too am playing with Tailscale at the moment. What’s working for me (although I believe you’re well past this) is just running an exit node into my network. I have Adguard and NPM forwarding and reverse proxying and as long as I don’t use .local it seems that the nameserver works on Tailscale too, although I do get some errors in my testing at work yesterday.

I wonder if you could set up an Openwrt container or VM and add Tailscale to it. That way you could port forward all the ports you want to Tailscale

lemmyvore@feddit.nl on 30 Apr 13:55 collapse

I tried on OpenWRT but the tailscaled binary is huge and barely fits my router’s resources. I can sort of squeeze it in if I compact the daemon binary and run the client binary temporarily only when I change config and then delete it (the daemon doesn’t need it to run).

A tiny VM might be an interesting idea though. Would also be able to simulate some scenarios in case I ever need to get a VPS.

Decronym@lemmy.decronym.xyz on 30 Apr 14:05 next collapse

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

Fewer Letters More Letters
DNS Domain Name Service/System
IP Internet Protocol
Plex Brand of media server package
UDP User Datagram Protocol, for real-time communications
VPN Virtual Private Network
VPS Virtual Private Server (opposed to shared hosting)

6 acronyms in this thread; the most compressed thread commented on today has 14 acronyms.

[Thread #726 for this sub, first seen 30th Apr 2024, 14:05] [FAQ] [Full list] [Contact] [Source code]

gencha@lemm.ee on 30 Apr 16:28 next collapse

Sharing the network space with another container is the way to go IMHO. I use podman and just run the main application in one container, and then another VPN-enabling container in the same pod, which is essentially what you’re achieving with with the network_mode: container:foo directive.

Ideally, exposing ports on the host node is not part of your design, so don’t have any –port directives at all. Your host should allow routing to the hosted containers and, thus, their exposed ports. If you run your workloads in a dedicated network, like 10.0.1.0/24, then those addresses assigned to your containers need to be addressable. Then you just reach all of their exposed ports directly. Ultimately, you then want to control port exposure through services like firewalld, but that can usually be delayed. Just remember that port forwarding is not a security mechanism, it’s a convenience mechanism.

If you want DLNA, forget about running that workload in a “proper” container. For DLNA, you need the ability to open random UDP ports for communication with consuming devices on the LAN. This will always require host networking.

Your DLNA-enabled workloads, like Plex, or Jellyfin, need a host networking container. Your services that require internet privacy, like qBittorrent, need their own, dedicated pod, on a dedicated network, with another container that controls their networking plane to redirect communication to the VPN. Ideally, all your manual configuration then ends up with a directive in the Wireguard config like:

PostUp = ip route add 192.168.1.0/24 via 192.168.19.1 dev eth0

Wireguard will likely, by default, route all traffic through the wg0 device. You just then tell it that the LAN CIDR is reachable through eth0 directly. This enables your communication path to the VPN-secured container after the VPN is up.

[deleted] on 02 May 09:53 collapse

.