Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dns if no address was set #38

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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