Skip to content

A combination of Tailscale in a container, tailscale on a host and subnet routing leads to dreadful performance due to incorrect routing #20668

Open

Description

@ocharles

What is the issue?

AI disclaimer: I worked quite a lot with Claude on this. The following is somewhat Claude generated, but my hand has touched everything.

Summary

We're having a strange issue that seems to be the combination of using Tailscale on a host machine, within a container, subnet router in a different network, and a Tailnet device in the second network needing to reach the container. What we see is the device in the second network thinks the container is directly reachable at the subnet router, rather than connecting to the container. This leads to absolutely horrific network performance due to packet fragmentation. What I'd like to know is if this is a bug in Tailscale, or if there's a configuration problem on our side to avoid this. I've attached a Terraform module to reproduce the issue (albeit in a simplified configuration) on AWS.

Bug details

Essentially we have two networks - in this repro they are called "Network A" and "Network B". There is no peering between these networks, so clients in both networks can only communicate over Tailscale.

First, let's look at network A:

network A: 10.200.0.0/16 (var.region_a)
  host-a     public subnet. Tailscale node with --accept-routes.
  container  runs on host-a; its OWN Tailscale node, plus an iperf3
             server sharing its network namespace.

This network is meant to mirror our "production services" network. In practice this is AWS VPC with machines that run Nomad, and these Nomad clients run Docker containers that themselves run Tailscale. We do this so each node can run Caddy and use Magic DNS, etc. In this repro, this network just has a single machine, and we run a little container on this machine.

Next, network B:

network B: 10.100.0.0/16 (var.region_b)
  router     public subnet. Subnet router advertising 10.100.0.0/16
             with the default masquerade.
  host-b     private subnet, egress via NAT gateway. A plain Tailscale
             node — it needs no special configuration, which is part of
             what makes this surprising.

This network is meant to mirror our office LAN. We have some devices in the office that aren't on Tailscale, so we use a subnet router to expose them. host-b is a machine in this hypothetical office. It runs Tailscale itself, but note that its private address still falls inside the range router advertises - that turns out to matter a lot.

The bug happens when host-b wants to fetch a resource from container (e.g., container is a web server and host-b wants to view a page served by that server). What we end up seeing is that host-b thinks it has a direct connection to container, but the address it has chosen for that "direct" path actually belongs to router. Small packets sail through it, so pings stay fast and everything looks healthy, but bulk transfers fall apart - in the repro by a factor of about 1500. My understanding is the following chain of events:

  1. host-b advertises its private address (10.100.2.x:41641) as an endpoint candidate. The container's tailscaled probes it, looking for a direct path.
  2. The probe leaves the container and is FORWARDED by host-a's kernel, which has 10.100.0.0/16 -> tailscale0 installed by --accept-routes. host-a's own tailscaled marks its packets to bypass that route, but forwarded container traffic is not exempt. So instead of being undeliverable, the probe travels host-a's own tunnel to the router.
  3. The router forwards it onto network B, masqueraded, so it arrives at host-b as src=<router private IP>:<container's port>.
  4. host-b sees a cryptographically valid disco probe from the container at that address and replies, and NAT state on both machines carries the reply back. host-b now believes the container is DIRECTLY reachable at <router private IP>:<port> and prefers it over DERP, since any working UDP path beats a relay.
  5. Traffic between host-b and the container now runs inside two nested WireGuard tunnels. Inner packets are up to 1280 (tun MTU) + 60 bytes of WireGuard/UDP/IP overhead = 1340 bytes, which does not fit the outer tunnel's 1280 MTU, so every full-size packet is fragmented. Nothing signals this to either endpoint: both see a healthy 1280-byte MTU, and the inner packets are UDP without DF, so no ICMP is generated and PMTUD cannot help.

Terraform repro

Attached is a Terraform module that you can spin up to reproduce the issue.

