The dns module contains functions belonging to two different categories:

1) Functions that use the underlying operating system facilities to perform
name resolution, and that do not necessarily perform any network communication.
This category contains only one function: dns.lookup(). Developers
looking to perform name resolution in the same way that other applications on
the same operating system behave should use dns.lookup().

2) Functions that connect to an actual DNS server to perform name resolution,
and that always use the network to perform DNS queries. This category
contains all functions in the dns module exceptdns.lookup(). These
functions do not use the same set of configuration files used by
dns.lookup() (e.g. /etc/hosts). These functions should be used by
developers who do not want to use the underlying operating system's facilities
for name resolution, and instead want to always perform DNS queries.

Below is an example that resolves 'archive.org' then reverse resolves the IP
addresses that are returned.

all<boolean> When true, the callback returns all resolved addresses in
an array. Otherwise, returns a single address. Default:false.

verbatim<boolean> When true, the callback receives IPv4 and IPv6
addresses in the order the DNS resolver returned them. When false,
IPv4 addresses are placed before IPv6 addresses.
Default: currently false (addresses are reordered) but this is
expected to change in the not too distant future.
New code should use { verbatim: true }.

Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or
AAAA (IPv6) record. All option properties are optional. If options is an
integer, then it must be 4 or 6 – if options is not provided, then IPv4
and IPv6 addresses are both returned if found.

With the all option set to true, the arguments for callback change to
(err, addresses), with addresses being an array of objects with the
properties address and family.

On error, err is an Error object, where err.code is the error code.
Keep in mind that err.code will be set to 'ENOENT' not only when
the hostname does not exist but also when the lookup fails in other ways
such as no available file descriptors.

dns.lookup() does not necessarily have anything to do with the DNS protocol.
The implementation uses an operating system facility that can associate names
with addresses, and vice versa. This implementation can have subtle but
important consequences on the behavior of any Node.js program. Please take some
time to consult the Implementation considerations section before using
dns.lookup().

dns.ADDRCONFIG: Returned address types are determined by the types
of addresses supported by the current system. For example, IPv4 addresses
are only returned if the current system has at least one IPv4 address
configured. Loopback addresses are not considered.

dns.V4MAPPED: If the IPv6 family was specified, but no IPv6 addresses were
found, then return IPv4 mapped IPv6 addresses. Note that it is not supported
on some operating systems (e.g FreeBSD 10.1).

Uses the DNS protocol to resolve a hostname (e.g. 'nodejs.org') into an array
of the resource records. The callback function has arguments
(err, records). When successful, records will be an array of resource
records. The type and structure of individual results varies based on rrtype:

ttl<boolean> Retrieve the Time-To-Live value (TTL) of each record.
When true, the callback receives an array of
{ address: '1.2.3.4', ttl: 60 } objects rather than an array of strings,
with the TTL expressed in seconds.

Uses the DNS protocol to resolve a IPv4 addresses (A records) for the
hostname. The addresses argument passed to the callback function
will contain an array of IPv4 addresses (e.g.
['74.125.79.104', '74.125.79.105', '74.125.79.106']).

ttl<boolean> Retrieve the Time-To-Live value (TTL) of each record.
When true, the callback receives an array of
{ address: '0:1:2:3:4:5:6:7', ttl: 60 } objects rather than an array of
strings, with the TTL expressed in seconds.

Uses the DNS protocol to resolve all records (also known as ANY or * query).
The ret argument passed to the callback function will be an array containing
various types of records. Each object has a property type that indicates the
type of the current record. And depending on the type, additional properties
will be present on the object:

Uses the DNS protocol to resolve CNAME records for the hostname. The
addresses argument passed to the callback function
will contain an array of canonical name records available for the hostname
(e.g. ['bar.example.com']).

Uses the DNS protocol to resolve regular expression based records (NAPTR
records) for the hostname. The addresses argument passed to the callback
function will contain an array of objects with the following properties:

Uses the DNS protocol to resolve name server records (NS records) for the
hostname. The addresses argument passed to the callback function will
contain an array of name server records available for hostname
(e.g. ['ns1.example.com', 'ns2.example.com']).

Uses the DNS protocol to resolve text queries (TXT records) for the
hostname. The records argument passed to the callback function is a
two-dimensional array of the text records available for hostname (e.g.
[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]). Each sub-array contains TXT chunks of
one record. Depending on the use case, these could be either joined together or
treated separately.

Sets the IP address and port of servers to be used when performing DNS
resolution. The servers argument is an array of rfc5952 formatted
addresses. If the port is the IANA default DNS port (53) it can be omitted.

The dns.setServers() method must not be called while a DNS query is in
progress.

Note that 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.

all<boolean> When true, the Promise is resolved with all addresses in
an array. Otherwise, returns a single address. Default:false.

