Skip to content

On Windows, dns resolves using the secondary nameserver #42676

Open
@spazmodius

Description

@spazmodius

Version

v16.14.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

dns

What steps will reproduce the bug?

My Primary DNS server configures for 127.0.0.1, a local instance of SmartDns. My secondary DNS server is my ISP's.

However, Node resolves using the secondary DNS server, not the primary:

$ node -e 'dns.resolve4("www.google.com", { ttl: true }, console.log);'
null [
  { address: '142.250.138.105', ttl: 63 },
  { address: '142.250.138.106', ttl: 63 },
  { address: '142.250.138.99', ttl: 63 },
  { address: '142.250.138.147', ttl: 63 },
  { address: '142.250.138.104', ttl: 63 },
  { address: '142.250.138.103', ttl: 63 }
]

I can tell because of the short TTLs, whereas my SmartDns server is configured with a minimum TTL of 2400. Thus:

$ node -e 'dns.setServers(["127.0.0.1"]); dns.resolve4("www.google.com", { ttl: true }, console.log);'
null [ { address: '172.217.13.4', ttl: 2397 } ]

And as confirmation:

$ node -e 'console.log(dns.getServers());'
[ '12.127.16.67', '127.0.0.1' ]

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

Always sorts local addresses after remote addresses. If both Primary and Secondary are remote, then re-ordering does not happen.

What is the expected behavior?

I'd expect dns.getServers() to return [ 'primary', 'secondary' ], and for name resolution to prefer the Primary DNS server.

What do you see instead?

dns.getServers() reverse the primary and secondary DNS servers, and resolution prefers the secondary server.

Additional information

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    dnsIssues and PRs related to the dns subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions