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

net: net.ListenUDP() only binds to IPv4 when 127.0.0.1 is not present #61310

Open
asdfjkluiop opened this issue Jul 12, 2023 · 1 comment
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@asdfjkluiop
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.20.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.20"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.20/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/user/sslip.io/src/sslip.io-dns-server/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3799498623=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When running on a system with no IPv4 loopback address(127.0.0.1) present net.ListenUDP("udp", &net.UDPAddr{Port: 1234}) binds to 0.0.0.0:1234 instead of [::]:1234. On IPv6 only systems with no IPv4 loopback this is undesirable.

What did you expect to see?

net.ListenUDP("udp", &net.UDPAddr{Port: 1234}) should bind to [::]:1234 when no IPv4 loopback is present on IPv6 only systems. Manually specifying the IPv6 wildcard address :: in the net.UDPAddr struct works as expected. This is only present when no bind address is given.

What did you see instead?

net.ListenUDP("udp", &net.UDPAddr{Port: 1234}) binds to 0.0.0.0:1234 even though only IPv6 is present.

@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 12, 2023
@cherrymui cherrymui added this to the Backlog milestone Jul 12, 2023
@cherrymui
Copy link
Member

cc @ianlancetaylor @neild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants