Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tun_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func (t *NativeTun) configure() error {
}
}
}
} else {
// If no IPv4 address is set, remove any existing IPv4 DNS servers
err := luid.SetDNS(winipcfg.AddressFamily(windows.AF_INET), nil, nil)
if err != nil {
return E.Cause(err, "remove ipv4 dns")
}
}
if len(t.options.Inet6Address) > 0 {
err := luid.SetIPAddressesForFamily(winipcfg.AddressFamily(windows.AF_INET6), t.options.Inet6Address)
Expand All @@ -102,6 +108,12 @@ func (t *NativeTun) configure() error {
}
}
}
} else {
// If no IPv6 address is set, remove any existing IPv6 DNS servers
err := luid.SetDNS(winipcfg.AddressFamily(windows.AF_INET6), nil, nil)
if err != nil {
return E.Cause(err, "remove ipv6 dns")
}
}
if len(t.options.Inet4Address) > 0 || len(t.options.Inet6Address) > 0 {
_ = luid.DisableDNSRegistration()
Expand Down