Skip to content

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

Open
@eigenstr

Description

@eigenstr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    caresIssues and PRs related to the c-ares dependency or the cares_wrap binding.dnsIssues and PRs related to the dns subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions