M
dns.resolve
History
Added in: v0.1.27
v0.1.27
Introduced in: v0.10.0
v0.10.0
Passing an invalid callback to the
callback argument now throws ERR_INVALID_ARG_TYPE instead of ERR_INVALID_CALLBACK.v18.0.0
dns.resolve(hostname, rrtype?, callback): void
Attributes
Uses the DNS protocol to resolve a host name (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:
rrtype | records contains | Result type | Shorthand method |
|---|---|---|---|
'A' | IPv4 addresses (default) | string | dns.resolve4() |
'AAAA' | IPv6 addresses | string | dns.resolve6() |
'ANY' | any records | Object | dns.resolveAny() |
'CAA' | CA authorization records | Object | dns.resolveCaa() |
'CNAME' | canonical name records | string | dns.resolveCname() |
'MX' | mail exchange records | Object | dns.resolveMx() |
'NAPTR' | name authority pointer records | Object | dns.resolveNaptr() |
'NS' | name server records | string | dns.resolveNs() |
'PTR' | pointer records | string | dns.resolvePtr() |
'SOA' | start of authority records | Object | dns.resolveSoa() |
'SRV' | service records | Object | dns.resolveSrv() |
'TLSA' | certificate associations | Object | dns.resolveTlsa() |
'TXT' | text records | string[] | dns.resolveTxt() |
On error, err is an Error object, where err.code is one of the
DNS error codes.