Details
# The attached Terraform module reproduces a Tailscale issue we're having (albeit in a simplified configuration). Essentially we have two networks - in this repro they are called "Network A" and "Network B". There is no peering between these networks, so clients in both networks can only communicate over Tailscale.
#
# First, let's look at network A:
#
#   network A: 10.200.0.0/16 (var.region_a)
#     host-a     public subnet. Tailscale node with --accept-routes.
#     container  runs on host-a; its OWN Tailscale node, plus an iperf3
#                server sharing its network namespace.
#
# This network is meant to mirror our "production services" network. In practice this is AWS VPC with machines that run Nomad, and these Nomad clients run Docker containers that themselves run Tailscale. We do this so each node can run Caddy and use Magic DNS, etc. In this repro, this network just has a single machine, and we run a little container on this machine.
#
# Next, network B:
#
#   network B: 10.100.0.0/16 (var.region_b)
#     router     public subnet. Subnet router advertising 10.100.0.0/16
#                with the default masquerade.
#     host-b     private subnet, egress via NAT gateway. A plain Tailscale
#                node — it needs no special configuration, which is part of
#                what makes this surprising.
#
# This network is meant to mirror our office LAN. We have some devices in the office that aren't on Tailscale, so we use a subnet router to expose them. host-b is a machine in this hypothetical office. It runs Tailscale itself, but note that its private address still falls inside the range router advertises - that turns out to matter a lot.
#
# The bug happens when host-b wants to fetch a resource from container (e.g., container is a web server and host-b wants to view a page served by that server). What we end up seeing is that host-b thinks it has a direct connection to container, but the address it has chosen for that "direct" path actually belongs to router. Small packets sail through it, so pings stay fast and everything looks healthy, but bulk transfers fall apart - in the repro by a factor of about 1500. My understanding is the following chain of events:
#
#   1. host-b advertises its private address (10.100.2.x:41641) as an endpoint candidate. The container's tailscaled probes it, looking for a direct path.
#   2. The probe leaves the container and is FORWARDED by host-a's kernel, which has 10.100.0.0/16 -> tailscale0 installed by --accept-routes. host-a's own tailscaled marks its packets to bypass that route, but forwarded container traffic is not exempt. So instead of being undeliverable, the probe travels host-a's own tunnel to the router.
#   3. The router forwards it onto network B, masqueraded, so it arrives at host-b as src=<router private IP>:<container's port>.
#   4. host-b sees a cryptographically valid disco probe from the container at that address and replies, and NAT state on both machines carries the reply back. host-b now believes the container is DIRECTLY reachable at <router private IP>:<port> and prefers it over DERP, since any working UDP path beats a relay.
#   5. Traffic between host-b and the container now runs inside two nested WireGuard tunnels. Inner packets are up to 1280 (tun MTU) + 60 bytes of WireGuard/UDP/IP overhead = 1340 bytes, which does not fit the outer tunnel's 1280 MTU, so every full-size packet is fragmented. Nothing signals this to either endpoint: both see a healthy 1280-byte MTU, and the inner packets are UDP without DF, so no ICMP is generated and PMTUD cannot help.
#
# Attached is a Terraform module that you can spin up to reproduce the issue. Here's what you need to do to verify the problem:
#
#   terraform init
#   terraform apply -var ts_auth_key=tskey-auth-... \
#     -var ssh_public_key="$(cat ~/.ssh/id_ed25519.pub)"
#
# You'll need a reusable auth key - ephemeral is handy, as then the four nodes clean themselves up afterwards - and AWS credentials for two regions. Give cloud-init about three minutes, then approve router's 10.100.0.0/16 route in the admin console. Nothing goes wrong until that route is approved, which is convenient: it means you can take a "before" measurement on the same machines.
#
# `terraform output` prints the SSH command for each machine (host-b has no public address, so that one goes via ProxyJump through router). Everything below happens on host-b:
#
#   CONTAINER=$(sudo tailscale status --json |
#     jq -r '.Peer[] | select(.HostName=="repro-container") | .TailscaleIPs[0]')
#
# Before approving the route we see exactly what we'd expect - no direct connection (more on why below), and a healthy transfer over the relay:
#
#   $ sudo tailscale ping -c 3 $CONTAINER
#   pong from repro-container (100.73.220.52) via peer-relay(...) in 69ms
#   direct connection not established
#
#   $ iperf3 -c $CONTAINER -t 12 -R
#   [  5]  0.00-12.00 sec  380 MBytes  265 Mbits/sec  receiver
#
# Now approve the route. Within a minute or two of probing, host-b decides it has a direct path:
#
#   $ sudo tailscale ping $CONTAINER
#   pong from repro-container (100.73.220.52) via 10.100.1.57:23479 in 69ms
#
# 10.100.1.57 is router's private address - it belongs to neither peer - and 23479 is container's WireGuard port as rewritten by the two masquerades. `tailscale status` shows nothing unusual, the path simply looks direct. And the transfer falls off a cliff:
#
#   $ iperf3 -c $CONTAINER -t 12 -R
#   [  5]  0.00-12.00 sec  256 KBytes  175 Kbits/sec  receiver
#
# 265 Mbit/s down to 0.175 Mbit/s, stable across runs, while ping stays at 69ms throughout. That gap between "interactive feels fine" and "downloads are unusable" is what made this so puzzling for us in production.
#
# There are two controls worth running. First, take the fake endpoint away and change nothing else - on router:
#
#   sudo tailscale down
#
# host-b falls back to the relay and iperf3 gives ~225 Mbit/s, so the "direct" path Tailscale preferred is three orders of magnitude worse than the relay it was preferred over. To put router back you have to mention all the non-default flags:
#
#   sudo tailscale up --accept-dns=false --advertise-routes=10.100.0.0/16 --hostname=repro-router
#
# The fake endpoint re-forms within a minute, so this isn't something a restart fixes.
#
# Second, keep the fake endpoint but make the packets fit - on host-b:
#
#   sudo ip route replace $CONTAINER/32 dev tailscale0 table 52 advmss 1100
#   iperf3 -c $CONTAINER -t 12 -R                                  # ~295 Mbit/s, same fake path
#   sudo ip route replace $CONTAINER/32 dev tailscale0 table 52     # put it back
#
# Same path, same nested tunnels, same masquerades and extra hops - only the segment size changed, and throughput is back to normal. So the cost isn't the detour, it's the fragmentation. Two notes: use `replace` rather than an add/del pair, because table 52 is tailscaled's own; and advmss only constrains what the peer sends to us, which is why we measure with `iperf3 -R`. Without -R the clamp looks like it does nothing, since host-b's own segment size comes from the MSS container advertised.
#
# You can watch the fragmentation on router while iperf3 runs:
#
#   $ sudo tcpdump -ni tailscale0 'ip[6:2] & 0x3fff != 0'
#   IP 100.99.72.62.23479 > 10.100.2.91.41641: UDP, length 1312
#   IP 100.99.72.62 > 10.100.2.91: ip-proto-17
#
# Every full-size packet shows up as that pair: 1312 + 28 = 1340 bytes going into a 1280-byte MTU. Capture on tailscale0 specifically, as with `-i any` the filter doesn't match. /proc/net/snmp on router agrees - ReasmReqds increments at exactly twice ReasmOKs.
#
# One thing you might reasonably ask is why container and host-b never manage a real direct connection, given that would beat the fake endpoint. That's deliberate, and it mirrors our production situation: our office is behind a NAT that won't hole-punch. Here host-b sits behind an AWS NAT gateway and container behind an iptables MASQUERADE with --random-fully, both endpoint-dependent, so neither side can punch. Worth stressing that the outer router <-> host-a tunnel *is* a genuine direct connection - both have public addresses with UDP 41641 open - so none of the slowness above can be blamed on DERP.
#
# `terraform destroy` tears it all down. Three t3.small instances and a NAT gateway runs at about $0.11/hour.

