Node.js dns module — DNS resolution and lookup functions.
Provides both callback-based and promise-based APIs for DNS operations.
Uses the operating system's underlying DNS facilities (primarily getaddrinfo)
for lookup(), and network-based DNS resolution for resolve*() methods.
🟢 lookup(hostname, options, callback)
Resolves a hostname into the first found A (IPv4) or AAAA (IPv6) record.
🟢 lookupService(address, port, callback)
Resolves the given address and port into a hostname and service using getnameinfo.
🟢 resolve(hostname, rrtype, callback)
Resolves a hostname using the specified record type (default "A").
🟢 resolve4(hostname, options, callback)
Resolves a hostname for IPv4 addresses (A records).
🟢 resolve6(hostname, options, callback)
Resolves a hostname for IPv6 addresses (AAAA records).
🟢 resolveCname(hostname, callback)
Resolves CNAME records for the given hostname.
🟢 resolveMx(hostname, callback)
Resolves MX records for the given hostname.
🟢 resolveNs(hostname, callback)
Resolves NS records for the given hostname.
🟢 resolveSrv(hostname, callback)
Resolves SRV records for the given hostname.
🟢 resolveTxt(hostname, callback)
Resolves TXT records for the given hostname.
🟢 resolveSoa(hostname, callback)
Resolves SOA (Start of Authority) record for the given hostname.
🟢 resolvePtr(hostname, callback)
Resolves PTR records for the given hostname.
🟢 resolveCaa(hostname, callback)
Resolves CAA (Certification Authority Authorization) records for the given hostname.
🟢 resolveNaptr(hostname, callback)
Resolves NAPTR (Naming Authority Pointer) records for the given hostname.
🟢 resolveTlsa(hostname, callback)
Resolves TLSA (Transport Layer Security Authentication) records for the given hostname.
🟢 resolveAny(hostname, callback)
Resolves all record types (ANY query) for the given hostname.
🟢 reverse(ip, callback)
Performs a reverse DNS query resolving an IP address to an array of hostnames.
🟢 getServers()
Returns an array of IP address strings of the servers currently configured for DNS resolution.
🟢 setServers(servers)
Sets the IP addresses of the servers to be used for DNS resolution.
🟢 setDefaultResultOrder(order)
Sets the default result order for dns.lookup() and dnsPromises.lookup().
🟢 getDefaultResultOrder()
Gets the default result order for dns.lookup().
🟢 promises
Gets the default result order for dns.lookup().
🟢 NODATA
— DNS server returned an answer with no data.
🟢 FORMERR
— DNS server claims query was malformed.
🟢 SERVFAIL
— DNS server returned a general failure.
🟢 NOTFOUND
— Domain name not found.
🟢 NOTIMP
— DNS server does not implement the requested operation.
🟢 REFUSED
— DNS server refused the query.
🟢 BADQUERY
— Misformatted DNS query.
🟢 BADNAME
— Misformatted hostname.
🟢 BADFAMILY
— Unsupported address family.
🟢 BADRESP
— Misformatted DNS reply.
🟢 CONNREFUSED
— Could not contact DNS servers.
🟢 TIMEOUT
— Timeout while contacting DNS servers.
🟢 FILE
— Error reading file.
🟢 DESTRUCTION
— Channel is being destroyed.
🟢 BADSTR
— Misformatted string.
🟢 BADFLAGS
— Illegal flags specified.
🟢 NONAME
— Given hostname is not numeric.
🟢 BADHINTS
— Illegal hints flags specified.
🟢 NOTINITIALIZED
— c-ares library initialization not yet performed.
🟢 LOADIPHLPAPI
— Error loading iphlpapi.dll (Windows).
🟢 ADDRGETNETWORKPARAMS
— Could not find GetNetworkParams function (Windows).
🟢 CANCELLED
— DNS query cancelled.