-
Notifications
You must be signed in to change notification settings - Fork 18k
net: LookupIP returns only ipv4 on windows but both ipv4 and ipv6 on linux(for a network that only supports IPv4) #71340
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
Comments
my issue is similiar to #2315. |
probably the reason no one has noticed this until now is that in an IPv4 network, there is often no need for an IPv6, but "net.LookupIP" should be independent of whether network supports IPv6 or not, just like it is in Linux. |
is this using the go or cgo resolvers (run with |
I checked, but in any case only ipv4 is returned. in same network and in Linux both ipv4 and ipv6 is returned. |
The pure go DNS resolver makes both AAAA and A queries, if that didn't return any ipv6 addresses, that points to a problem with the resolver you have on your windows setup, rather than a bug in Go. |
I check everything, The problem is definitely related to go. i run "nslookup cloudflare.com" in cmd and both IPv4 and IPv6 is returned. Please check it yourself before close the issue. |
os: windows, network: only ipv4 command: output: ////////////// command: output: //////////// output: Non-authoritative answer: //////////// import ("fmt" func main () {
} |
Also try with GODEBUG=netdns=go+2 |
yes, with GODEBUG=netdns=go+2 both ipv4 and ipv6 is returned. but without this, go should return both ipv4 and ipv6. for test if you are using windows,right click on your network in Control Panel\Network and Internet\Network Connections and uncheck ipv6. please reopen this issue thx. |
When using cgo, C GetAddrInfo is used with AF_UNSPEC. |
When using the native cgo resolver, the Go package will return the values that the C library returns. This isn't something that we can change in Go. See the discussion at https://pkg.go.dev/net#hdr-Name_Resolution. |
I got my answer, this is C problem, I should use go resolver, thank you all. |
Go version
go1.24rc2 both windows-amd64 and linux-arm64(android)
What did you do?
What did you see happen?
output: [104.16.132.229 104.16.133.229]
in windows if my network only support IPv4, "net.LookupIP" incorrectly only return IPv4 !
but in Linux it doesn't matter your network support IPv6 or not and correctly always return both IPv4 and IPv6 even your network doesn't support IPv6.
probably the reason no one has noticed this until now is that in an IPv4 network, there is often no need for an IPv6, but "net.LookupIP" should be independent of whether network supports IPv6 or not, just like it is in Linux.
What did you expect to see?
expected output: [2606:4700::6810:84e5 2606:4700::6810:85e5 104.16.132.229 104.16.133.229]
The text was updated successfully, but these errors were encountered: