Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
headscale-derp【部署与运维】Configure and manage DERP relay servers for Tailscale/Headscale — embedded and standalone DERP deployment, latency testing, and connectivity diagnostics. Use when direct peer connections fail, traffic is routed through DERP relays, or setting up custom relay regions.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
DERP = Designated Encrypted Relay Protocol. DERP is Tailscale's TURN-like fallback mechanism used when direct peer-to-peer NAT traversal fails. Traffic through DERP is fully encrypted (WireGuard inside TLS), but it routes through a relay server rather than directly between peers, so it introduces additional latency.
Common scenarios where DERP is used:
Headscale includes an embedded DERP server that is enabled by default in the config.yaml:
derp:
server:
enabled: true
region_id: 999
region_code: "headscale"
region_name: "Headscale Embedded DERP"
stun_listen_addr: "0.0.0.0:3478"
private_key_path: "/var/lib/headscale/derp_server_private.key"
The embedded server runs a STUN endpoint on port 3478 and relays on port 443 (or whatever port Headscale listens on). It's suitable for small tailnets (under ~50 nodes).
| Option | Default | Description |
|---|---|---|
derp.server.enabled | true | Enable the embedded DERP server |
derp.server.region_id | 999 | Numeric region identifier (must be unique across all regions) |
derp.urls | [] | Additional DERP map URLs (for standalone servers) |
derp.paths | [] | Local DERP map JSON file paths |
derp.auto_update | true | Automatically fetch Tailscale's default DERP map |
derp.stun_listen_addr | 0.0.0.0:3478 | STUN listener address |
A DERP map is a JSON structure that defines relay regions and nodes. Example:
{
"Regions": {
"900": {
"RegionID": 900,
"RegionCode": "us-nyc",
"RegionName": "New York",
"Nodes": [
{
"Name": "900a",
"RegionID": 900,
"HostName": "derp-nyc.example.com",
"DERPPort": 443,
"STUNPort": 3478,
"STUNOnly": false
}
]
}
}
}
The DERP map can be served via HTTPS URL (put in derp.urls) or as a local JSON file (put in derp.paths).
Run tailscale netcheck to see which DERP regions are reachable and their latency:
$ tailscale netcheck
Report:
* UDP: true
* IPv4: yes
* IPv6: no
* MappingVariesByDestIP: true
* HairPinning: false
* PortMapping: UPnP
* Nearest DERP: Dallas
* DERP latency:
- dallas: 18ms (dallas)
- us-west: 35ms (us-west)
- new-york-city: 5ms (new-york-city)
- london: 85ms (london)
For larger tailnets or dedicated relay capacity, run a standalone DERP server using the official tailscale/derper Docker image:
docker run -d \
--name=derper \
--restart=always \
-p 3478:3478/udp \
-p 443:443 \
-v /etc/letsencrypt:/certs \
-v /var/lib/derper:/var/lib/derper \
tailscale/derper \
--hostname=derp.example.com
DERP requires TLS. Recommended approaches:
tailscale/derper supports automatic certificate issuance via Let's Encrypt. It listens on port 80 for the ACME HTTP-01 challenge.--cert=/path/to/cert.pem --key=/path/to/key.pem to the derper binary.Tailscale clients automatically select the DERP region with the lowest latency. The selection algorithm:
tailscale netcheck to force a refresh.This skill is activated by keywords: DERP, relay, peer relay, STUN, direct connection failed
Do not use this skill when direct peer connections work — DERP tuning is only needed when NAT traversal fails. For general client connectivity diagnostics, load tailscale-client instead.