Files
Brad Fitzpatrick e55c2846a3 scripts: add script to detect and flush stale macOS DNS caches
macOS's mDNSResponder negatively caches NXDOMAIN/NODATA answers on its
own schedule, ignoring the negative TTL the MagicDNS resolver asks for.
When a Mac resolves a peer's name shortly before that node joins (or is
renamed to that name), it keeps answering "no such host" long after
Tailscale itself knows the peer. Users report this as the new node not
existing.

Add scripts/macos-dns-cache-check.sh, which runs "tailscale status
--json", asks mDNSResponder (via dscacheutil, which uses the same
lookup path as other macOS apps; dig and host bypass it) for the A/AAAA
records of every peer's DNSName, and compares them to the peer's
TailscaleIPs. It reports how many peers mismatch and how (no answer,
missing addresses, unexpected addresses), and if any do, flushes both
cache layers (dscacheutil -flushcache and killall -HUP mDNSResponder),
then re-checks the mismatched peers.

Under sudo it runs "tailscale status" as the invoking user first, since
the App Store variant only lets the CLI find the GUI's local API when
they run as the same user. It uses jq when present and falls back to
JavaScript for Automation for JSON parsing, since older macOS versions
don't ship jq.

Updates tailscale/corp#45631

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I7c3e9a1b52d84f6e0a9d3c7b8e1f4a2d6c5b9e08
2026-09-21 14:13:36 +00:00
..