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: Dialer.LocalAddr selecting wrong network-interface to send request via. #57538

Closed
CodeMonkeyKevin opened this issue Jan 1, 2023 · 1 comment

Comments

@CodeMonkeyKevin
Copy link

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

$ go version
go version go1.19.4 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="/snap/go/10008"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/10008/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/app/go/src/blaster/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2212035460=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I have wwan0 with src ip 100.99.192.214:

$ ip route show
default via 192.168.1.1 dev eno1 proto dhcp metric 100
default via 100.99.192.213 dev wwan0 proto static metric 700
100.99.192.212/30 dev wwan0 proto kernel scope link src 100.99.192.214 metric 700
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.211 metric 100

When specifying this source ip as the LocalAddr in net.Dailer as this https://go.dev/play/p/vRKTPQMnyHu still results in the request being made to eno1 interface and not wwan0 interface.

What did you expect to see?

Using TCP dump I should see wwan0 for the request as such (via curl interface targeting curl -v --interface wwan0 https://api.ipify.org)
05:03:00.131301 wwan0 Out IP 100.99.192.214.40804 > 173.231.16.76.443: Flags [S], seq 2925401696, win 65236, options [mss 1388,sackOK,TS val 251821070 ecr 0,nop,wscale 7], length 0

What did you see instead?

I see the request is routed to eno1 interface which src 100.99.192.214 is not associated with (see ip route show above:
05:01:38.297518 eno1 Out IP 100.99.192.214.60759 > 173.231.16.76.443: Flags [S], seq 1998656637, win 64240, options [mss 1460,sackOK,TS val 251739236 ecr 0,nop,wscale 7], length 0

Request times out as the src ip does not match the right interface.

@seankhliao
Copy link
Member

This is outside the control of Go. The program has bound to the correct source IP, it's then up to the kernel to route it, pointing to misconfiguration on your routing side.
Closing as not a bug in Go.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jan 1, 2023
@golang golang locked and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants