control/controlknobs,net/dns,tailcfg: add a control knob that disables hosts file updates on Windows

In the absence of a better mechanism, writing unqualified hostnames to the hosts file may be required
for MagicDNS to work on some Windows environments, such as domain-joined machines. It can also
improve MagicDNS performance on non-domain joined devices when we are not the device's primary
DNS resolver.

At the same time, updating the hosts file can be slow and expensive, especially when it already contains
many entries, as was previously reported in #14327. It may also have negative side effects, such as interfering
with the system's DNS resolution policies.

Additionally, to fix #18712, we had to extend hosts file usage to domain-joined machines when we are not
the primary DNS resolver. For the reasons above, this change may introduce risk.

To allow customers to disable hosts file updates remotely without disabling MagicDNS entirely, whether on
domain-joined machines or not, this PR introduces the `disable-hosts-file-updates` node attribute.

Updates #18712
Updates #14327

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2026-02-12 22:38:54 -06:00
committed by Nick Khyl
parent afb065fb68
commit 9741c1e846
3 changed files with 31 additions and 8 deletions
+9 -1
View File
@@ -178,7 +178,8 @@ type CapabilityVersion int
// - 129: 2025-10-04: Fixed sleep/wake deadlock in magicsock when using peer relay (PR #17449)
// - 130: 2025-10-06: client can send key.HardwareAttestationPublic and key.HardwareAttestationKeySignature in MapRequest
// - 131: 2025-11-25: client respects [NodeAttrDefaultAutoUpdate]
const CurrentCapabilityVersion CapabilityVersion = 131
// - 132: 2026-02-13: client respects [NodeAttrDisableHostsFileUpdates]
const CurrentCapabilityVersion CapabilityVersion = 132
// ID is an integer ID for a user, node, or login allocated by the
// control plane.
@@ -2740,6 +2741,13 @@ const (
//
// The value of the key in [NodeCapMap] is a JSON boolean.
NodeAttrDefaultAutoUpdate NodeCapability = "default-auto-update"
// NodeAttrDisableHostsFileUpdates indicates that the node's DNS manager should
// not create hosts file entries when it normally would, such as when we're not
// the primary resolver on Windows or when the host is domain-joined and its
// primary domain takes precedence over MagicDNS. As of 2026-02-12, it is only
// used on Windows.
NodeAttrDisableHostsFileUpdates NodeCapability = "disable-hosts-file-updates"
)
// SetDNSRequest is a request to add a DNS record.