mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-20 08:41:19 -08:00
net/dns: align Apple resolver scoping with search-domain behavior
Apple tunnels derive global search domains from match domains. Scope simple iOS and sandboxed macOS configurations to the full MagicDNS route set; keep custom split resolvers and uncovered forward/PTR records behind a primary resolver. Respect scoping controls and reject unsafe fallback when base DNS cannot be read. Add mode-selection and reverse-coverage tests for both Apple platforms. RELNOTE: Fix MagicDNS routing and split-DNS search scoping on Apple clients. Updates tailscale/corp#48693 Change-Id: I50b5641db466f77c19f911255748e12a10d0a5fe Signed-off-by: James Tucker <[email protected]>
This commit is contained in:
1 parent
70422c917a
commit
0fe0fe4524
6 files changed
+354
-91
No files matched your search
@@ -142,12 +142,11 @@ type Knobs struct {
|
||||
// is supported by the client and storage is available.
|
||||
CacheNetworkMaps atomic.Bool
|
||||
|
||||
// ScopeQuad100OnMacOS is whether sandboxed macOS should scope quad-100 to
|
||||
// its match domains rather than installing it as the OS's primary resolver,
|
||||
// so a user's DoH system profile isn't shadowed. It has no effect on other
|
||||
// platforms. Off by default; when off, sandboxed macOS keeps the older
|
||||
// behavior of making quad-100 the default resolver, as iOS still does.
|
||||
// See tailscale/corp#45534.
|
||||
// ScopeQuad100OnMacOS lets sandboxed macOS scope quad-100 for simple DNS
|
||||
// configs, so public queries can use the OS resolver (including DoH).
|
||||
// Custom split resolvers or unrouted forward/PTR records still require
|
||||
// quad-100 as primary. Off by default; has no effect on other platforms.
|
||||
// See tailscale/corp#45534 and tailscale/corp#48693.
|
||||
ScopeQuad100OnMacOS atomic.Bool
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,35 @@ func (c Config) hasSplitDNSRouteForHost(host dnsname.FQDN) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// hasHostsWithoutReverseRoutes reports whether any PTR record synthesized by
|
||||
// quad-100 from Hosts is outside the configured routes. Apple scoping must
|
||||
// preserve these answers as well as forward records.
|
||||
func (c Config) hasHostsWithoutReverseRoutes() bool {
|
||||
for _, ips := range c.Hosts {
|
||||
for _, ip := range ips {
|
||||
if !ip.IsValid() || !c.hasSplitDNSRouteForHost(reverseDNSName(ip)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// reverseDNSName returns the PTR query name for a valid IP address.
|
||||
func reverseDNSName(ip netip.Addr) dnsname.FQDN {
|
||||
if ip.Is4() {
|
||||
b := ip.As4()
|
||||
return dnsname.FQDN(fmt.Sprintf("%d.%d.%d.%d.in-addr.arpa.", b[3], b[2], b[1], b[0]))
|
||||
}
|
||||
b := ip.As16()
|
||||
const hex = "0123456789abcdef"
|
||||
name := make([]byte, 0, 64+len("ip6.arpa."))
|
||||
for i := len(b) - 1; i >= 0; i-- {
|
||||
name = append(name, hex[b[i]&0xf], '.', hex[b[i]>>4], '.')
|
||||
}
|
||||
return dnsname.FQDN(append(name, "ip6.arpa."...))
|
||||
}
|
||||
|
||||
func (c Config) hasDefaultResolvers() bool {
|
||||
return len(c.DefaultResolvers) > 0
|
||||
}
|
||||
|
||||
+47
-49
@@ -352,7 +352,17 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
||||
// iteration; sort it so equal configs compare and log equal.
|
||||
slices.Sort(rcfg.LocalDomains)
|
||||
|
||||
// Similarly, the OS always gets search paths.
|
||||
isWindows := m.goos == "windows"
|
||||
isIOS := m.goos == "ios"
|
||||
isSandboxedMac := m.goos == "darwin" && isSandboxedMacOS()
|
||||
supportsSplitDNS := m.os.SupportsSplitDNS()
|
||||
isSandboxedApple := isIOS || isSandboxedMac
|
||||
|
||||
// Preserve configured search domains in control's order (tailnet first).
|
||||
// Do not add split-DNS suffixes: restricted resolvers are match-only.
|
||||
// LAN-provided search domains are appended below, at lowest priority.
|
||||
// The Apple extension only installs this list in primary resolver mode;
|
||||
// scoped mode uses the match domains as its global search list.
|
||||
ocfg.SearchDomains = cfg.SearchDomains
|
||||
if propagateHostsToOS && m.goos == "windows" {
|
||||
ocfg.Hosts = compileHostEntries(cfg)
|
||||
@@ -405,13 +415,6 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
||||
// quad-100 will still have the full split configuration as well,
|
||||
// and so can service WSL requests correctly.
|
||||
//
|
||||
// This bool is used in a couple of places below to implement this
|
||||
// workaround.
|
||||
isWindows := m.goos == "windows"
|
||||
isIOS := m.goos == "ios"
|
||||
isSandboxedMac := m.goos == "darwin" && isSandboxedMacOS()
|
||||
supportsSplitDNS := m.os.SupportsSplitDNS()
|
||||
isSandboxedApple := isIOS || isSandboxedMac
|
||||
// Apple platforms keep split-domain traffic pointed at quad-100 rather than
|
||||
// handing the upstream resolvers to the OS directly, because those resolvers
|
||||
// may only be reachable through the tunnel.
|
||||
@@ -431,38 +434,43 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
||||
rcfg.Routes = routes
|
||||
ocfg.Nameservers = cfg.serviceIPs(m.knobs)
|
||||
|
||||
// usePrimaryResolver forces quad-100 to be installed as the OS's primary
|
||||
// (catch-all) resolver rather than scoped to the match domains. iOS always
|
||||
// does this (it has no way to selectively answer ExtraRecords). Sandboxed
|
||||
// macOS did too until control opts it into scoping via
|
||||
// NodeAttrScopeQuad100OnMacOS, so that a user's DoH system profile isn't
|
||||
// shadowed by quad-100. See tailscale/corp#45534.
|
||||
usePrimaryResolver := isIOS || (isSandboxedMac && !m.scopeQuad100OnMacOS())
|
||||
// Apple tunnels can contribute global search domains only through
|
||||
// matchDomains with matchDomainsNoSearch=false; NEDNSSettings.searchDomains
|
||||
// is stripped by configd. Scope only simple configs (Mode A), otherwise
|
||||
// install quad-100 as primary (Mode B) and keep split suffixes internal.
|
||||
// This prevents custom split suffixes from becoming search domains while
|
||||
// keeping bare tailnet names reachable. See tailscale/corp#48693.
|
||||
//
|
||||
// Both forward records and the PTR records synthesized from Hosts must
|
||||
// be covered. Scoping is opt-out on iOS and opt-in on sandboxed macOS.
|
||||
appleScopeEnabled := (isIOS && !m.disableSplitDNSOptimization()) ||
|
||||
(isSandboxedMac && m.scopeQuad100OnMacOS())
|
||||
scopeApple := appleScopeEnabled && rcfg.RoutesRequireNoCustomResolvers() &&
|
||||
!cfg.requiresPrimaryResolver() && !cfg.hasHostsWithoutReverseRoutes()
|
||||
|
||||
if supportsSplitDNS && !usePrimaryResolver && !cfg.requiresPrimaryResolver() {
|
||||
// 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() {
|
||||
ocfg.MatchDomains = cfg.matchDomains()
|
||||
return rcfg, ocfg, nil
|
||||
}
|
||||
|
||||
// Even though iOS devices can do split DNS, they don't provide a way to
|
||||
// selectively answer ExtraRecords, and ignore other DNS traffic. As a
|
||||
// workaround, we read the existing default resolver configuration and use
|
||||
// that as the forwarder for all DNS traffic that quad-100 doesn't handle.
|
||||
//
|
||||
// If the OS can't do native split-DNS, read out the underlying resolver
|
||||
// config and blend it into our config. On iOS, [OSConfigurator.GetBaseConfig]
|
||||
// has a tendency to temporarily fail if called immediately following an
|
||||
// When quad-100 is primary (or the OS cannot do split DNS), use the
|
||||
// underlying resolver for queries quad-100 cannot answer locally. On iOS,
|
||||
// [OSConfigurator.GetBaseConfig] can temporarily fail immediately after an
|
||||
// interface change. These failures should be retried if/when the OS indicates
|
||||
// that the DNS configuration has changed via [RecompileDNSConfig].
|
||||
base, err := m.os.GetBaseConfig()
|
||||
if err != nil {
|
||||
if (isIOS || isNoopManager(m.os) || (supportsSplitDNS && !isSandboxedMac)) && err == ErrGetBaseConfigNotSupported {
|
||||
// No base config to blend in: noopManager (userspace networking),
|
||||
// some iOS builds, or a split-DNS manager that has none by
|
||||
// construction (e.g. systemd-resolved). Fall back to a scoped
|
||||
// config instead of erroring and leaving the old OS config.
|
||||
// Sandboxed macOS is excluded: it does have a base config
|
||||
// (/etc/resolv.conf), so this error is a real read failure there.
|
||||
canScopeWithoutBase := !isSandboxedApple && (isNoopManager(m.os) || supportsSplitDNS) ||
|
||||
isIOS && supportsSplitDNS && scopeApple
|
||||
if canScopeWithoutBase && err == ErrGetBaseConfigNotSupported {
|
||||
// Some managers have no base config by construction. Apple Mode B
|
||||
// cannot fall back to scoping: it would lose unrouted records or
|
||||
// expose split suffixes as search domains. Nor can it install a
|
||||
// catch-all without forwarding upstreams; report the read error.
|
||||
// Sandboxed macOS has /etc/resolv.conf, so an unsupported read
|
||||
// remains an error there, even for an otherwise simple config.
|
||||
m.health.SetHealthy(OSConfigurationReadWarnable)
|
||||
ocfg.MatchDomains = cfg.matchDomains()
|
||||
return rcfg, ocfg, nil
|
||||
@@ -472,21 +480,10 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
||||
}
|
||||
m.health.SetHealthy(OSConfigurationReadWarnable)
|
||||
|
||||
// On iOS only (for now), check if all route names point to resources inside the tailnet.
|
||||
// If so, we can set those names as MatchDomains to enable a split DNS configuration
|
||||
// which will help preserve battery life.
|
||||
// Because on iOS MatchDomains must equal SearchDomains, we cannot do this when
|
||||
// we have any Routes outside the tailnet. Otherwise when app connectors are enabled,
|
||||
// a query for 'work-laptop' might lead to search domain expansion, resolving
|
||||
// as 'work-laptop.aws.com' for example.
|
||||
if isIOS && rcfg.RoutesRequireNoCustomResolvers() {
|
||||
if !m.disableSplitDNSOptimization() {
|
||||
for r := range rcfg.Routes {
|
||||
ocfg.MatchDomains = append(ocfg.MatchDomains, r)
|
||||
}
|
||||
} else {
|
||||
m.logf("iOS split DNS is disabled by nodeattr")
|
||||
}
|
||||
if isIOS && supportsSplitDNS && scopeApple {
|
||||
// Include the authoritative MagicDNS roots, not just upstream routes.
|
||||
// Do not union search-only domains: that would capture their queries.
|
||||
ocfg.MatchDomains = cfg.matchDomains()
|
||||
}
|
||||
var defaultRoutes []*dnstype.Resolver
|
||||
if len(base.Nameservers) == 0 && !isSandboxedApple {
|
||||
@@ -521,9 +518,10 @@ func (m *Manager) disableSplitDNSOptimization() bool {
|
||||
var scopeQuad100OnMacOSEnv = envknob.RegisterOptBool("TS_DEBUG_SCOPE_QUAD100_MACOS")
|
||||
|
||||
// scopeQuad100OnMacOS reports whether sandboxed macOS should scope quad-100 to
|
||||
// its match domains rather than installing it as the OS's primary resolver.
|
||||
// Off (false) unless control sets NodeAttrScopeQuad100OnMacOS, or the
|
||||
// TS_DEBUG_SCOPE_QUAD100_MACOS env override is set. See tailscale/corp#45534.
|
||||
// its match domains for eligible simple configs, rather than installing it
|
||||
// as the OS's primary resolver. Off (false) unless control sets
|
||||
// NodeAttrScopeQuad100OnMacOS, or TS_DEBUG_SCOPE_QUAD100_MACOS is set.
|
||||
// See tailscale/corp#45534.
|
||||
func (m *Manager) scopeQuad100OnMacOS() bool {
|
||||
if v, ok := scopeQuad100OnMacOSEnv().Get(); ok {
|
||||
return v
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package dns
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/health"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/util/dnsname"
|
||||
"tailscale.com/util/eventbus/eventbustest"
|
||||
)
|
||||
|
||||
// TestManagerAppleDNSModes exercises the two modes in corp#48693. Apple uses
|
||||
// match domains as the global search list (except reverse zones), so custom
|
||||
// split suffixes must stay internal to quad-100 in Mode B. Search-only suffixes
|
||||
// deliberately do not become routing domains in Mode A.
|
||||
func TestManagerAppleDNSModes(t *testing.T) {
|
||||
for _, goos := range []string{"ios", "darwin"} {
|
||||
t.Run(goos, func(t *testing.T) {
|
||||
tstest.Replace(t, &isSandboxedMacOS, func() bool { return goos == "darwin" })
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
edit func(*Config)
|
||||
primary bool
|
||||
disableScope bool
|
||||
macEnv string
|
||||
noBase bool
|
||||
}{
|
||||
{name: "mode-a-magicdns-forward-reverse-and-search-only"},
|
||||
{
|
||||
name: "mode-a-conventional-ts-net-upstream",
|
||||
edit: func(c *Config) { c.Routes["ts.net."] = mustRes("199.247.155.52") },
|
||||
},
|
||||
{
|
||||
name: "mode-b-custom-split-resolver",
|
||||
edit: func(c *Config) { c.Routes["split.example."] = mustRes("192.0.2.53") },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-uncovered-forward-host",
|
||||
edit: func(c *Config) { c.Hosts["extra.example."] = mustIPs("100.64.0.9") },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-magicdns-hosts-unrouted",
|
||||
edit: func(c *Config) { c.MagicDNSHostsUnrouted = true },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-default-resolvers",
|
||||
edit: func(c *Config) { c.DefaultResolvers = mustRes("192.0.2.54") },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-uncovered-ipv4-ptr",
|
||||
edit: func(c *Config) { c.Hosts["printer.corp.ts.net."] = mustIPs("192.168.1.10") },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-uncovered-ipv6-ptr",
|
||||
edit: func(c *Config) { c.Hosts["printer.corp.ts.net."] = mustIPs("2001:db8::1") },
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-b-mixed-covered-and-uncovered-ptrs",
|
||||
edit: func(c *Config) {
|
||||
c.Hosts["printer.corp.ts.net."] = mustIPs("100.64.0.9", "2001:db8::1")
|
||||
},
|
||||
primary: true,
|
||||
},
|
||||
{
|
||||
name: "mode-a-covered-ipv4-ptr",
|
||||
edit: func(c *Config) {
|
||||
c.Hosts["printer.corp.ts.net."] = mustIPs("192.168.1.10")
|
||||
c.Routes["1.168.192.in-addr.arpa."] = nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mode-a-covered-ipv6-ptr",
|
||||
edit: func(c *Config) {
|
||||
c.Hosts["printer.corp.ts.net."] = mustIPs("2001:db8::1")
|
||||
c.Routes["8.b.d.0.1.0.0.2.ip6.arpa."] = nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mode-a-exact-ptr-route",
|
||||
edit: func(c *Config) {
|
||||
c.Hosts["printer.corp.ts.net."] = mustIPs("192.168.1.10")
|
||||
c.Routes["10.1.168.192.in-addr.arpa."] = nil
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mode-b-control-disables-scoping",
|
||||
disableScope: true,
|
||||
primary: true,
|
||||
},
|
||||
{name: "mac-env-opt-out", macEnv: "false", primary: goos == "darwin"},
|
||||
{name: "mac-env-opt-in", macEnv: "true", disableScope: true, primary: goos == "ios"},
|
||||
{
|
||||
name: "mac-env-cannot-bypass-mode-b",
|
||||
macEnv: "true",
|
||||
edit: func(c *Config) { c.Routes["split.example."] = mustRes("192.0.2.53") },
|
||||
primary: true,
|
||||
},
|
||||
{name: "no-base-mode-a", noBase: true},
|
||||
{
|
||||
name: "no-base-custom-split-resolver",
|
||||
edit: func(c *Config) { c.Routes["split.example."] = mustRes("192.0.2.53") },
|
||||
primary: true,
|
||||
noBase: true,
|
||||
},
|
||||
{
|
||||
name: "no-base-unrouted-host",
|
||||
edit: func(c *Config) { c.MagicDNSHostsUnrouted = true },
|
||||
primary: true,
|
||||
noBase: true,
|
||||
},
|
||||
{
|
||||
name: "no-base-uncovered-forward-host",
|
||||
edit: func(c *Config) { c.Hosts["extra.example."] = mustIPs("100.64.0.9") },
|
||||
primary: true,
|
||||
noBase: true,
|
||||
},
|
||||
{
|
||||
name: "no-base-uncovered-ptr",
|
||||
edit: func(c *Config) { c.Hosts["printer.corp.ts.net."] = mustIPs("192.168.1.10") },
|
||||
primary: true,
|
||||
noBase: true,
|
||||
},
|
||||
{name: "no-base-scoping-disabled", primary: true, disableScope: true, noBase: true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
envknob.SetenvForTest(t, "TS_DEBUG_SCOPE_QUAD100_MACOS", tt.macEnv)
|
||||
c := Config{
|
||||
Routes: upstreams("corp.ts.net", "", "0.e.1.a.c.5.1.1.a.7.d.f.ip6.arpa", ""),
|
||||
Hosts: hosts("laptop.corp.ts.net", "100.64.0.1", "fd7a:115c:a1e0::1"),
|
||||
SearchDomains: fqdns("corp.ts.net", "office.example"),
|
||||
}
|
||||
// Match the actual IPv4 MagicDNS roots emitted by ipnlocal.
|
||||
for i := 64; i <= 127; i++ {
|
||||
c.Routes[dnsname.FQDN(fmt.Sprintf("%d.100.in-addr.arpa.", i))] = nil
|
||||
}
|
||||
if tt.edit != nil {
|
||||
tt.edit(&c)
|
||||
}
|
||||
knobs := scopeQuad100Knobs()
|
||||
knobs.ScopeQuad100OnMacOS.Store(!tt.disableScope)
|
||||
knobs.DisableSplitDNSWhenNoCustomResolvers.Store(tt.disableScope)
|
||||
f := &fakeOSConfigurator{
|
||||
SplitDNS: true,
|
||||
BaseConfig: OSConfig{
|
||||
Nameservers: mustIPs("192.168.1.1"),
|
||||
SearchDomains: fqdns("lan.example"),
|
||||
},
|
||||
}
|
||||
if tt.noBase {
|
||||
err := ErrGetBaseConfigNotSupported
|
||||
f.GetBaseConfigErr = &err
|
||||
}
|
||||
m := &Manager{
|
||||
goos: goos,
|
||||
os: f,
|
||||
knobs: knobs,
|
||||
health: health.NewTracker(eventbustest.NewBus(t)),
|
||||
logf: t.Logf,
|
||||
}
|
||||
rcfg, ocfg, err := m.compileConfig(c)
|
||||
if tt.noBase && tt.primary {
|
||||
// A catch-all without a forwarding resolver would break public
|
||||
// DNS. Fail rather than bypassing Mode B or control opt-outs.
|
||||
if !errors.Is(err, ErrGetBaseConfigNotSupported) {
|
||||
t.Fatalf("compileConfig error = %v; want ErrGetBaseConfigNotSupported", err)
|
||||
}
|
||||
if len(ocfg.Nameservers) != 0 || len(ocfg.MatchDomains) != 0 {
|
||||
t.Fatalf("failed compile returned OS config: %+v", ocfg)
|
||||
}
|
||||
if !m.health.IsUnhealthy(OSConfigurationReadWarnable) {
|
||||
t.Error("failed base config read did not set health warning")
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m.health.IsUnhealthy(OSConfigurationReadWarnable) {
|
||||
t.Error("successful compile left a base config read warning")
|
||||
}
|
||||
wantOS := OSConfig{Nameservers: serviceAddr46, SearchDomains: slices.Clone(c.SearchDomains)}
|
||||
if !tt.primary {
|
||||
wantOS.MatchDomains = c.matchDomains()
|
||||
}
|
||||
wantDefault := c.DefaultResolvers
|
||||
if len(wantDefault) == 0 && !tt.noBase && (goos == "ios" || tt.primary) {
|
||||
wantDefault = mustRes("192.168.1.1")
|
||||
wantOS.SearchDomains = append(wantOS.SearchDomains, "lan.example.")
|
||||
}
|
||||
if diff := cmp.Diff(wantOS, ocfg, cmpopts.EquateEmpty(), cmpopts.EquateComparable(netip.Addr{})); diff != "" {
|
||||
t.Errorf("OS config (-want +got):\n%s", diff)
|
||||
}
|
||||
if diff := cmp.Diff(wantDefault, rcfg.Routes["."], cmpopts.EquateEmpty()); diff != "" {
|
||||
t.Errorf("default forwarding route (-want +got):\n%s", diff)
|
||||
}
|
||||
for suffix, upstream := range c.Routes {
|
||||
if len(upstream) == 0 {
|
||||
if !slices.Contains(rcfg.LocalDomains, suffix) {
|
||||
t.Errorf("authoritative suffix %q missing from resolver", suffix)
|
||||
}
|
||||
} else if diff := cmp.Diff(upstream, rcfg.Routes[suffix]); diff != "" {
|
||||
t.Errorf("route %q lost (-want +got):\n%s", suffix, diff)
|
||||
}
|
||||
}
|
||||
if diff := cmp.Diff(c.Hosts, rcfg.Hosts, cmpopts.EquateComparable(netip.Addr{})); diff != "" {
|
||||
t.Errorf("host records lost (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReverseDNSName(t *testing.T) {
|
||||
for _, tt := range []struct{ ip, want string }{
|
||||
{"192.168.1.10", "10.1.168.192.in-addr.arpa."},
|
||||
{"100.64.0.9", "9.0.64.100.in-addr.arpa."},
|
||||
{"2001:db8::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."},
|
||||
{"fd7a:115c:a1e0::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.1.a.c.5.1.1.a.7.d.f.ip6.arpa."},
|
||||
} {
|
||||
t.Run(tt.ip, func(t *testing.T) {
|
||||
if got := reverseDNSName(netip.MustParseAddr(tt.ip)); got != dnsname.FQDN(tt.want) {
|
||||
t.Errorf("reverseDNSName = %q; want %q", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+24
-29
@@ -494,11 +494,8 @@ func TestManager(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
// Sandboxed macOS: split traffic stays pointed at quad-100 (upstreams
|
||||
// may only be reachable via the tunnel). With NodeAttrScopeQuad100OnMacOS
|
||||
// set, quad-100 is scoped to the match domains so public names fall
|
||||
// through to the OS resolver (e.g. a DoH profile) rather than being
|
||||
// shadowed. See the -no-knob variant for the default. tailscale/corp#45534.
|
||||
// A custom split resolver requires Mode B even with macOS scoping
|
||||
// enabled: otherwise the split suffix becomes a global search suffix.
|
||||
name: "routes-split-sandboxed-darwin",
|
||||
in: Config{
|
||||
Routes: upstreams("corp.com", "2.2.2.2"),
|
||||
@@ -512,11 +509,11 @@ func TestManager(t *testing.T) {
|
||||
},
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
SearchDomains: fqdns("tailscale.com", "universe.tf"),
|
||||
MatchDomains: fqdns("corp.com"),
|
||||
SearchDomains: fqdns("tailscale.com", "universe.tf", "coffee.shop"),
|
||||
},
|
||||
rs: resolver.Config{
|
||||
Routes: upstreams(
|
||||
".", "8.8.8.8",
|
||||
"corp.com.", "2.2.2.2"),
|
||||
},
|
||||
goos: "darwin",
|
||||
@@ -549,13 +546,12 @@ func TestManager(t *testing.T) {
|
||||
sandboxedMacOS: true,
|
||||
},
|
||||
{
|
||||
// An ExtraRecord paired with an authoritative (resolver-less) route
|
||||
// is scoped like any other split domain, on every platform. The
|
||||
// darwin and linux variants must agree.
|
||||
// An ExtraRecord can remain scoped when both its forward and
|
||||
// synthesized PTR records have authoritative routes.
|
||||
name: "extra-record-routed-scopes-quad100",
|
||||
in: Config{
|
||||
Hosts: hosts("extra.example.com.", "100.64.0.9"),
|
||||
Routes: upstreams("corp.ts.net.", "", "extra.example.com.", ""),
|
||||
Routes: upstreams("corp.ts.net.", "", "extra.example.com.", "", "64.100.in-addr.arpa.", ""),
|
||||
SearchDomains: fqdns("corp.ts.net"),
|
||||
},
|
||||
split: true,
|
||||
@@ -566,11 +562,11 @@ func TestManager(t *testing.T) {
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
SearchDomains: fqdns("corp.ts.net"),
|
||||
MatchDomains: fqdns("corp.ts.net", "extra.example.com"),
|
||||
MatchDomains: fqdns("64.100.in-addr.arpa", "corp.ts.net", "extra.example.com"),
|
||||
},
|
||||
rs: resolver.Config{
|
||||
Hosts: hosts("extra.example.com.", "100.64.0.9"),
|
||||
LocalDomains: fqdns("corp.ts.net.", "extra.example.com."),
|
||||
LocalDomains: fqdns("64.100.in-addr.arpa.", "corp.ts.net.", "extra.example.com."),
|
||||
},
|
||||
goos: "darwin",
|
||||
sandboxedMacOS: true,
|
||||
@@ -720,10 +716,10 @@ func TestManager(t *testing.T) {
|
||||
goos: "darwin",
|
||||
},
|
||||
{
|
||||
// The `routes-multi-split-linux` test case above on iOS should NOT result in a split
|
||||
// DNS configuration.
|
||||
// Check that MatchDomains is empty. Due to Apple limitations, we cannot set MatchDomains
|
||||
// without those domains also being SearchDomains.
|
||||
// The `routes-multi-split-linux` test case above on iOS: quad-100 stays
|
||||
// the primary resolver (the scoping optimization is skipped when split
|
||||
// routes carry custom resolvers), so MatchDomains is empty. Split-DNS
|
||||
// suffixes are match-only and never enter the search list.
|
||||
name: "routes-multi-does-not-split-on-ios",
|
||||
in: Config{
|
||||
Routes: upstreams(
|
||||
@@ -818,10 +814,9 @@ func TestManager(t *testing.T) {
|
||||
goos: "darwin",
|
||||
},
|
||||
{
|
||||
// The `magic-split` test case above on iOS should NOT result in a split DNS configuration.
|
||||
// Check that MatchDomains is empty. Due to Apple limitations, we cannot set MatchDomains
|
||||
// without those domains also being SearchDomains.
|
||||
name: "magic-split-does-not-split-on-ios",
|
||||
// The forward records are covered, but their public-IP PTR names
|
||||
// are not. Keep quad-100 primary so it can answer those PTR queries.
|
||||
name: "magic-split-uncovered-ptr-keeps-primary-on-ios",
|
||||
in: Config{
|
||||
Hosts: hosts(
|
||||
"dave.ts.com.", "1.2.3.4",
|
||||
@@ -829,7 +824,7 @@ func TestManager(t *testing.T) {
|
||||
Routes: upstreams("ts.com", ""),
|
||||
SearchDomains: fqdns("tailscale.com", "universe.tf"),
|
||||
},
|
||||
split: false,
|
||||
split: true,
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
SearchDomains: fqdns("tailscale.com", "universe.tf"),
|
||||
@@ -925,10 +920,10 @@ func TestManager(t *testing.T) {
|
||||
goos: "darwin",
|
||||
},
|
||||
{
|
||||
// The `routes-magic-split-linux` test case above on Darwin should NOT result in a
|
||||
// split DNS configuration.
|
||||
// Check that MatchDomains is empty. Due to Apple limitations, we cannot set MatchDomains
|
||||
// without those domains also being SearchDomains.
|
||||
// The `routes-magic-split-linux` test case above on iOS: quad-100 stays
|
||||
// the primary resolver (the scoping optimization is skipped when split
|
||||
// routes carry custom resolvers), so MatchDomains is empty. Split-DNS
|
||||
// suffixes are match-only and never enter the search list.
|
||||
name: "routes-magic-does-not-split-on-ios",
|
||||
in: Config{
|
||||
Routes: upstreams(
|
||||
@@ -1023,8 +1018,8 @@ func TestManager(t *testing.T) {
|
||||
split: true,
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
SearchDomains: fqdns("optimistic-display.ts.net"),
|
||||
MatchDomains: fqdns("ts.net"),
|
||||
SearchDomains: fqdns("optimistic-display.ts.net."),
|
||||
MatchDomains: fqdns("optimistic-display.ts.net.", "ts.net."),
|
||||
},
|
||||
rs: resolver.Config{
|
||||
Routes: upstreams(
|
||||
@@ -1048,7 +1043,7 @@ func TestManager(t *testing.T) {
|
||||
split: true,
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
SearchDomains: fqdns("optimistic-display.ts.net"),
|
||||
SearchDomains: fqdns("optimistic-display.ts.net."),
|
||||
},
|
||||
rs: resolver.Config{
|
||||
Routes: upstreams(
|
||||
|
||||
@@ -226,13 +226,12 @@ const (
|
||||
// if needed.
|
||||
DisableSplitDNSWhenNoCustomResolvers Cap = "disable-split-dns-when-no-custom-resolvers"
|
||||
|
||||
// ScopeQuad100OnMacOS makes sandboxed macOS clients scope quad-100
|
||||
// to its match domains instead of installing it as the OS's primary
|
||||
// (catch-all) resolver, so that public names fall through to the OS
|
||||
// resolver -- e.g. a user's DoH system profile -- rather than being
|
||||
// shadowed. It has no effect on any other platform. Without this attribute,
|
||||
// sandboxed macOS keeps the older behavior of making quad-100 the default
|
||||
// resolver, as iOS still does. See tailscale/corp#45534.
|
||||
// ScopeQuad100OnMacOS lets sandboxed macOS scope quad-100 for simple DNS
|
||||
// configs, so public queries can use the OS resolver (including DoH).
|
||||
// Custom split resolvers or unrouted forward/PTR records still require
|
||||
// quad-100 as primary. Without this attribute, quad-100 stays primary.
|
||||
// Has no effect on other platforms. See tailscale/corp#45534 and
|
||||
// tailscale/corp#48693.
|
||||
ScopeQuad100OnMacOS Cap = "scope-quad100-macos"
|
||||
|
||||
// DisableLocalDNSOverrideViaNRPT indicates that the node's DNS manager should not
|
||||
|
||||
Reference in new issue
Block a user