Node.js module
dns
The 'node:dns' module provides DNS lookup and resolution services. It supports synchronous and asynchronous methods to resolve host names, addresses, and service records.
Functions include lookup, resolve, reverse, and others for fetching various DNS record types like A, AAAA, CNAME, MX, PTR, SRV, and TXT.
Fully supported in Bun
Fully implemented. > 90% of Node.js's test suite passes.
Functions 21
- dns.getDefaultResultOrder()
Get the default value for
orderin lookup anddnsPromises.lookup(). - dns.getServers()
Returns an array of IP address strings, formatted according to RFC 5952, that are currently configured for DNS resolution.
- dns.lookup()
Resolves a host name (e.g.
- dns.lookupService()
Resolves the given
addressandportinto a host name and service using the operating system's underlyinggetnameinfoimplementation. - dns.resolve()
Uses the DNS protocol to resolve a host name (e.g.
- dns.resolve4()
Uses the DNS protocol to resolve a IPv4 addresses (
Arecords) for thehostname. - dns.resolve6()
Uses the DNS protocol to resolve IPv6 addresses (
AAAArecords) for thehostname. - dns.resolveAny()
Uses the DNS protocol to resolve all records (also known as
ANYor*query). - dns.resolveCaa()
Uses the DNS protocol to resolve
CAArecords for thehostname. - dns.resolveCname()
Uses the DNS protocol to resolve
CNAMErecords for thehostname. - dns.resolveMx()
Uses the DNS protocol to resolve mail exchange records (
MXrecords) for thehostname. - dns.resolveNaptr()
Uses the DNS protocol to resolve regular expression-based records (
NAPTRrecords) for thehostname. - dns.resolveNs()
Uses the DNS protocol to resolve name server records (
NSrecords) for thehostname. - dns.resolvePtr()
Uses the DNS protocol to resolve pointer records (
PTRrecords) for thehostname. - dns.resolveSoa()
Uses the DNS protocol to resolve a start of authority record (
SOArecord) for thehostname. - dns.resolveSrv()
Uses the DNS protocol to resolve service records (
SRVrecords) for thehostname. - dns.resolveTlsa()
Uses the DNS protocol to resolve certificate associations (
TLSArecords) for thehostname. - dns.resolveTxt()
Uses the DNS protocol to resolve text queries (
TXTrecords) for thehostname. - dns.reverse()
Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names.
- dns.setDefaultResultOrder()
Set the default value of
orderin lookup anddnsPromises.lookup(). - dns.setServers()
Sets the IP address and port of servers to be used when performing DNS resolution.
Classes 1
- class dns.Resolver
An independent resolver for DNS requests.
Interfaces 26
- interface AnyAaaaRecord
- interface AnyARecord
- interface AnyCaaRecord
- interface AnyCnameRecord
- interface AnyMxRecord
- interface AnyNaptrRecord
- interface AnyNsRecord
- interface AnyPtrRecord
- interface AnySoaRecord
- interface AnySrvRecord
- interface AnyTlsaRecord
- interface AnyTxtRecord
- interface CaaRecord
- interface LookupAddress
- interface LookupAllOptions
- interface LookupOneOptions
- interface LookupOptions
- interface MxRecord
- interface NaptrRecord
- interface RecordWithTtl
- interface ResolveOptions
- interface ResolverOptions
- interface ResolveWithTtlOptions
- interface SoaRecord
- interface SrvRecord
- interface TlsaRecord
Types 1
Variables 27
- const dns.ADDRCONFIG
Limits returned address types to the types of non-loopback addresses configured on the system.
- const dns.ADDRGETNETWORKPARAMS
- const dns.ALL
If
dns.V4MAPPEDis specified, return resolved IPv6 addresses as well as IPv4 mapped IPv6 addresses. - const dns.BADFAMILY
- const dns.BADFLAGS
- const dns.BADHINTS
- const dns.BADNAME
- const dns.BADQUERY
- const dns.BADRESP
- const dns.BADSTR
- const dns.CANCELLED
- const dns.CONNREFUSED
- const dns.DESTRUCTION
- const dns.EOF
- const dns.FILE
- const dns.FORMERR
- const dns.LOADIPHLPAPI
- const dns.NODATA
- const dns.NOMEM
- const dns.NONAME
- const dns.NOTFOUND
- const dns.NOTIMP
- const dns.NOTINITIALIZED
- const dns.REFUSED
- const dns.SERVFAIL
- const dns.TIMEOUT
- const dns.V4MAPPED
If the IPv6 family was specified, but no IPv6 addresses were found, then return IPv4 mapped IPv6 addresses.
Namespaces 16
- namespace dns.lookup
- namespace dns.lookupService
- namespace dns.resolve
- namespace dns.resolve4
- namespace dns.resolve6
- namespace dns.resolveAny
- namespace dns.resolveCaa
- namespace dns.resolveCname
- namespace dns.resolveMx
- namespace dns.resolveNaptr
- namespace dns.resolveNs
- namespace dns.resolvePtr
- namespace dns.resolveSoa
- namespace dns.resolveSrv
- namespace dns.resolveTlsa
- namespace dns.resolveTxt