diff --git a/net/dns/manager.go b/net/dns/manager.go index 8daa13cbc..0010905a5 100644 --- a/net/dns/manager.go +++ b/net/dns/manager.go @@ -367,12 +367,14 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig // workaround. isWindows := m.goos == "windows" isApple := (m.goos == "darwin" || m.goos == "ios") - if len(cfg.singleResolverSet()) > 0 && m.os.SupportsSplitDNS() && !isWindows && !isApple { - // Split DNS configuration requested, where all split domains - // go to the same resolvers. We can let the OS do it. - ocfg.Nameservers = toIPsOnly(cfg.singleResolverSet()) - ocfg.MatchDomains = cfg.matchDomains() - return rcfg, ocfg, nil + if m.os.SupportsSplitDNS() && !isWindows && !isApple { + if srs := toIPsOnly(cfg.singleResolverSet()); len(srs) > 0 { + // Split DNS configuration requested, where all split domains + // go to the same resolvers. We can let the OS do it. + ocfg.Nameservers = srs + ocfg.MatchDomains = cfg.matchDomains() + return rcfg, ocfg, nil + } } // Split DNS configuration with either multiple upstream routes, diff --git a/net/dns/manager_test.go b/net/dns/manager_test.go index 8a67aca5c..8797fb68f 100644 --- a/net/dns/manager_test.go +++ b/net/dns/manager_test.go @@ -957,6 +957,23 @@ func TestManager(t *testing.T) { }, goos: "windows", }, + { + // Regression test for #19834 + name: "single-doh-splitdns-no-magicdns", + in: Config{ + Routes: upstreams( + "example.com", "http://100.101.102.103:1234/dns-query"), + }, + split: true, + os: OSConfig{ + Nameservers: serviceAddr46, + MatchDomains: fqdns("example.com"), + }, + rs: resolver.Config{ + Routes: upstreams("example.com.", "http://100.101.102.103:1234/dns-query"), + }, + goos: "linux", + }, } trIP := cmp.Transformer("ipStr", func(ip netip.Addr) string { return ip.String() })