net/dns: use an additional registry setting to disable dynamic DNS updates for our interface on Windows

Fixes #9775

Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
Aaron Klotz 2023-12-01 14:57:29 -07:00
parent 49fd0a62c9
commit 64a26b221b

View File

@ -399,11 +399,24 @@ func (m *windowsManager) Close() error {
// Windows DHCP client from sending dynamic DNS updates for our interface to
// AD domain controllers.
func (m *windowsManager) disableDynamicUpdates() error {
if err := m.setSingleDWORD(winutil.IPv4TCPIPInterfacePrefix, "DisableDynamicUpdate", 1); err != nil {
return err
prefixen := []winutil.RegistryPathPrefix{
winutil.IPv4TCPIPInterfacePrefix,
winutil.IPv6TCPIPInterfacePrefix,
}
if err := m.setSingleDWORD(winutil.IPv6TCPIPInterfacePrefix, "DisableDynamicUpdate", 1); err != nil {
return err
for _, prefix := range prefixen {
k, err := m.openInterfaceKey(prefix)
if err != nil {
return err
}
defer k.Close()
if err := k.SetDWordValue("DisableDynamicUpdate", 1); err != nil {
return err
}
if err := k.SetDWordValue("MaxNumberOfAddressesToRegister", 0); err != nil {
return err
}
}
return nil
}