Skip to content

How to resolve IP address by it's domain? net.LookupIP function is incorrect. #37818

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
ghost opened this issue Mar 12, 2020 · 2 comments
Closed

Comments

@ghost
Copy link

ghost commented Mar 12, 2020

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

$ go version
go1.13.8 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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/entrl/.cache/go-build"
GOENV="/home/entrl/.config/go/env"
GOEXE=""
GOFLAGS=" -mod="
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="github.com/entrl/*"
GONOSUMDB="github.com/entrl/*"
GOOS="linux"
GOPATH="/home/entrl/go"
GOPRIVATE="github.com/entrl/*"
GOPROXY="direct"
GOROOT="/snap/go/5364"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/5364/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/entrl/Desktop/go-code/dns-resolver/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build407494331=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/__ErkGGpo4p

I'm trying to resolve IP address by host name. But unfortunately all sites which are hosted on CloudFlare returns 1.1.1.1
That is because Go sets IP address to Host Header instead of variable I passed to LookupIP function.

What did you expect to see?

I expect to see real IP address for domain

What did you see instead?

I see 1.1.1.1 in response

@seankhliao
Copy link
Member

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

1.1.1.1 is the correct response, if you try to make an HTTP request you will get a 301 redirect to www.udemy.com, which will return a "real" address

@ghost
Copy link
Author

ghost commented Mar 12, 2020

Got it, thank you.

@ghost ghost closed this as completed Mar 12, 2020
@golang golang locked and limited conversation to collaborators Mar 12, 2021
This issue was closed.
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

2 participants