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

DNS server set to 0.0.0.0 causes lookups to time out #39795

Open
eigenstr opened this issue Aug 17, 2021 · 2 comments
Open

DNS server set to 0.0.0.0 causes lookups to time out #39795

eigenstr opened this issue Aug 17, 2021 · 2 comments
Labels
cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. dns Issues and PRs related to the dns subsystem.

Comments

@eigenstr
Copy link

Version

v14.17.5

Platform

Linux crux 5.10.59 #2 SMP Sun Aug 15 09:05:30 EDT 2021 i686 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

This code will eventually fail with a timeout, as if it didn't get any replies. However, the A query is sent to localhost and the local DNS server (BIND) replies immediately (as confirmed with both tcpdump and strace), every time it retries the query. However, it seems as if node is discarding the response for some reason.

var dns = require('dns');
dns.setServers(['0.0.0.0']);
dns.resolve('my.host.name', 'A', function (err, records) {});

Changing the DNS server to 127.0.0.1 (or any specific IP) works fine. Changing the nameserver line in /etc/resolv.conf and omitting the call to setServers() works exactly the same.

glibc is fine with "nameserver 0.0.0.0" in /etc/resolv.conf. I've never seen anything else fail like this, or care. (I understand that doesn't mean it's right!)

If node claimed 0.0.0.0 was invalid, or refused/failed to send the query, I would accept that as intended behavior. But it sends the query and gets a response which it ignores. That seems buggy.

The query gets sent "on the wire" (loopback) to 127.0.0.1, so I wondered if perhaps node was saying "I sent the query to 0.0.0.0 but got a reply from 127.0.0.1 so I'm going to ignore it. I tried to figure that out but got lost in the source.

How often does it reproduce? Is there a required condition?

100% reproducible.

What is the expected behavior?

Having a nameserver in resolv.conf set to 0.0.0.0 would work the same as 127.0.0.1.

Since it sends the query, I would expect it to accept/use the response it gets back.

What do you see instead?

0.0.0.0 causes timeouts, while 127.0.0.1 works fine.

Additional information

No response

@tniessen tniessen added cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. dns Issues and PRs related to the dns subsystem. labels Aug 17, 2021
@vastep
Copy link

vastep commented Aug 18, 2021

Hi. Why do you think 0.0.0.0 would work? It is not the address of any actual resource. But 127.0.0.1 is. Zeros have special meaning as 255s have. So I think it is not an issue but incorrect usage/config of the address.

@eigenstr
Copy link
Author

In the old days (early 90s is when I think I picked it up) "nameserver 0.0.0.0" was the resolv.conf convention for "localhost". glibc's resolver (based on BIND) recognized it and did the right thing.

Objectively, I'd agree that it probably doesn't make sense, and I certainly wouldn't go out of my way to make it work. BUT, node does send a query and it does get a response, which is ignored or discarded for whatever reason. If it rejected the address or failed to query, I wouldn't complain, but the current behavior seems buggy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cares Issues and PRs related to the c-ares dependency or the cares_wrap binding. dns Issues and PRs related to the dns subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants