Optionaloptions: ResolverOptionsReturns an array of IP address strings, formatted according to RFC 5952, that are currently configured for DNS resolution. A string will include a port section if a custom port is used.
[
'4.4.4.4',
'2001:4860:4860::8888',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053',
]
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names.
On error, err is an Error object, where err.code is
one of the DNS error codes.
Sets the IP address and port of servers to be used when performing DNS
resolution. The servers argument is an array of RFC 5952 formatted
addresses. If the port is the IANA default DNS port (53) it can be omitted.
dns.setServers([
'4.4.4.4',
'[2001:4860:4860::8888]',
'4.4.4.4:1053',
'[2001:4860:4860::8888]:1053',
]);
An error will be thrown if an invalid address is provided.
The dns.setServers() method must not be called while a DNS query is in
progress.
The setServers method affects only resolve, dns.resolve*() and reverse (and specifically not lookup).
This method works much like resolve.conf.
That is, if attempting to resolve with the first server provided results in a NOTFOUND error, the resolve() method will not attempt to resolve with
subsequent servers provided. Fallback DNS servers will only be used if the
earlier ones time out or result in some other error.
array of RFC 5952 formatted addresses
The resolver instance will send its requests from the specified IP address. This allows programs to specify outbound interfaces when used on multi-homed systems.
If a v4 or v6 address is not specified, it is set to the default and the operating system will choose a local address automatically.
The resolver will use the v4 local address when making requests to IPv4 DNS
servers, and the v6 local address when making requests to IPv6 DNS servers.
The rrtype of resolution requests has no impact on the local address used.
Optionalipv4: stringA string representation of an IPv4 address.
Optionalipv6: stringA string representation of an IPv6 address.
An independent resolver for DNS requests.
Creating a new resolver uses the default server settings. Setting the servers used for a resolver using
resolver.setServers()does not affect other resolvers:The following methods from the
node:dnsmodule are available:resolver.getServers()resolver.resolve()resolver.resolve4()resolver.resolve6()resolver.resolveAny()resolver.resolveCaa()resolver.resolveCname()resolver.resolveMx()resolver.resolveNaptr()resolver.resolveNs()resolver.resolvePtr()resolver.resolveSoa()resolver.resolveSrv()resolver.resolveTxt()resolver.reverse()resolver.setServers()Since
v8.3.0