Skip to content

net: defaultNS contains ipv6 address #70843

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

Closed
shyamsundar87 opened this issue Dec 14, 2024 · 8 comments
Closed

net: defaultNS contains ipv6 address #70843

shyamsundar87 opened this issue Dec 14, 2024 · 8 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@shyamsundar87
Copy link

Go version

go version go1.23.0

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/User/.cache/go-build'
GOENV='/home/User/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOOS='linux'

What did you do?

As following file :
https://github.com/golang/go/blob/master/src/net/dnsconfig.go
has :

//go:linkname defaultNS
var defaultNS = []string{"127.0.0.1:53", "[::1]:53"}

It by-default assumes to listen for IPv6 addresses without properly sanitizing if at all IPv6 is enabled through-out in the system.
This causes lots of bottlenecks in wide varieties of other programs that depends on Golang's infrastructure.

What did you see happen?

It by-default assumes to listen for IPv6 addresses without properly sanitizing if at all IPv6 is enabled through-out in the system.
This causes lots of bottlenecks in wide varieties of other programs that depends on Golang's infrastructure.

What did you expect to see?

Better design would be to check if ipv6 is enabled system-wide and then really use

var defaultNS = []string{"127.0.0.1:53", "[::1]:53"}

if not fallback to

var defaultNS = []string{"127.0.0.1:53"}
@shyamsundar87 shyamsundar87 changed the title By default NameServers listens for IPv6 addresses [Even when IPv6 is disabled system-wide] By default NameServers listens for IPv6 addresses [Even when IPv6 is disabled] Dec 14, 2024
@seankhliao seankhliao changed the title By default NameServers listens for IPv6 addresses [Even when IPv6 is disabled] net: defaultNS contains ipv6 address Dec 14, 2024
@seankhliao
Copy link
Member

please show a real problem of probing for a dns server on localhost over ipv6

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 14, 2024
@gabyhelp
Copy link

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@mateusz834
Copy link
Member

Also please note that this is just a fallback, in most case it is not going to be used, it is overwritten by /etc/resolv.conf nameservers.

@shyamsundar87
Copy link
Author

shyamsundar87 commented Dec 14, 2024

please show a real problem of probing for a dns server on localhost over ipv6

Following error appears when some CI-CD builds fails [when docker pulls fail because of this]:

[::1]:53: dial udp [::1]:53: socket: address family not supported by protocol

These uses golang under the hood
First of all why might you need such errors?
Whats the purpose of listening for IPv6 if :

ip -6 addr   #shows nothing

@mateusz834
Copy link
Member

@shyamsundar87 can you try with GODEBUG=netdns=cgo+2 and report whether it helps? Looking at the glibc source, it seems like it defaults to 127.0.0.1.

@shyamsundar87
Copy link
Author

shyamsundar87 commented Dec 14, 2024

@shyamsundar87 can you try with GODEBUG=netdns=cgo+2 and report whether it helps? Looking at the glibc source, it seems like it defaults to 127.0.0.1.

I saw following code somewhere :

$ GODEBUG=netdns=cgo+2 go run main.go
go package net: confVal.netCgo = true  netGo = false
go package net: using cgo DNS resolver

Im very new to golang.
Why would you want me to use golang's DNS resolver when people mostly keep using their own resolvers system-wide?
What might the problem be to sanitize for IPv6 check whether its linux/mac/windows accordingly, and shape your code to listen for it?
By this fix [suggestion], you're indirectly forcing the user to use IPv6 even if they dont want to.

Also please note that this is just a fallback, in most case it is not going to be used, it is overwritten by /etc/resolv.conf nameservers.

Some users could've unlinked the file when they're using some other resolvers.

@seankhliao
Copy link
Member

it sounds to me that this isn't a real issue. as mentioned above, this is a fallback that we try when other resolvers aren't configured (and these defaults won't work in docker anyway because there isn't a local dns client). if you've broken dns resolution in the environment, you have bigger issues.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2024
@shyamsundar87
Copy link
Author

shyamsundar87 commented Dec 14, 2024

it sounds to me that this isn't a real issue. as mentioned above, this is a fallback that we try when other resolvers aren't configured (and these defaults won't work in docker anyway because there isn't a local dns client). if you've broken dns resolution in the environment, you have bigger issues.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

I dont really see this fixing the root stuff. First of all this really takes away the user's freedom to choosing their own IP stack for whatever TCP/UDP they use for networking.
I see this as simply enabling IPv6 even if anyone doesnt need it.
First of all if at all I've broke DNS in env, it might've been impossible for me to comment here now. [provided if Im unable to find nearest Github's nameservers manually]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants