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: LookupHost returns "no such host" when dns request timeout #10417
Comments
What is the exact message when you print out the error? |
@ianlancetaylor Updated. |
By default, unless you did something unusual when you built the Go compiler, the Go DNS client simply calls the system function getaddrinfo in this case. That error means that getaddrinfo returned EAI_NONAME. That is usually displayed as "Name or service not known" but to make the different DNS implementations more compatible the Go library converts it to "no such host". Unfortunately, as far as I can see, the getaddrinfo function has no way to indicate a timeout or a failure to contact the DNS servers. When using the native Go DNS client, it is possible to get a timeout error. When calling getaddrinfo, which is the default, that is not possible. If you build your own Go distribution, you can force use of the native Go DNS client rather than getaddrinfo by building your program with "go build -tags netgo -installsuffix netgo". But I don't see any way to fix this with the default build. |
I see. But would you mind to document that in net package? |
Update #10417. Change-Id: Ibfbdd05358f696a37217eef160f71b14a468ff86 Reviewed-on: https://go-review.googlesource.com/8788 Reviewed-by: Rob Pike <r@golang.org>
What version of Go are you using (go version)?
go version go1.4.2 linux/amd64
What operating system and processor architecture are you using?
Ubuntu 14.04.1 LTS
What did you do?
In this case DNS resolver doesn't response to queries.
What did you expect to see?
Timeout error
What did you see instead?
lookup 1428707955.plus.google.com.: no such host
timeout: false
How to reproduce the problem?
The test conducted uses an iptables rule to drop all inbound DNS responses. And the host used for the test "X.plus.google.com" (X = a timestamp) has a wildcard DNS record, so it should exist regardless what "X" is.
Test code and log is available at:
https://gist.github.com/ashi009/b97db1606258385cc32d
$ sudo apt-get install ngrep $ git clone https://gist.github.com/b97db1606258385cc32d.git $ cd b97db1606258385cc32d $ chmod +x reproduce.sh $ ./reproduce.sh
Note that, this error is also reproducible on
go version go1.4.2 darwin/amd64
, but needs different setup as iptables, strace are not available on mac.The text was updated successfully, but these errors were encountered: