From eaf3fc8daf90fb18714e21df38258db2ae33184a Mon Sep 17 00:00:00 2001 From: Nick Khyl Date: Tue, 20 Oct 2026 08:59:46 -0400 Subject: [PATCH] net/dns: don't make quad-100 the primary resolver on Windows when hosts are unrouted In #20775 (and the follow-up in #21471), we started installing quad-100 as the OS's primary resolver whenever cfg has hosts not covered by a split DNS route, so that sandboxed macOS clients could still answer them. However, that check was added to the generic split DNS gate rather than to the Apple-specific one, so it also applies on Windows, where dcfg.Hosts always carries every node's records and MagicDNSHostsUnrouted is set whenever MagicDNS is disabled. As a result, a Windows node with MagicDNS off and at least one split DNS route (or with MagicDNS on and a peer shared in from another tailnet) gets a catch-all NRPT rule pointing at quad-100, and all DNS traffic on the device is proxied through it instead of only the configured suffixes. The check is redundant for Apple platforms: iOS never takes the scoped path there, and sandboxed macOS only does so via scopeApple, which already requires !cfg.requiresPrimaryResolver(). This removes it from the generic gate, restoring the pre-1.104 behavior on Windows, and adds tests. Updates tailscale/corp#45534 Fixes #21863 Signed-off-by: Nick Khyl --- net/dns/manager.go | 2 +- net/dns/manager_test.go | 63 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/net/dns/manager.go b/net/dns/manager.go index 8a4d3dbccd..d7debcb2da 100644 --- a/net/dns/manager.go +++ b/net/dns/manager.go @@ -451,7 +451,7 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig // iOS still reads the base config below, even when scoped, so direct // queries to quad-100 can be forwarded to the underlying resolver. - if supportsSplitDNS && !isIOS && (!isSandboxedApple || scopeApple) && !cfg.requiresPrimaryResolver() { + if supportsSplitDNS && !isIOS && (!isSandboxedApple || scopeApple) { ocfg.MatchDomains = cfg.matchDomains() return rcfg, ocfg, nil } diff --git a/net/dns/manager_test.go b/net/dns/manager_test.go index de058f0ec6..2231c6f2d3 100644 --- a/net/dns/manager_test.go +++ b/net/dns/manager_test.go @@ -620,6 +620,69 @@ func TestManager(t *testing.T) { goos: "darwin", sandboxedMacOS: true, }, + { + // Windows with MagicDNS off: control sends a split route but no + // global resolvers. Hosts carries every node (Windows always + // does) and MagicDNSHostsUnrouted is set, but neither may force + // quad-100 to become the OS's primary (catch-all) resolver; the + // OS should only get an NRPT rule for the split suffix. + name: "windows-magicdns-off-split-route-stays-scoped", + in: Config{ + Routes: upstreams("corp.example.com.", "10.0.0.53"), + SearchDomains: fqdns("corp.ts.net"), + Hosts: hosts( + "self.corp.ts.net.", "100.100.0.1", + "peer.corp.ts.net.", "100.100.0.2"), + MagicDNSHostsUnrouted: true, + }, + split: true, + bs: OSConfig{Nameservers: mustIPs("192.168.1.1")}, + os: OSConfig{ + Nameservers: serviceAddr46, + SearchDomains: fqdns("corp.ts.net"), + MatchDomains: fqdns("corp.example.com"), + }, + rs: resolver.Config{ + Routes: upstreams("corp.example.com.", "10.0.0.53"), + Hosts: hosts( + "self.corp.ts.net.", "100.100.0.1", + "peer.corp.ts.net.", "100.100.0.2"), + }, + goos: "windows", + }, + { + // Windows with MagicDNS on and a shared-in peer from another + // tailnet. Its name is outside our MagicDNS root, so Hosts has a + // name no route covers; that still must not make quad-100 the + // primary resolver. + name: "windows-magicdns-on-shared-peer-stays-scoped", + in: Config{ + Routes: upstreams( + "corp.ts.net.", "", + "100.100.in-addr.arpa.", ""), + SearchDomains: fqdns("corp.ts.net"), + Hosts: hosts( + "self.corp.ts.net.", "100.100.0.1", + "shared.tail1234.ts.net.", "100.100.0.9"), + }, + split: true, + bs: OSConfig{Nameservers: mustIPs("192.168.1.1")}, + os: OSConfig{ + Hosts: []*HostEntry{ + {Addr: netip.MustParseAddr("100.100.0.1"), Hosts: []string{"self.corp.ts.net.", "self"}}, + }, + Nameservers: serviceAddr46, + SearchDomains: fqdns("corp.ts.net"), + MatchDomains: fqdns("100.100.in-addr.arpa", "corp.ts.net"), + }, + rs: resolver.Config{ + Hosts: hosts( + "self.corp.ts.net.", "100.100.0.1", + "shared.tail1234.ts.net.", "100.100.0.9"), + LocalDomains: fqdns("100.100.in-addr.arpa.", "corp.ts.net."), + }, + goos: "windows", + }, { // MagicDNSHostsUnrouted on a split-DNS manager with no base config // (e.g. systemd-resolved): fall back to a scoped config instead of