terraform {
  required_version = ">= 1.5"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.0"
    }
  }
}

variable "ts_auth_key" {
  description = "Reusable Tailscale auth key. An ephemeral key is recommended so the four nodes remove themselves on destroy."
  type        = string
  sensitive   = true
}

variable "ssh_public_key" {
  description = "SSH public key installed on all three instances. host-b has no public address; reach it with ProxyJump through the router."
  type        = string
}

variable "region_a" {
  description = "Region for network A."
  type        = string
  default     = "us-east-1"
}

variable "region_b" {
  description = "Region for network B. A different region from region_a gives a realistic WAN RTT, which makes the throughput collapse obvious."
  type        = string
  default     = "eu-west-1"
}

variable "instance_type" {
  type    = string
  default = "t3.small"
}

provider "aws" {
  alias  = "a"
  region = var.region_a
}

provider "aws" {
  alias  = "b"
  region = var.region_b
}

data "aws_ami" "a" {
  provider    = aws.a
  most_recent = true
  owners      = ["099720109477"] # Canonical
  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd*/ubuntu-noble-24.04-amd64-server-*"]
  }
}

data "aws_ami" "b" {
  provider    = aws.b
  most_recent = true
  owners      = ["099720109477"]
  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd*/ubuntu-noble-24.04-amd64-server-*"]
  }
}

# Pin the subnets to an AZ that actually offers var.instance_type. Without this
# AWS picks an AZ for us, and some AZs (e.g. us-east-1e) offer no t3 instances
# at all, so the apply fails with "Unsupported: Your requested instance type is
# not supported in your requested Availability Zone".
data "aws_ec2_instance_type_offerings" "a" {
  provider      = aws.a
  location_type = "availability-zone"
  filter {
    name   = "instance-type"
    values = [var.instance_type]
  }
}

data "aws_ec2_instance_type_offerings" "b" {
  provider      = aws.b
  location_type = "availability-zone"
  filter {
    name   = "instance-type"
    values = [var.instance_type]
  }
}

locals {
  az_a = sort(data.aws_ec2_instance_type_offerings.a.locations)[0]
  az_b = sort(data.aws_ec2_instance_type_offerings.b.locations)[0]
}

# --- network A ---------------------------------------------------------------

resource "aws_vpc" "a" {
  provider   = aws.a
  cidr_block = "10.200.0.0/16"
  tags       = { Name = "ts16375-a" }
}

resource "aws_subnet" "a" {
  provider                = aws.a
  vpc_id                  = aws_vpc.a.id
  cidr_block              = "10.200.1.0/24"
  availability_zone       = local.az_a
  map_public_ip_on_launch = true
}

resource "aws_internet_gateway" "a" {
  provider = aws.a
  vpc_id   = aws_vpc.a.id
}

resource "aws_route_table" "a" {
  provider = aws.a
  vpc_id   = aws_vpc.a.id
  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = aws_internet_gateway.a.id
  }
}

resource "aws_route_table_association" "a" {
  provider       = aws.a
  subnet_id      = aws_subnet.a.id
  route_table_id = aws_route_table.a.id
}

resource "aws_key_pair" "a" {
  provider   = aws.a
  key_name   = "ts16375-repro"
  public_key = var.ssh_public_key
}

