Behind an OpenWrt sing-box (Momo) transparent proxy, inbound Tailscale SSH can fail in a confusing way:
- Cold inbound
sshto a home node hangs or times out. - Running
tailscale ping <peer>from the home node first makes inbound SSH work immediately. - Leave that SSH session idle for a few minutes and the terminal freezes, even though both nodes still appear online.
Summary
- Cause: Momo intercepts Tailscale’s STUN and DERP traffic and sends it through
outbound/socks, which drops UDP or closes long-lived DERP connections withEOF. Inbound SSH only works while an outbound-opened NAT mapping stays warm. - Why domain rules miss it:
tailscaledreads relay endpoints from its DERP map and dials literal IP addresses, so.tailscale.comdomain rules never match DERP connections. - Quick workaround: Run
tailscale ping <CLOUD_NODE_TAILSCALE_IP>from the home node to open a direct UDP path, then keep it alive with/usr/bin/ping -n -i 15 <CLOUD_NODE_TAILSCALE_IP>while fixing the router. - Fix: Route Tailscale UDP (
source_port: 41641), STUN (udp/3478), and literal DERP IPs (tcp/80,443via a local rule-set) todirectbefore Fake-IP, GeoIP, and proxy rules. Keep.tailscale.comand.tailscale.iocontrol-plane domains on a stable proxy outbound.
Why it looks intermittent
Tailscale tries direct UDP first and falls back to DERP relays (or a Peer Relay) when NAT traversal fails:
- A cloud node opens a cold inbound SSH connection to the home node.
- No direct NAT mapping exists yet, so Tailscale falls back to DERP.
- Momo routes the DERP connection to
outbound/socks, where it dies withEOF. - Running
tailscale pingfrom the home node opens an outbound UDP NAT state and establishes a direct peer path. - SSH works over that direct path until idle time expires the NAT entry; with DERP broken, there is no fallback and the session freezes silently.
Because SSH works as soon as a direct path is warm, sshd is fine—the broken relay path is the issue.
Split control plane vs. transport plane
In mainland China behind OpenWrt transparent proxying, Tailscale’s two traffic planes need opposite routes:
- Control plane (
.tailscale.com,.tailscale.io): login, coordination, key exchange, ACL updates. Usually needs a stable proxy outbound. - Transport plane (peer UDP, STUN, DERP): WireGuard packets, NAT discovery, relay streams. Must bypass the proxy and go
direct.
Routing the whole device direct breaks control-plane reachability where coordination servers are blocked; proxying everything breaks UDP and DERP streams.
Confirming the problem
1. Check tailscaled on the home node
tailscale status
tailscale netcheck
systemctl status tailscaled
Look for a normal logged-in daemon with DERP/relay failures in netcheck. Do not restart tailscaled over an active SSH session—it will cut your connection without fixing router rules.
2. Compare cold inbound vs. warm NAT
From the cloud node, try SSH before sending anything from home:
ssh <USER>@<HOME_NODE_TAILSCALE_IP>
Then punch an outbound packet from the home node:
tailscale ping <CLOUD_NODE_TAILSCALE_IP>
If SSH starts working right after tailscale ping, outbound packets are warming a direct path while inbound relay fallback is dead.
3. Check tailscaled and Momo logs together
Home node:
journalctl -u tailscaled --since "30 minutes ago"
OpenWrt:
logread -e momo | tail -n 120
You should see tailscaled DERP EOF errors lining up with Momo sending literal DERP IPs into the proxy:
tailscaled: DERP connection -> EOF
Momo: <DERP_IP>:3478 -> outbound/socks
Momo: <DERP_IP>:80 -> outbound/socks
Momo: <DERP_IP>:443 -> outbound/socks
Why DNS-only rules fail
Putting .tailscale.com / DERP hostnames ahead of Fake-IP and GeoIP passes sing-box check, but DERP still ends up on outbound/socks. tailscaled already has the relay IPs from the downloaded DERP map and connects directly by IPv4/IPv6 without a domain match. Those connections fall straight through to the default proxy outbound unless matched by port and IP rule-set.
sing-box / Momo routing policy
Put these rules right after protocol sniffing—before source bypass, Fake-IP, GeoIP, private-CIDR, and selector rules:
{
"route": {
"rule_set": [
{
"type": "local",
"tag": "tailscale-derp",
"format": "source",
"path": "/etc/momo/ruleset/tailscale-derp.json"
}
],
"rules": [
{
"network": "udp",
"source_port": 41641,
"action": "route",
"outbound": "direct"
},
{
"network": "udp",
"port": 3478,
"action": "route",
"outbound": "direct"
},
{
"network": "tcp",
"port": [80, 443],
"rule_set": ["tailscale-derp"],
"action": "route",
"outbound": "direct"
},
{
"ip_cidr": [
"100.64.0.0/10",
"fd7a:115c:a1e0::/48",
"<CLOUD_NODE_PUBLIC_IP>/32"
],
"action": "route",
"outbound": "direct"
},
{
"domain_suffix": [".tailscale.com", ".tailscale.io"],
"action": "route",
"outbound": "<STABLE_PROXY_OUTBOUND>"
}
]
}
}
Check your node’s actual tailscaled UDP port before hard-coding 41641 (Tailscale firewall ports). If you also match DERP hostnames (derp*.tailscale.com), place that rule directly above the .tailscale.com proxy rule.
Keeping DERP IPs fresh
Tailscale rotates DERP IPs, so avoid a hand-maintained static list. Fetch the current map from:
curl -fsS https://login.tailscale.com/derpmap/default | jq .
Automate updates on the router with a scheduled job:
- Download
https://login.tailscale.com/derpmap/defaultto a temp file and verify valid JSON. - Extract all
IPv4andIPv6entries into a tempsing-boxsource rule-set (rule-set format). - Validate the full config with
sing-box check -c <MOMO_CONFIG>. - Atomically replace
/etc/momo/ruleset/tailscale-derp.jsononly if validation passes; keep the old file on failure.
Reload and cold-test
Keep a second SSH session open and set a timed rollback before reloading Momo remotely:
sing-box check -c <MOMO_CONFIG>
/etc/init.d/momo reload
/etc/init.d/momo status
logread -e momo | tail -n 120
Confirm all four flows hit the expected outbound in logread:
UDP source 41641 -> outbound/direct
UDP destination 3478 -> outbound/direct
DERP TCP 80 / 443 -> outbound/direct
Tailscale control plane -> <STABLE_PROXY_OUTBOUND>
Then verify from a cold state (a warm NAT test hides broken DERP):
- Stop any temporary
pingkeepalive. - Wait past the NAT idle timeout without running
tailscale ping. - SSH from the cloud node to
<HOME_NODE_TAILSCALE_IP>and confirm it connects on the first try. - Leave the shell idle past the previous freeze window and verify it still responds.
- Reboot the home node when convenient and repeat the cold SSH check.
Optional: self-hosted Peer Relay
If public DERP latency is too high, any cloud node with a public IP running Tailscale 1.86+ can serve as a private Tailscale Peer Relay:
sudo tailscale set \
--relay-server-port=<PEER_RELAY_UDP_PORT> \
--relay-server-static-endpoints="<CLOUD_NODE_PUBLIC_IP>:<PEER_RELAY_UDP_PORT>"
Open <PEER_RELAY_UDP_PORT>/udp on the cloud firewall, add <CLOUD_NODE_PUBLIC_IP>/32 to Momo’s direct CIDR list, and grant tailscale.com/cap/relay to the nodes that should use it.