mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
net/dns: log why resolved does not look like it's on use [Linux]
Updates #3742 Updates #3531 Change-Id: I9fc7fa0f4bcab1cf8001ba92408c660a5b25f105 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
ff3442d92d
commit
6feb8f4c51
@ -95,6 +95,7 @@ func dnsMode(logf logger.Logf, env newOSConfigEnv) (ret string, err error) {
|
||||
// try to program resolved in that case.
|
||||
// https://github.com/tailscale/tailscale/issues/2136
|
||||
if err := resolvedIsActuallyResolver(bs); err != nil {
|
||||
logf("dns: resolvedIsActuallyResolver error: %v", err)
|
||||
dbg("resolved", "not-in-use")
|
||||
return "direct", nil
|
||||
}
|
||||
@ -184,6 +185,7 @@ func dnsMode(logf logger.Logf, env newOSConfigEnv) (ret string, err error) {
|
||||
// Sometimes, NetworkManager owns the configuration but points
|
||||
// it at systemd-resolved.
|
||||
if err := resolvedIsActuallyResolver(bs); err != nil {
|
||||
logf("dns: resolvedIsActuallyResolver error: %v", err)
|
||||
dbg("resolved", "not-in-use")
|
||||
// You'd think we would use newNMManager here. However, as
|
||||
// explained in
|
||||
@ -300,7 +302,7 @@ func resolvedIsActuallyResolver(bs []byte) error {
|
||||
}
|
||||
for _, ns := range cfg.Nameservers {
|
||||
if ns != netaddr.IPv4(127, 0, 0, 53) {
|
||||
return errors.New("resolv.conf doesn't point to systemd-resolved")
|
||||
return fmt.Errorf("resolv.conf doesn't point to systemd-resolved; points to %v", cfg.Nameservers)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -34,8 +34,9 @@ func TestLinuxDNSMode(t *testing.T) {
|
||||
resolvDotConf(
|
||||
"# Managed by NetworkManager",
|
||||
"nameserver 10.0.0.1")),
|
||||
wantLog: "dns: [rc=nm resolved=not-in-use ret=direct]",
|
||||
want: "direct",
|
||||
wantLog: "dns: resolvedIsActuallyResolver error: resolv.conf doesn't point to systemd-resolved; points to [10.0.0.1]\n" +
|
||||
"dns: [rc=nm resolved=not-in-use ret=direct]",
|
||||
want: "direct",
|
||||
},
|
||||
{
|
||||
name: "resolvconf_but_no_resolvconf_binary",
|
||||
@ -123,10 +124,11 @@ func TestLinuxDNSMode(t *testing.T) {
|
||||
// alleged that it was managed by systemd-resolved, but it
|
||||
// was actually a completely static config file pointing
|
||||
// elsewhere.
|
||||
name: "allegedly_resolved_but_not_in_resolv.conf",
|
||||
env: env(resolvDotConf("# Managed by systemd-resolved", "nameserver 10.0.0.1")),
|
||||
wantLog: "dns: [rc=resolved resolved=not-in-use ret=direct]",
|
||||
want: "direct",
|
||||
name: "allegedly_resolved_but_not_in_resolv.conf",
|
||||
env: env(resolvDotConf("# Managed by systemd-resolved", "nameserver 10.0.0.1")),
|
||||
wantLog: "dns: resolvedIsActuallyResolver error: resolv.conf doesn't point to systemd-resolved; points to [10.0.0.1]\n" +
|
||||
"dns: [rc=resolved resolved=not-in-use ret=direct]",
|
||||
want: "direct",
|
||||
},
|
||||
{
|
||||
// We used to incorrectly decide that resolved wasn't in
|
||||
|
Loading…
Reference in New Issue
Block a user