verbatim<boolean> When true, the Promise is resolved with IPv4 and
IPv6 addresses in the order the DNS resolver returned them. When false,
IPv4 addresses are placed before IPv6 addresses.
Default: currently false (addresses are reordered) but this is
expected to change in the not too distant future.
New code should use { verbatim: true }.

Resolves a hostname (e.g. 'nodejs.org') into the first found A (IPv4) or
AAAA (IPv6) record. All option properties are optional. If options is an
integer, then it must be 4 or 6 – if options is not provided, then IPv4
and IPv6 addresses are both returned if found.

With the all option set to true, the Promise is resolved with addresses
being an array of objects with the properties address and family.

On error, the Promise is rejected with an Error object, where err.code
is the error code.
Keep in mind that err.code will be set to 'ENOENT' not only when
the hostname does not exist but also when the lookup fails in other ways
such as no available file descriptors.

dnsPromises.lookup() does not necessarily have anything to do with the DNS
protocol. The implementation uses an operating system facility that can
associate names with addresses, and vice versa. This implementation can have
subtle but important consequences on the behavior of any Node.js program. Please
take some time to consult the Implementation considerations section before
using dnsPromises.lookup().

Uses the DNS protocol to resolve a hostname (e.g. 'nodejs.org') into an array
of the resource records. When successful, the Promise is resolved with an
array of resource records. The type and structure of individual results vary
based on rrtype:

ttl<boolean> Retrieve the Time-To-Live value (TTL) of each record.
When true, the Promise is resolved with an array of
{ address: '1.2.3.4', ttl: 60 } objects rather than an array of strings,
with the TTL expressed in seconds.

Uses the DNS protocol to resolve IPv4 addresses (A records) for the
hostname. On success, the Promise is resolved with an array of IPv4
addresses (e.g. ['74.125.79.104', '74.125.79.105', '74.125.79.106']).

ttl<boolean> Retrieve the Time-To-Live value (TTL) of each record.
When true, the Promise is resolved with an array of
{ address: '0:1:2:3:4:5:6:7', ttl: 60 } objects rather than an array of
strings, with the TTL expressed in seconds.

Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the
hostname. On success, the Promise is resolved with an array of IPv6
addresses.

Uses the DNS protocol to resolve all records (also known as ANY or * query).
On success, the Promise is resolved with an array containing various types of
records. Each object has a property type that indicates the type of the
current record. And depending on the type, additional properties will be
present on the object:

Uses the DNS protocol to resolve mail exchange records (MX records) for the
hostname. On success, the Promise is resolved with an array of objects
containing both a priority and exchange property (e.g.
[{priority: 10, exchange: 'mx.example.com'}, ...]).

Uses the DNS protocol to resolve name server records (NS records) for the
hostname. On success, the Promise is resolved with an array of name server
records available for hostname (e.g.
['ns1.example.com', 'ns2.example.com']).

Uses the DNS protocol to resolve text queries (TXT records) for the
hostname. On success, the Promise is resolved with a two-dimensional array
of the text records available for hostname (e.g.
[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]). Each sub-array contains TXT chunks of
one record. Depending on the use case, these could be either joined together or
treated separately.

Sets the IP address and port of servers to be used when performing DNS
resolution. The servers argument is an array of rfc5952 formatted
addresses. If the port is the IANA default DNS port (53) it can be omitted.

The dnsPromises.setServers() method must not be called while a DNS query is in
progress.

Note that 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.

Although dns.lookup() and the various dns.resolve*()/dns.reverse()
functions have the same goal of associating a network name with a network
address (or vice versa), their behavior is quite different. These differences
can have subtle but significant consequences on the behavior of Node.js
programs.

Under the hood, dns.lookup() uses the same operating system facilities
as most other programs. For instance, dns.lookup() will almost always
resolve a given name the same way as the ping command. On most POSIX-like
operating systems, the behavior of the dns.lookup() function can be
modified by changing settings in nsswitch.conf(5) and/or resolv.conf(5),
but note that changing these files will change the behavior of all other
programs running on the same operating system.

Though the call to dns.lookup() will be asynchronous from JavaScript's
perspective, it is implemented as a synchronous call to getaddrinfo(3) that runs
on libuv's threadpool. This can have surprising negative performance
implications for some applications, see the UV_THREADPOOL_SIZE
documentation for more information.

Note that various networking APIs will call dns.lookup() internally to resolve
host names. If that is an issue, consider resolving the hostname to an address
using dns.resolve() and using the address instead of a host name. Also, some
networking APIs (such as socket.connect() and dgram.createSocket())
allow the default resolver, dns.lookup(), to be replaced.

These functions are implemented quite differently than dns.lookup(). They
do not use getaddrinfo(3) and they always perform a DNS query on the
network. This network communication is always done asynchronously, and does not
use libuv's threadpool.

As a result, these functions cannot have the same negative impact on other
processing that happens on libuv's threadpool that dns.lookup() can have.

They do not use the same set of configuration files than what dns.lookup()
uses. For instance, they do not use the configuration from /etc/hosts.