resource "aws_security_group" "host_a" {
  provider = aws.a
  vpc_id   = aws_vpc.a.id
  name     = "ts16375-host-a"

  # Open WireGuard so the outer host-a <-> router tunnel connects directly.
  ingress {
    from_port   = 41641
    to_port     = 41641
    protocol    = "udp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_instance" "host_a" {
  provider               = aws.a
  ami                    = data.aws_ami.a.id
  instance_type          = var.instance_type
  subnet_id              = aws_subnet.a.id
  vpc_security_group_ids = [aws_security_group.host_a.id]
  key_name               = aws_key_pair.a.key_name
  tags                   = { Name = "ts16375-host-a" }

  # cloud-init installs Tailscale from the internet, so the egress path has to
  # exist before the instance boots. Terraform will not infer this ordering.
  depends_on = [aws_route_table_association.a]

  user_data = <<-EOF
    #!/bin/bash
    set -eux
    curl -fsSL https://tailscale.com/install.sh | sh
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io
    systemctl enable --now docker

    # --accept-routes is the ingredient that lets the container's probes for
    # 10.100.x.x be forwarded into this host's own tunnel.
    tailscale up --auth-key='${var.ts_auth_key}' --hostname=repro-host-a \
      --accept-routes --accept-dns=false

    # Make the container's NAT endpoint-dependent so a genuine direct path
    # cannot be punched. Docker's own MASQUERADE preserves ports, which can be
    # punchable.
    iptables -t nat -I POSTROUTING 1 -s 172.17.0.0/16 ! -o docker0 \
      -j MASQUERADE --random-fully

    # A container with its own Tailscale node. Its WireGuard traffic leaves via
    # the bridge and is forwarded by the host kernel, so unlike the host's own
    # tailscaled it is subject to the accepted routes.
    docker run -d --name app --restart unless-stopped \
      --cap-add NET_ADMIN --device /dev/net/tun \
      -e TS_AUTHKEY='${var.ts_auth_key}' \
      -e TS_HOSTNAME=repro-container \
      -e TS_USERSPACE=false \
      -e TS_EXTRA_ARGS='--accept-dns=false' \
      tailscale/tailscale:stable

    # iperf3 server in the container's network namespace.
    docker run -d --name iperf --restart unless-stopped \
      --network container:app networkstatic/iperf3 -s
  EOF
}

# --- network B ---------------------------------------------------------------

resource "aws_vpc" "b" {
  provider   = aws.b
  cidr_block = "10.100.0.0/16"
  tags       = { Name = "ts16375-b" }
}

resource "aws_subnet" "b_public" {
  provider                = aws.b
  vpc_id                  = aws_vpc.b.id
  cidr_block              = "10.100.1.0/24"
  availability_zone       = local.az_b
  map_public_ip_on_launch = true
}

resource "aws_subnet" "b_private" {
  provider          = aws.b
  vpc_id            = aws_vpc.b.id
  cidr_block        = "10.100.2.0/24"
  availability_zone = local.az_b
}

resource "aws_internet_gateway" "b" {
  provider = aws.b
  vpc_id   = aws_vpc.b.id
}

resource "aws_route_table" "b_public" {
  provider = aws.b
  vpc_id   = aws_vpc.b.id
  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = aws_internet_gateway.b.id
  }
}

resource "aws_route_table_association" "b_public" {
  provider       = aws.b
  subnet_id      = aws_subnet.b_public.id
  route_table_id = aws_route_table.b_public.id
}

resource "aws_eip" "nat" {
  provider = aws.b
  domain   = "vpc"
}

# Gives host-b egress, and an endpoint-dependent ("hard") NAT so that a
# genuine direct path to the container cannot be established.
resource "aws_nat_gateway" "b" {
  provider      = aws.b
  allocation_id = aws_eip.nat.id
  subnet_id     = aws_subnet.b_public.id
  depends_on    = [aws_internet_gateway.b]
}

resource "aws_route_table" "b_private" {
  provider = aws.b
  vpc_id   = aws_vpc.b.id
  route {
    cidr_block     = "0.0.0.0/0"
    nat_gateway_id = aws_nat_gateway.b.id
  }
}

resource "aws_route_table_association" "b_private" {
  provider       = aws.b
  subnet_id      = aws_subnet.b_private.id
  route_table_id = aws_route_table.b_private.id
}

resource "aws_key_pair" "b" {
  provider   = aws.b
  key_name   = "ts16375-repro"
  public_key = var.ssh_public_key
}

resource "aws_security_group" "router" {
  provider = aws.b
  vpc_id   = aws_vpc.b.id
  name     = "ts16375-router"

  ingress {
    from_port   = 41641
    to_port     = 41641
    protocol    = "udp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  ingress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = [aws_vpc.b.cidr_block]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_instance" "router" {
  provider               = aws.b
  ami                    = data.aws_ami.b.id
  instance_type          = var.instance_type
  subnet_id              = aws_subnet.b_public.id
  vpc_security_group_ids = [aws_security_group.router.id]
  key_name               = aws_key_pair.b.key_name
  source_dest_check      = false
  tags                   = { Name = "ts16375-router" }

  depends_on = [aws_route_table_association.b_public]

  user_data = <<-EOF
    #!/bin/bash
    set -eux
    curl -fsSL https://tailscale.com/install.sh | sh
    DEBIAN_FRONTEND=noninteractive apt-get install -y tcpdump
    echo 'net.ipv4.ip_forward = 1' > /etc/sysctl.d/99-forward.conf
    sysctl -p /etc/sysctl.d/99-forward.conf
    # Default masquerade (no --snat-subnet-routes=false): forwarded tailnet
    # traffic is rewritten to this machine's private address, which becomes the
    # source of the fake endpoint.
    tailscale up --auth-key='${var.ts_auth_key}' --hostname=repro-router \
      --advertise-routes=10.100.0.0/16 --accept-dns=false
  EOF
}

resource "aws_security_group" "host_b" {
  provider = aws.b
  vpc_id   = aws_vpc.b.id
  name     = "ts16375-host-b"

  # Only reachable from inside network B — the fake endpoint arrives from the
  # router's private address.
  ingress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = [aws_vpc.b.cidr_block]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_instance" "host_b" {
  provider               = aws.b
  ami                    = data.aws_ami.b.id
  instance_type          = var.instance_type
  subnet_id              = aws_subnet.b_private.id
  vpc_security_group_ids = [aws_security_group.host_b.id]
  key_name               = aws_key_pair.b.key_name
  tags                   = { Name = "ts16375-host-b" }

  # Without this, host-b boots before its route to the NAT gateway exists and
  # cloud-init fails outright: the Tailscale install script cannot reach the
  # internet, so the machine comes up with no tailscaled at all.
  depends_on = [aws_route_table_association.b_private]

  user_data = <<-EOF
    #!/bin/bash
    set -eux
    curl -fsSL https://tailscale.com/install.sh | sh
    DEBIAN_FRONTEND=noninteractive apt-get install -y iperf3 jq
    tailscale up --auth-key='${var.ts_auth_key}' --hostname=repro-host-b \
      --accept-dns=false
  EOF
}

# --- outputs -----------------------------------------------------------------

output "fake_endpoint_ip" {
  description = "The router's private address. When the bug fires, `tailscale ping repro-container` on host-b reports a *direct* path via this address, which belongs to neither peer."
  value       = aws_instance.router.private_ip
}

output "ssh_router" {
  value = "ssh ubuntu@${aws_instance.router.public_ip}"
}

output "ssh_host_a" {
  value = "ssh ubuntu@${aws_instance.host_a.public_ip}"
}

output "ssh_host_b" {
  value = "ssh -J ubuntu@${aws_instance.router.public_ip} ubuntu@${aws_instance.host_b.private_ip}"
}

Here's what you need to do to verify the problem:

terraform init
terraform apply -var ts_auth_key=tskey-auth-... \
  -var ssh_public_key="$(cat ~/.ssh/id_ed25519.pub)"

You'll need a reusable auth key - ephemeral is handy, as then the four nodes clean themselves up afterwards - and AWS credentials for two regions. Give cloud-init about three minutes, then approve router's 10.100.0.0/16 route in the admin console. Nothing goes wrong until that route is approved, which is convenient: it means you can take a "before" measurement on the same machines.

terraform output prints the SSH command for each machine (host-b has no public address, so that one goes via ProxyJump through router). Everything below happens on host-b:

CONTAINER=$(sudo tailscale status --json |
  jq -r '.Peer[] | select(.HostName=="repro-container") | .TailscaleIPs[0]')

Before approving the route we see exactly what we'd expect - no direct connection (more on why below), and a healthy transfer over the relay:

$ sudo tailscale ping -c 3 $CONTAINER
pong from repro-container (100.73.220.52) via peer-relay(...) in 69ms
direct connection not established

$ iperf3 -c $CONTAINER -t 12 -R
[  5]  0.00-12.00 sec  380 MBytes  265 Mbits/sec  receiver

Now approve the route. Within a minute or two of probing, host-b decides it has a direct path:

$ sudo tailscale ping $CONTAINER
pong from repro-container (100.73.220.52) via 10.100.1.57:23479 in 69ms

10.100.1.57 is router's private address - it belongs to neither peer - and 23479 is container's WireGuard port as rewritten by the two masquerades. tailscale status shows nothing unusual, the path simply looks direct. And the transfer falls off a cliff:

$ iperf3 -c $CONTAINER -t 12 -R
[  5]  0.00-12.00 sec  256 KBytes  175 Kbits/sec  receiver

265 Mbit/s down to 0.175 Mbit/s, stable across runs, while ping stays at 69ms throughout. That gap between "interactive feels fine" and "downloads are unusable" is what made this so puzzling for us in production.

There are two controls worth running. First, take the fake endpoint away and change nothing else - on router:

sudo tailscale down

host-b falls back to the relay and iperf3 gives ~225 Mbit/s, so the "direct" path Tailscale preferred is three orders of magnitude worse than the relay it was preferred over. To put router back you have to mention all the non-default flags:

sudo tailscale up --accept-dns=false --advertise-routes=10.100.0.0/16 --hostname=repro-router

The fake endpoint re-forms within a minute, so this isn't something a restart fixes.

Second, keep the fake endpoint but make the packets fit - on host-b:

sudo ip route replace $CONTAINER/32 dev tailscale0 table 52 advmss 1100
iperf3 -c $CONTAINER -t 12 -R                                  # ~295 Mbit/s, same fake path
sudo ip route replace $CONTAINER/32 dev tailscale0 table 52     # put it back

Same path, same nested tunnels, same masquerades and extra hops - only the segment size changed, and throughput is back to normal. So the cost isn't the detour, it's the fragmentation. Two notes: use replace rather than an add/del pair, because table 52 is tailscaled's own; and advmss only constrains what the peer sends to us, which is why we measure with iperf3 -R. Without -R the clamp looks like it does nothing, since host-b's own segment size comes from the MSS container advertised.

You can watch the fragmentation on router while iperf3 runs:

$ sudo tcpdump -ni tailscale0 'ip[6:2] & 0x3fff != 0'
IP 100.99.72.62.23479 > 10.100.2.91.41641: UDP, length 1312
IP 100.99.72.62 > 10.100.2.91: ip-proto-17

Every full-size packet shows up as that pair: 1312 + 28 = 1340 bytes going into a 1280-byte MTU. Capture on tailscale0 specifically, as with -i any the filter doesn't match. /proc/net/snmp on router agrees - ReasmReqds increments at exactly twice ReasmOKs.

One thing you might reasonably ask is why container and host-b never manage a real direct connection, given that would beat the fake endpoint. That's deliberate, and it mirrors our production situation: our office is behind a NAT that won't hole-punch. Here host-b sits behind an AWS NAT gateway and container behind an iptables MASQUERADE with --random-fully, both endpoint-dependent, so neither side can punch. Worth stressing that the outer router <-> host-a tunnel is a genuine direct connection - both have public addresses with UDP 41641 open - so none of the slowness above can be blamed on DERP.

terraform destroy tears it all down. Three t3.small instances and a NAT gateway runs at about $0.11/hour.

Steps to reproduce

No response

Are there any recent changes that introduced the issue?

No response

OS

No response

OS version

No response

Tailscale version

1.98.10

Other software

No response

Bug report

No response

Activity

  1. added
    subnet
    and removed on Jul 29, 2026
  2. added theissue type on Jul 29, 2026
  3. IFindMe commented on Jul 29, 2026

    @IFindMe

    Tailscale doesn't care whether it's your Router IP, ISP IP, a cloud VM IP, or a VPN's forwarded IP—as long as both peers can exchange UDP packets.

  4. ocharles commented on Jul 29, 2026

    @ocharles
    Author

    I'm aware of that, but I'm not sure what your point is?

  5. bcreane commented on Aug 6, 2026

    @bcreane
    Contributor

    Throughput collapse here is #311

    Reproduced the data-plane symptom in natlab and measured it - details and packet-size evidence in #311, repro in #20681.

    Short version: on a direct path whose real MTU is 1280, a 1 MiB transfer moves 512 bytes; identical topology at 1500 moves all of it in 590ms. Dropped packets are 1340 (1280 TUN payload + 60 framing), because the data path uses tstun.SafeWireMTU() (1360) no matter what the path actually is. That's the "ping fine, downloads unusable" split reported here, and it's consistent with advmss clamping being an effective workaround.

    TS_DEBUG_ENABLE_PMTUD=true does not help: discovery correctly identifies the 1280 path and the result is discarded before it reaches the data path.

    Two other things in this report are not #311, and won't be fixed by fixing it:

    1. addCandidateEndpoint accepts endpoints with no plausibility check, so an address only reachable via the peer's own advertised subnet route becomes a direct-path candidate.
    2. A working UDP path beats DERP essentially permanently - betterAddr gives private IPs +20 and nothing demotes a path that's up but performing terribly.

    Fixing #311 resolves the reported symptom, likely in full. (1) and (2) are why traffic chose that path to begin with and would still misbehave on a path degraded some other way. Worth noting (1) has no obvious clean fix: filtering endpoints inside a peer's advertised subnet routes would also discard genuine LAN-direct paths.

    Probably the same root cause as #16197 (k8s operator, client MTU > proxy tailscale0 MTU).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T3 Performance/Debuggingbugsubnet

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions