Some Bits: Nelson's log

6 posts about tailscale

Accessing Plex containers for Claude

I have like 20 containers in Proxmox now doing various services. I used to use Tailscale to access them all but my tailnet was getting cluttered up with stuff that only needed to be reachable for admin purposes, not regular use. This got untenable using Claude to do admin work.

The setup Claude came up with just requires LAN or Tailscale access to the proxmox host (pve). It then jumps through that via ssh to the each to container via a LAN connection. One added complication: Claude has to use an HTTP proxy for any ssh at all.

sandbox → HTTP proxy → claude@pve (over Tailscale) → ProxyJump → root@192.168.0.99:22 (the container)

Claude has its own ssh key that it’s managing. I am trusting this key with limited access to PVE and then full root access on the container. Scary but so far so good!

On PVE, Claude has a user account with a restrictive authorized_keys for Claude’s key. It limits what the key does to just proxying ssh PVE to the container. There’s one line like this for each container.

restrict,port-forwarding,permitopen="192.168.0.99:22",command="/bin/false" ssh-ed25519 AAAA… claude@desktop foo

On the container, root’s authorized_keys allows Claude in with full access.

In Claude’s shell environment, it has an SSH config with stanzas like this:

Host example
  HostName 192.168.0.99
  HostKeyAlias example-ct317
  User root
  ProxyJump pve

ProxyJump is a bit of ssh config magic that simplifies the process of sshing first into once place and then onto a second.

(I’m skipping over the details of how Claude uses the HTTP proxy to connect to PVE in the first place. This is necessary for any ssh at all to work, Claude Code seemed to have a solution for that workaround.)

This all seems baroque as I’m typing it all out (myself, not Claude) but it’s quite simple. Bottom line: Claude gets full root access to a container behind a firewall without tailscale on each container. Instead we use Proxmox as an ssh proxy but Claude only has minimal permissions on the Proxmox host.

Proxmox container for a Tailscale exit node

I want to set up a Tailscale exit node for me on the server with a good home Internet connection. This is a sort of poor-man’s VPN, routing all traffic through my home ISP connection. It’s pretty easy but I ran into a problem with IP forwarding.

First I set up a tiny Alpine container and used the Tailscale community script to set up Tailscale on it. You can install Tailscale by hand but this script handles the extra config needed to give an unprivileged LXC access to the tunnel device.

Then I set up Tailscale in the container to advertise as an exit node. The key thing there is sysctl configurations to enable IP forwarding inside the container OS. Very important! You also have to tell tailscale to advertise itself as an exit node.

Once I did this it worked. At least, I think it did. But it stopped working, maybe after a reboot?

To fix it, I also enabled IP forwarding via sysctl on the Proxmox server itself. I’m not 100% sure this is required or even a good idea. But when I enabled it, the exit node started working again. I’m a little confused about this but I think it’s OK.

Death to Tailscale MagicDNS

It took several years but I finally disabled Tailscale MagicDNS. It just caused too many problems. It broke Proxmox containers. It broke private DNS on my Android phone. It broke all sorts of stuff. I don’t want tailscale to mess with DNS.

I’ve replaced it with tailscale-cloudflare-dnssync. This is a simple Python program that uses Tailscale and Cloudflare APIs to read your entire tailnet’s list of hostnames and create DNS records. There’s a zillion versions of this kind of script, including some that support other DNS services. This one works fine for me. I’ve set it up to run daily but since the Tailscape IP assignments are static, the DNS records aren’t going to change much.

I also set up my local resolver to search the subdomain I put all the tailnet hosts in. So I can use short hostnames like sfrouter instead of FQDNs like sfrouter.tailscale.example.com.

The downside of this new setup is now all my tailnet hostnames are out there in a public DNS list somewhere. They all point to private unroutable IP addresses, so there’s very little someone can do with that info. But now someone could figure out with some DNS queries that I have, say, a PiKVM and then try to attack it somehow. Then again I remember when AXFR was still a supported DNS query, and a very useful one at that! It just doesn’t seem that big a worry for me.

MagicDNS was always a kludge. Tailscale would basically try to intercept your system’s DNS resolvers and insert its own at 100.100.100.100. Its primary feature I used was to serve address records for hostname.your-tailnet.ts.net. (These aren’t real DNS records, they were only visible to you from their special nameserver). Over time it has grown a lot of other complex features, none of which I want. And it caused all sorts of problems. Good riddance.

As a bonus I think this will make it easier for me to get working SSL certificates for my tailscale names. There’s some way to do that with MagicDNS but I never figured it out.

tailscale, Magic DNS, proxmox, and LXC

Frustrating interaction. tailscale MagicDNS breaks LXC under Proxmox. The solution is to start tailscale with --accept-dns=false on the Proxmox server. This is well documented by Tailscale but I missed it. In detail...

I have tailscale installed on the Proxmox hypervisor host, with MagicDNS enabled. If I start an LXC container then DNS doesn’t work at all in the container’s guest operating system.

The underlying issue is how tailscale does MagicDNS, how it answers DNS queries to supply its own answers for your hosts at *.*.ts.net. On Linux it does this by rewriting /etc/resolv.conf setting nameserver 100.100.100.100. The details of how it does this are complex because so many other things on a modern Linux box are also trying to overwrite that file. (Yes, systemd is involved). But it seems to work fine on the Proxmox server.

What doesn’t work is MagicDNS inside an LXC container. When you launch LXC it seems to start with a copy of whatever /etc/resolv.conf is in the Proxmox host. (Every time; if you reboot the container it gets a new copy.) So if tailscale is running it can pick up that 100.100.100.100 nameserver. Unfortunately the LXC guest operating system does not have access to that IP address (nor to any of your tailnet, it shouldn’t!) So DNS doesn’t work.

The simple fix is to turn off tailscale on the proxmox server: tailscale down. But it’s nice to have tailscale to access the server! If you run tailscale up --accept-dns=false then there’s no MagicDNS on the Proxmox server and /etc/resolv.conf is left alone. This setting seems to be sticky, it’s persisting even though I didn’t edit any config files.

Another option the docs mention is writing a /etc/.pve-ignore.resolv.conf file in the LXC container’s filesystem. That’s part of a general mechanism to have Proxmox not overwrite files in LXC guests.

Tailscale key expiry

I had my first real problem with Tailscale. Not coincidentally, six months after first using and loving it. Tailscale expires keys every 180 days and you have to manually re-authenticate every single host. This is the first bad user experience I’ve had with Tailscale, the product is usually much friendlier.

I got no notice that this expiration was coming. And it’s potentially catastrophic; what if your host is unreachable except via Tailscale? (See below). I don’t use Tailscale a lot and I don’t have any proper monitoring. Maybe if I were paying closer attention I’d have known it was coming?

The rest of this note is a little ranty because I’m experiencing the indignation of a sharp corner on an otherwise very nicely designed product. Tailscale folks, I love your product. This part of it needs some attention. To be fair, key management and updates are a hard problem in all of software, Tailscale is not unusual.

How to update Tailscale key

Re-authenticating isn’t hard with the CLI: just run tailscale up --force-reauth. This gives you a URL that you load in a browser logged in to Tailscale’s management console. It’s a remarkably manual process. The Android GUI client is a little easier; you’re prompted to log in directly on the device itself.

But here’s the shit sandwich: “tailscale up --force-reauth currently involves bringing down the Tailscale connection and thus should not be done remotely over SSH or RDP.” Can confirm; I tried to update a remote host via ssh over Tailscale and the update hung before I saw the authentication URL. A terrible experience for a networking product whose major purpose is remote administration of machines. And the auth process is interactive, you can’t just fire it off in a cron job or something. (There’s a hint that maybe there’s a “Reauthenticate” option in the dashboard after a machine “has already signed a new authentication URL” but I no longer have an expired host to test that with.)

I do give the product team credit, they did think about the “what if I can’t access the host to update it?” problem. There’s a button you can press to temporarily enable an expired key (for 30 minutes), giving you access. You still have the “how do you update remotely” problem but at least you can get to the host.

There may be a better way to do all this; you can generate auth keys and automate using them. Maybe a more serious Tailscale deployment is managed that way, I haven’t looked into it. The default keys are a great user experience right until they expire.

Determining Tailscale key status

The software tools for detecting whether your Tailscale key is expired are not good. The best tool is the Machines dashboard; this does have a status line and you can filter for expired machines.

On a host with an expired key your first clue that something isn’t working is probably when you can’t access other hosts on the Tailnet. tailscale status reports a confusing message, “Health check: not connected to home DERP region 12. Logged out.”. If you try tailscale up it will prompt you to reauthenticate and afterwards tailscale status will keep showing you the auth URL until you reauth.

On a working connected host elsewhere on a tailnet tailscale status does not show you if another host has an expired key. The status shown is - which I think means “unknown”. It’s not offline or some special expired status. tailscale ping will report peer's node key has expired.

I could not find a way to see what machines were soon to be expired in the machine dashboard; the keys page doesn’t show the automatic keys that the default path uses. The command line tools don’t seem to tell you either, or at least I can’t find it. I guess you can periodically tailscale up --force-auth to refresh the keys but it’s up to you to know when to do that? Again, I assume using managed auth keys is the real solution for this.

Why expire at all?

I don’t quite understand why Tailscale expires host keys at all. There’s a general idea that expiring logins, etc is good security practice to solve various corner cases like a years-old server that gets recycled or is running an old insecure version. Sorta? But for that kind of thing I much prefer a system where an old auth token is only expired if it has not been used for awhile; expiring something that was trusted just minutes ago seems like a bad decision.

It’s possible to disable key expiration for specific hosts via the machines dashboard. The docs suggest this is for “trusted servers, subnet routers, or remote IoT devices that are hard to reach.” There’s no way to disable expiration for a whole tailnet; all you can do is set the expiration time from 1 to 180 days.

Windows update

This isn’t about key expiration really, but the Windows client still has no auto-updater. I was still running 1.30 with a security hole! They’re working on it (and recently changed the installer they use) but it doesn’t seem a high priority. Installing an update is easy enough but it really needs to be automatic.

Tailscale first impressions: very good

Goodness what a networking miracle. After years of failing to get VPN tunneling set up between two houses, I finally gave Tailscale a try. I thought it’d take me a few hours to get going. No: 10 minutes, tops, and I was VPNing from one house to another without regard for the NAT on one side and the Starlink double NAT on the other.

Never seen a complex networking software like this work so easily. The install experience is a dream; great clear docs, everything Just Works. Linux, Windows, Android, just install the thing, log in via Google with one click, done. I immediately could ping the new Tailscale IP address to reach my machine. There’s a great, easy to understand web console showing status of all your Tailscale hosts.

Behind the scenes it’s not magic so much as well-put-together parts. Wireguard is the underlying VPN protocol, making it easy to set up point to point tunnels. Some sophisticated NAT traversal (and relay servers) ensure everything can connect to each other. All the keys, negotiation, and naming is handled in a datastore Tailscale runs. You authenticate to Tailscale using one of many choices; Google is definitely very seamless.

The one thing I’m on the fence about with Tailscale is that it’s designed as a point-to-point VPN between hosts running Tailscale. That means that while I can access my Linux box behind NAT, I can’t access my thermostat on the same LAN directly like you’d normally expect with a router VPN. They do support full subnet routing via a Tailscale node, that seems like a big commercial feature for them, but it’s not the simple default setup. OTOH this P2P model will cover 90% of what I need to do and has some advantages aside.

I assume there’s no way to use Tailscale without trusting Tailscale itself; its software and service are in the middle. I’m fine with that but I wonder how that limits their sales to big companies. There is an open source alternative server that so far the Tailscale company has been friendly about.

Configuration

I didn’t really have to do any setup beyond install, but I did a couple of extra things.

I set up DNS aliases in a domain I own for all my hosts. Now I can connect to sfwin.ts.example.com instead of some opaque IP address. Tailscale has their own beta feature for DNS (MagicDNS) but it works by having your client machines use their DNS server instead of your own. That’s probably fine but I didn’t want to quite jump to that yet. MagicDNS will automatically add new Tailscale hosts to DNS records; I’ll have to do that manually.

I forwarded UDP port 41641 from my router to my Linux server in SF. This isn’t necessary, but I noticed that traffic between my two Linux boxes behind NAT routers was going via one of Tailscale’s relays, overhead I’d rather avoid. Tailscale does have a lot of NAT traversal, even simple UPnP would have worked, but this static forward is fine by me too. I’m not positive but I think it’s helped.

Kicking the tires

tailscale status is an invaluable command for seeing what’s going on with your peers. It prints basic status of your hosts with extra information for open links like idle, tx 820 rx 732 or active; direct 98.97.1.1:16227

tailscale ping has some tailscale-specific info. For instance this is what it looks like when I ping a host behind double NAT when the link was previously down. I’m not positive but I take this as evidence that the link first comes up via a relay in Seattle, then switches to direct connection after a few pings.

nelson @tt ~ 1 ❯ tailscale ping gvlin.ts.example.com
pong from gvlin (100.106.1.1) via DERP(sea) in 316ms
pong from gvlin (100.106.1.1) via DERP(sea) in 97ms
pong from gvlin (100.106.1.1) via DERP(sea) in 76ms
pong from gvlin (100.106.1.1) via 98.97.1.1:16227 in 224ms
nelson @tt ~ 3s ❯ tailscale ping gvlin.ts.example.com
pong from gvlin (100.106.1.1) via 98.97.1.1:16227 in 95ms

I’m curious about performance. For two hosts without Tailscale I could get about 360Mbps copying a stream of random numbers with a direct link (via ssh and rsync, so maybe some encryption involved). With tailscale I got maybe half that, 200Mbps, using 140% of CPU on the server and 80% of CPU on the client receiving the file. I did one try of a copy via a relay and maxed out at about 10Mbps; if that’s a real problem you can run your own relay server. I didn’t test packet loss or latency using iperf3 or the like, but I suspect it’s not much different than the underlying medium.

Tailscale hosts are getting addresses in the 100.64.0.0/10 block used for private networks. Boy I hope that never collides with Starlink’s use of this block! They also have IPv6 support but I’m not sure whether I’m likely to ever use those addresses.

One confusing thing; on Linux tailscale isn’t using the routing table for its VPN traffic. While there is a tailscale0 network device, there is no route shown in ip route for the 100.64.0.0/10 block. Instead it’s in the IP Tables, as iptables -S shows. I don’t really understand IP tables so I couldn’t decipher all the rules but it looks like there’s one blanket rule, not a specific rule for each destination host.

Tailscale links go down after just a little bit of disuse but come back up immediately when used. Latency for that first packet through is under one second.

Making my Windows machine part of Tailscale means the WSL Linux images running on it also can access the private VPN addresses. I believe WSL2 works entirely via forwarding through the host Windows networking, so that’s not a surprise.

Tailscale has some higher end authentication features, in particular a way to integrate ssh logins. I haven’t tried them. There’s also an alpha feature for collecting a list of “services” running on Tailscale nodes for easy access.