mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-29 21:12:45 -08:00
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 <[email protected]>
This commit is contained in:
1 parent
ef596ebd34
commit
eaf3fc8daf
2 files changed
+64
-1
No files matched your search
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user