node:dns
Node-compatible DNS name resolution and Resolver APIs (node:dns).
Available in vjs only (not available in vjs-lite). Enabled by default
unless --no-node-compat is passed.
import ... from "node:dns"
node-compat (enabled by default in vjs; absent in vjs-lite; disable with --no-node-compat)Example
Section titled “Example”import { lookup, promises as dnsPromises } from "node:dns";
lookup("localhost", (err, address, family) => { console.log(err, address, family);});const res = await dnsPromises.lookup("localhost");console.log(res.address, res.family);getDefaultResultOrdervjs onlyv0.0.0-alpha.2dns.lookup() ("verbatim", "ipv4first", or "ipv6first").setDefaultResultOrdervjs onlyv0.0.0-alpha.2dns.lookup().getServersvjs onlyv0.0.0-alpha.2setServersvjs onlyv0.0.0-alpha.2lookupvjs onlyv0.0.0-alpha.2hostname into the first found A (IPv4) or AAAA (IPv6) record via getaddrinfo.lookupServicevjs onlyv0.0.0-alpha.2(address, port) into a hostname and service name via getnameinfo.resolvevjs onlyv0.0.0-alpha.2rrtype (default "A") for hostname.resolve4vjs onlyv0.0.0-alpha.2A) records for hostname.resolve6vjs onlyv0.0.0-alpha.2AAAA) records for hostname.resolveAnyvjs onlyv0.0.0-alpha.2ANY) records for hostname.resolveCnamevjs onlyv0.0.0-alpha.2CNAME records for hostname.resolveMxvjs onlyv0.0.0-alpha.2MX records for hostname.resolveNaptrvjs onlyv0.0.0-alpha.2NAPTR records for hostname.resolveNsvjs onlyv0.0.0-alpha.2NS records for hostname.resolvePtrvjs onlyv0.0.0-alpha.2PTR records for hostname.resolveSoavjs onlyv0.0.0-alpha.2SOA record for hostname.resolveSrvvjs onlyv0.0.0-alpha.2SRV records for hostname.resolveTxtvjs onlyv0.0.0-alpha.2TXT records for hostname.reversevjs onlyv0.0.0-alpha.2ip to hostnames.LookupAddressvjs onlyv0.0.0-alpha.2lookup(..., { all: true }).LookupOptionsvjs onlyv0.0.0-alpha.2dns.lookup().ResolveOptionsvjs onlyv0.0.0-alpha.2resolve4() and resolve6().RecordWithTtlvjs onlyv0.0.0-alpha.2{ ttl: true } is passed to resolve4() / resolve6().MxRecordvjs onlyv0.0.0-alpha.2resolveMx().NaptrRecordvjs onlyv0.0.0-alpha.2resolveNaptr().SoaRecordvjs onlyv0.0.0-alpha.2resolveSoa().SrvRecordvjs onlyv0.0.0-alpha.2resolveSrv().ResolverOptionsvjs onlyv0.0.0-alpha.2new Resolver(options).DnsPromisesvjs onlyv0.0.0-alpha.2node:dns/promises).ADDRCONFIGvjs onlyv0.0.0-alpha.2getaddrinfo hint flag limiting results to configured address families.ALLvjs onlyv0.0.0-alpha.2getaddrinfo hint flag returning both IPv4-mapped and IPv6 addresses.V4MAPPEDvjs onlyv0.0.0-alpha.2getaddrinfo hint flag returning IPv4-mapped IPv6 addresses when no native IPv6 exists.BADFAMILYvjs onlyv0.0.0-alpha.2BADFLAGSvjs onlyv0.0.0-alpha.2BADHINTSvjs onlyv0.0.0-alpha.2BADNAMEvjs onlyv0.0.0-alpha.2BADQUERYvjs onlyv0.0.0-alpha.2BADRESPvjs onlyv0.0.0-alpha.2BADSTRvjs onlyv0.0.0-alpha.2CANCELLEDvjs onlyv0.0.0-alpha.2CONNREFUSEDvjs onlyv0.0.0-alpha.2DESTRUCTIONvjs onlyv0.0.0-alpha.2EOFvjs onlyv0.0.0-alpha.2FILEvjs onlyv0.0.0-alpha.2FORMERRvjs onlyv0.0.0-alpha.2LOADIPHLPAPIvjs onlyv0.0.0-alpha.2iphlpapi.dll on Windows.NODATAvjs onlyv0.0.0-alpha.2NOMEMvjs onlyv0.0.0-alpha.2NONAMEvjs onlyv0.0.0-alpha.2NOTFOUNDvjs onlyv0.0.0-alpha.2ENOTFOUND).NOTIMPvjs onlyv0.0.0-alpha.2NOTINITIALIZEDvjs onlyv0.0.0-alpha.2REFUSEDvjs onlyv0.0.0-alpha.2SERVFAILvjs onlyv0.0.0-alpha.2TIMEOUTvjs onlyv0.0.0-alpha.2ADDRGETNETWORKPARAMSvjs onlyv0.0.0-alpha.2promisesvjs onlyv0.0.0-alpha.2node:dns/promises).Functions
Section titled “Functions”getDefaultResultOrder
Section titled “getDefaultResultOrder”export function getDefaultResultOrder(): ResultOrder;
Return the default result ordering used by dns.lookup() ("verbatim",
"ipv4first", or "ipv6first").
ResultOrder — Current default ResultOrder.setDefaultResultOrder
Section titled “setDefaultResultOrder”export function setDefaultResultOrder(order: ResultOrder): void;
Set the default result ordering used by dns.lookup().
| Name | Type | Description |
|---|---|---|
order | ResultOrder | "ipv4first", "ipv6first", or "verbatim". |
voidgetServers
Section titled “getServers”export function getServers(): string[];
Return the array of IP address strings currently configured for DNS resolution.
string[] — Array of DNS server IP strings.setServers
Section titled “setServers”export function setServers(servers: readonly string[]): void;
Replace the array of DNS server IP addresses used by default queries.
| Name | Type | Description |
|---|---|---|
servers | readonly string[] | Array of IPv4 or IPv6 server strings (with optional :port). |
voidlookup
Section titled “lookup”export function lookup(
hostname: string,
callback: (err: Error | null, address: string, family: number) => void,
): void;
export function lookup(
hostname: string,
family: number,
callback: (err: Error | null, address: string, family: number) => void,
): void;
export function lookup(
hostname: string,
options: LookupOptions & { all: true },
callback: (err: Error | null, addresses: LookupAddress[]) => void,
): void;
export function lookup(
hostname: string,
options: LookupOptions,
callback: (err: Error | null, address: string | LookupAddress[], family?: number) => void,
): void;
Resolve hostname into the first found A (IPv4) or AAAA (IPv6) record via getaddrinfo.
lookup(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | Hostname or IP literal to resolve. |
callback | (err: Error | null, address: string, family: number) => void | Callback invoked with (err, address, family). |
voidlookup(hostname, family, callback)Resolve hostname with family integer constraint.
| Name | Type | Description |
|---|---|---|
hostname | string | Hostname or IP literal to resolve. |
family | number | Address family (0, 4, or 6). |
callback | (err: Error | null, address: string, family: number) => void | Callback invoked with (err, address, family). |
voidlookup(hostname, options, callback)Resolve hostname returning all matching LookupAddress records.
| Name | Type | Description |
|---|---|---|
hostname | string | Hostname or IP literal to resolve. |
options | LookupOptions & { all: true } | Lookup options with all: true. |
callback | (err: Error | null, addresses: LookupAddress[]) => void | Callback invoked with (err, addresses). |
voidlookup(hostname, options, callback)Resolve hostname with explicit LookupOptions.
| Name | Type | Description |
|---|---|---|
hostname | string | Hostname or IP literal to resolve. |
options | LookupOptions | Lookup options. |
callback | (err: Error | null, address: string | LookupAddress[], family?: number) => void | Callback invoked with (err, addressOrList, family). |
voidlookupService
Section titled “lookupService”export function lookupService(
address: string,
port: number,
callback: (err: Error | null, hostname: string, service: string) => void,
): void;
Resolve (address, port) into a hostname and service name via getnameinfo.
| Name | Type | Description |
|---|---|---|
address | string | IPv4 or IPv6 address string. |
port | number | Numeric port (0..=65535). |
callback | (err: Error | null, hostname: string, service: string) => void | Callback invoked with (err, hostname, service). |
voidresolve
Section titled “resolve”export function resolve(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
export function resolve(
hostname: string,
rrtype: string,
callback: (err: Error | null, addresses: unknown) => void,
): void;
Resolve DNS records of rrtype (default "A") for hostname.
resolve(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | Domain name to query. |
callback | (err: Error | null, addresses: string[]) => void | Callback invoked with (err, addresses). |
voidresolve(hostname, rrtype, callback)Resolve DNS records of explicit rrtype for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | Domain name to query. |
rrtype | string | DNS resource record type ("A", "AAAA", "MX", "TXT", etc.). |
callback | (err: Error | null, addresses: unknown) => void | Callback invoked with (err, addresses). |
voidresolve4
Section titled “resolve4”export function resolve4(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
export function resolve4(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
Resolve IPv4 (A) records for hostname.
resolve4(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolve4(hostname, options, callback)Resolve IPv4 (A) records with options for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
options | ResolveOptions | — |
callback | (err: Error | null, addresses: string[] | RecordWithTtl[]) => void | — |
voidresolve6
Section titled “resolve6”export function resolve6(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
export function resolve6(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
Resolve IPv6 (AAAA) records for hostname.
resolve6(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolve6(hostname, options, callback)Resolve IPv6 (AAAA) records with options for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
options | ResolveOptions | — |
callback | (err: Error | null, addresses: string[] | RecordWithTtl[]) => void | — |
voidresolveAny
Section titled “resolveAny”export function resolveAny(
hostname: string,
callback: (err: Error | null, addresses: AnyRecord[]) => void,
): void;
Resolve all available (ANY) records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: AnyRecord[]) => void | — |
voidresolveCname
Section titled “resolveCname”export function resolveCname(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
Resolve CNAME records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolveMx
Section titled “resolveMx”export function resolveMx(
hostname: string,
callback: (err: Error | null, addresses: MxRecord[]) => void,
): void;
Resolve MX records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: MxRecord[]) => void | — |
voidresolveNaptr
Section titled “resolveNaptr”export function resolveNaptr(
hostname: string,
callback: (err: Error | null, addresses: NaptrRecord[]) => void,
): void;
Resolve NAPTR records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: NaptrRecord[]) => void | — |
voidresolveNs
Section titled “resolveNs”export function resolveNs(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
Resolve NS records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolvePtr
Section titled “resolvePtr”export function resolvePtr(
hostname: string,
callback: (err: Error | null, addresses: string[]) => void,
): void;
Resolve PTR records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolveSoa
Section titled “resolveSoa”export function resolveSoa(
hostname: string,
callback: (err: Error | null, address: SoaRecord) => void,
): void;
Resolve the SOA record for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, address: SoaRecord) => void | — |
voidresolveSrv
Section titled “resolveSrv”export function resolveSrv(
hostname: string,
callback: (err: Error | null, addresses: SrvRecord[]) => void,
): void;
Resolve SRV records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: SrvRecord[]) => void | — |
voidresolveTxt
Section titled “resolveTxt”export function resolveTxt(
hostname: string,
callback: (err: Error | null, addresses: string[][]) => void,
): void;
Resolve TXT records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[][]) => void | — |
voidreverse
Section titled “reverse”export function reverse(
ip: string,
callback: (err: Error | null, hostnames: string[]) => void,
): void;
Reverse-resolve IP address ip to hostnames.
| Name | Type | Description |
|---|---|---|
ip | string | — |
callback | (err: Error | null, hostnames: string[]) => void | — |
voidClasses
Section titled “Classes”Resolver
Section titled “Resolver”export class Resolver {
constructor(options?: ResolverOptions);
cancel(): void;
getServers(): string[];
setServers(servers: readonly string[]): void;
setLocalAddress(ipv4?: string, ipv6?: string): void;
resolve(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve(
hostname: string,
rrtype: string,
callback: (err: Error | null, addresses: unknown) => void,
): void;
resolve4(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve4(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
resolve6(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve6(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
resolveAny(hostname: string, callback: (err: Error | null, addresses: AnyRecord[]) => void): void;
resolveCname(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolveMx(hostname: string, callback: (err: Error | null, addresses: MxRecord[]) => void): void;
resolveNaptr(
hostname: string,
callback: (err: Error | null, addresses: NaptrRecord[]) => void,
): void;
resolveNs(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolvePtr(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolveSoa(hostname: string, callback: (err: Error | null, address: SoaRecord) => void): void;
resolveSrv(hostname: string, callback: (err: Error | null, addresses: SrvRecord[]) => void): void;
resolveTxt(hostname: string, callback: (err: Error | null, addresses: string[][]) => void): void;
reverse(ip: string, callback: (err: Error | null, hostnames: string[]) => void): void;
}
Independent callback-based DNS resolver instance.
constructor(options?: ResolverOptions);
Construct a new DNS Resolver.
| Name | Type | Description |
|---|---|---|
options optional | ResolverOptions | Optional timeout and retry configuration. |
Resolver.cancel
Section titled “Resolver.cancel”cancel(): void;
Cancel all outstanding DNS queries on this resolver.
voidResolver.getServers
Section titled “Resolver.getServers”getServers(): string[];
Return the list of configured DNS server IP addresses.
string[]Resolver.setServers
Section titled “Resolver.setServers”setServers(servers: readonly string[]): void;
Set the DNS server IP addresses used by this resolver.
| Name | Type | Description |
|---|---|---|
servers | readonly string[] | — |
voidResolver.setLocalAddress
Section titled “Resolver.setLocalAddress”setLocalAddress(ipv4?: string, ipv6?: string): void;
Set local source IPv4/IPv6 addresses for outgoing DNS queries.
| Name | Type | Description |
|---|---|---|
ipv4 optional | string | — |
ipv6 optional | string | — |
voidResolver.resolve
Section titled “Resolver.resolve”resolve(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve(
hostname: string,
rrtype: string,
callback: (err: Error | null, addresses: unknown) => void,
): void;
Resolve DNS records of rrtype (default "A") for hostname.
resolve(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolve(hostname, rrtype, callback)Resolve DNS records of explicit rrtype for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
rrtype | string | — |
callback | (err: Error | null, addresses: unknown) => void | — |
voidResolver.resolve4
Section titled “Resolver.resolve4”resolve4(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve4(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
Resolve IPv4 (A) records for hostname.
resolve4(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolve4(hostname, options, callback)Resolve IPv4 (A) records with options for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
options | ResolveOptions | — |
callback | (err: Error | null, addresses: string[] | RecordWithTtl[]) => void | — |
voidResolver.resolve6
Section titled “Resolver.resolve6”resolve6(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
resolve6(
hostname: string,
options: ResolveOptions,
callback: (err: Error | null, addresses: string[] | RecordWithTtl[]) => void,
): void;
Resolve IPv6 (AAAA) records for hostname.
resolve6(hostname, callback)| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidresolve6(hostname, options, callback)Resolve IPv6 (AAAA) records with options for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
options | ResolveOptions | — |
callback | (err: Error | null, addresses: string[] | RecordWithTtl[]) => void | — |
voidResolver.resolveAny
Section titled “Resolver.resolveAny”resolveAny(hostname: string, callback: (err: Error | null, addresses: AnyRecord[]) => void): void;
Resolve all available DNS records (ANY) for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: AnyRecord[]) => void | — |
voidResolver.resolveCname
Section titled “Resolver.resolveCname”resolveCname(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
Resolve CNAME records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidResolver.resolveMx
Section titled “Resolver.resolveMx”resolveMx(hostname: string, callback: (err: Error | null, addresses: MxRecord[]) => void): void;
Resolve MX records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: MxRecord[]) => void | — |
voidResolver.resolveNaptr
Section titled “Resolver.resolveNaptr”resolveNaptr(
hostname: string,
callback: (err: Error | null, addresses: NaptrRecord[]) => void,
): void;
Resolve NAPTR records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: NaptrRecord[]) => void | — |
voidResolver.resolveNs
Section titled “Resolver.resolveNs”resolveNs(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
Resolve NS records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidResolver.resolvePtr
Section titled “Resolver.resolvePtr”resolvePtr(hostname: string, callback: (err: Error | null, addresses: string[]) => void): void;
Resolve PTR records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[]) => void | — |
voidResolver.resolveSoa
Section titled “Resolver.resolveSoa”resolveSoa(hostname: string, callback: (err: Error | null, address: SoaRecord) => void): void;
Resolve SOA record for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, address: SoaRecord) => void | — |
voidResolver.resolveSrv
Section titled “Resolver.resolveSrv”resolveSrv(hostname: string, callback: (err: Error | null, addresses: SrvRecord[]) => void): void;
Resolve SRV records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: SrvRecord[]) => void | — |
voidResolver.resolveTxt
Section titled “Resolver.resolveTxt”resolveTxt(hostname: string, callback: (err: Error | null, addresses: string[][]) => void): void;
Resolve TXT records for hostname.
| Name | Type | Description |
|---|---|---|
hostname | string | — |
callback | (err: Error | null, addresses: string[][]) => void | — |
voidResolver.reverse
Section titled “Resolver.reverse”reverse(ip: string, callback: (err: Error | null, hostnames: string[]) => void): void;
Reverse-resolve IP address ip to hostnames.
| Name | Type | Description |
|---|---|---|
ip | string | — |
callback | (err: Error | null, hostnames: string[]) => void | — |
voidInterfaces
Section titled “Interfaces”LookupAddress
Section titled “LookupAddress”export interface LookupAddress {
address: string;
family: number;
}
Resolved IP address entry returned by lookup(..., { all: true }).
| Property | Type | Description | Since |
|---|---|---|---|
address | string | IPv4 or IPv6 address string. | v0.0.0-alpha.2 |
family | number | Address family (4 or 6). | v0.0.0-alpha.2 |
LookupOptions
Section titled “LookupOptions”export interface LookupOptions {
family?: number | "IPv4" | "IPv6";
hints?: number;
all?: boolean;
order?: ResultOrder;
verbatim?: boolean;
}
Options accepted by dns.lookup().
| Property | Type | Description | Since |
|---|---|---|---|
family optional | number | "IPv4" | "IPv6" | Address family constraint (0, 4, 6, "IPv4", or "IPv6"). | v0.0.0-alpha.2 |
hints optional | number | getaddrinfo hint flags (ADDRCONFIG, V4MAPPED, ALL). | v0.0.0-alpha.2 |
all optional | boolean | Return an array of all resolved addresses when true. | v0.0.0-alpha.2 |
order optional | ResultOrder | Address sorting order ("ipv4first", "ipv6first", "verbatim"). | v0.0.0-alpha.2 |
verbatim optional | boolean | Support legacy verbatim boolean flag. | v0.0.0-alpha.2 |
ResolveOptions
Section titled “ResolveOptions”export interface ResolveOptions {
ttl?: boolean;
}
Options accepted by resolve4() and resolve6().
| Property | Type | Description | Since |
|---|---|---|---|
ttl optional | boolean | Include record TTL values when true. | v0.0.0-alpha.2 |
RecordWithTtl
Section titled “RecordWithTtl”export interface RecordWithTtl {
address: string;
ttl: number;
}
Address record with TTL returned when { ttl: true } is passed to resolve4() / resolve6().
| Property | Type | Description | Since |
|---|---|---|---|
address | string | Resolved IP address string. | v0.0.0-alpha.2 |
ttl | number | Time-to-live in seconds. | v0.0.0-alpha.2 |
MxRecord
Section titled “MxRecord”export interface MxRecord {
priority: number;
exchange: string;
}
MX mail-exchange record returned by resolveMx().
| Property | Type | Description | Since |
|---|---|---|---|
priority | number | Mail exchange preference priority. | v0.0.0-alpha.2 |
exchange | string | Mail server hostname. | v0.0.0-alpha.2 |
NaptrRecord
Section titled “NaptrRecord”export interface NaptrRecord {
flags: string;
service: string;
regexp: string;
replacement: string;
order: number;
preference: number;
}
NAPTR record returned by resolveNaptr().
| Property | Type | Description | Since |
|---|---|---|---|
flags | string | Flags string. | v0.0.0-alpha.2 |
service | string | Service string. | v0.0.0-alpha.2 |
regexp | string | Regular expression substitution string. | v0.0.0-alpha.2 |
replacement | string | Replacement domain name. | v0.0.0-alpha.2 |
order | number | Rule order value. | v0.0.0-alpha.2 |
preference | number | Rule preference value. | v0.0.0-alpha.2 |
SoaRecord
Section titled “SoaRecord”export interface SoaRecord {
nsname: string;
hostmaster: string;
serial: number;
refresh: number;
retry: number;
expire: number;
minttl: number;
}
SOA start-of-authority record returned by resolveSoa().
| Property | Type | Description | Since |
|---|---|---|---|
nsname | string | Primary name server. | v0.0.0-alpha.2 |
hostmaster | string | Hostmaster email address in DNS notation. | v0.0.0-alpha.2 |
serial | number | Zone serial number. | v0.0.0-alpha.2 |
refresh | number | Refresh interval in seconds. | v0.0.0-alpha.2 |
retry | number | Retry interval in seconds. | v0.0.0-alpha.2 |
expire | number | Expiration interval in seconds. | v0.0.0-alpha.2 |
minttl | number | Minimum TTL in seconds. | v0.0.0-alpha.2 |
SrvRecord
Section titled “SrvRecord”export interface SrvRecord {
priority: number;
weight: number;
port: number;
name: string;
}
SRV service-location record returned by resolveSrv().
| Property | Type | Description | Since |
|---|---|---|---|
priority | number | Priority of the target host. | v0.0.0-alpha.2 |
weight | number | Relative weight for records with equal priority. | v0.0.0-alpha.2 |
port | number | Target TCP or UDP port. | v0.0.0-alpha.2 |
name | string | Target hostname. | v0.0.0-alpha.2 |
ResolverOptions
Section titled “ResolverOptions”export interface ResolverOptions {
timeout?: number;
tries?: number;
maxTimeout?: number;
}
Options accepted by new Resolver(options).
| Property | Type | Description | Since |
|---|---|---|---|
timeout optional | number | Query timeout in milliseconds (-1 for default). | v0.0.0-alpha.2 |
tries optional | number | Maximum retry attempts per DNS query. | v0.0.0-alpha.2 |
maxTimeout optional | number | Maximum UDP payload size in bytes. | v0.0.0-alpha.2 |
DnsPromises
Section titled “DnsPromises”export interface DnsPromises {
Resolver: typeof import("node:dns/promises").Resolver;
lookup: typeof import("node:dns/promises").lookup;
lookupService: typeof import("node:dns/promises").lookupService;
resolve: typeof import("node:dns/promises").resolve;
resolve4: typeof import("node:dns/promises").resolve4;
resolve6: typeof import("node:dns/promises").resolve6;
resolveAny: typeof import("node:dns/promises").resolveAny;
resolveCname: typeof import("node:dns/promises").resolveCname;
resolveMx: typeof import("node:dns/promises").resolveMx;
resolveNaptr: typeof import("node:dns/promises").resolveNaptr;
resolveNs: typeof import("node:dns/promises").resolveNs;
resolvePtr: typeof import("node:dns/promises").resolvePtr;
resolveSoa: typeof import("node:dns/promises").resolveSoa;
resolveSrv: typeof import("node:dns/promises").resolveSrv;
resolveTxt: typeof import("node:dns/promises").resolveTxt;
reverse: typeof import("node:dns/promises").reverse;
getServers: typeof getServers;
setServers: typeof setServers;
getDefaultResultOrder: typeof getDefaultResultOrder;
setDefaultResultOrder: typeof setDefaultResultOrder;
}
Promise-based DNS API surface (node:dns/promises).
| Property | Type | Description | Since |
|---|---|---|---|
Resolver | typeof import("node:dns/promises").Resolver | Promise-based Resolver constructor. | v0.0.0-alpha.2 |
lookup | typeof import("node:dns/promises").lookup | Resolve hostname using OS getaddrinfo. | v0.0.0-alpha.2 |
lookupService | typeof import("node:dns/promises").lookupService | Reverse-resolve (address, port) to { hostname, service }. | v0.0.0-alpha.2 |
resolve | typeof import("node:dns/promises").resolve | Resolve DNS records of rrtype for hostname. | v0.0.0-alpha.2 |
resolve4 | typeof import("node:dns/promises").resolve4 | Resolve IPv4 (A) records. | v0.0.0-alpha.2 |
resolve6 | typeof import("node:dns/promises").resolve6 | Resolve IPv6 (AAAA) records. | v0.0.0-alpha.2 |
resolveAny | typeof import("node:dns/promises").resolveAny | Resolve ANY records. | v0.0.0-alpha.2 |
resolveCname | typeof import("node:dns/promises").resolveCname | Resolve CNAME records. | v0.0.0-alpha.2 |
resolveMx | typeof import("node:dns/promises").resolveMx | Resolve MX records. | v0.0.0-alpha.2 |
resolveNaptr | typeof import("node:dns/promises").resolveNaptr | Resolve NAPTR records. | v0.0.0-alpha.2 |
resolveNs | typeof import("node:dns/promises").resolveNs | Resolve NS records. | v0.0.0-alpha.2 |
resolvePtr | typeof import("node:dns/promises").resolvePtr | Resolve PTR records. | v0.0.0-alpha.2 |
resolveSoa | typeof import("node:dns/promises").resolveSoa | Resolve SOA record. | v0.0.0-alpha.2 |
resolveSrv | typeof import("node:dns/promises").resolveSrv | Resolve SRV records. | v0.0.0-alpha.2 |
resolveTxt | typeof import("node:dns/promises").resolveTxt | Resolve TXT records. | v0.0.0-alpha.2 |
reverse | typeof import("node:dns/promises").reverse | Reverse-resolve an IP address to hostnames. | v0.0.0-alpha.2 |
getServers | typeof getServers | Return configured DNS servers. | v0.0.0-alpha.2 |
setServers | typeof setServers | Configure DNS servers. | v0.0.0-alpha.2 |
getDefaultResultOrder | typeof getDefaultResultOrder | Return default lookup() result order. | v0.0.0-alpha.2 |
setDefaultResultOrder | typeof setDefaultResultOrder | Set default lookup() result order. | v0.0.0-alpha.2 |
Type Aliases
Section titled “Type Aliases”ResultOrder
Section titled “ResultOrder”export type ResultOrder = "ipv4first" | "ipv6first" | "verbatim";
DNS address ordering preference accepted by setDefaultResultOrder() and lookup().
AnyRecord
Section titled “AnyRecord”export type AnyRecord =
| ({ type: "A" | "AAAA" } & RecordWithTtl)
| ({ type: "MX" } & MxRecord)
| ({ type: "NAPTR" } & NaptrRecord)
| ({ type: "SOA" } & SoaRecord)
| ({ type: "SRV" } & SrvRecord)
| { type: "TXT"; entries: string[] }
| { type: "NS" | "PTR" | "CNAME"; value: string };
Union of typed DNS records returned by resolveAny().
Constants
Section titled “Constants”ADDRCONFIG
Section titled “ADDRCONFIG”export const ADDRCONFIG: number;
getaddrinfo hint flag limiting results to configured address families.
export const ALL: number;
getaddrinfo hint flag returning both IPv4-mapped and IPv6 addresses.
V4MAPPED
Section titled “V4MAPPED”export const V4MAPPED: number;
getaddrinfo hint flag returning IPv4-mapped IPv6 addresses when no native IPv6 exists.
BADFAMILY
Section titled “BADFAMILY”export const BADFAMILY: string;
DNS error code: address family not supported.
BADFLAGS
Section titled “BADFLAGS”export const BADFLAGS: string;
DNS error code: invalid flags passed to query.
BADHINTS
Section titled “BADHINTS”export const BADHINTS: string;
DNS error code: invalid hints value.
BADNAME
Section titled “BADNAME”export const BADNAME: string;
DNS error code: malformed hostname.
BADQUERY
Section titled “BADQUERY”export const BADQUERY: string;
DNS error code: malformed DNS query.
BADRESP
Section titled “BADRESP”export const BADRESP: string;
DNS error code: malformed DNS reply.
BADSTR
Section titled “BADSTR”export const BADSTR: string;
DNS error code: malformed IP string.
CANCELLED
Section titled “CANCELLED”export const CANCELLED: string;
DNS error code: query cancelled.
CONNREFUSED
Section titled “CONNREFUSED”export const CONNREFUSED: string;
DNS error code: could not contact DNS servers.
DESTRUCTION
Section titled “DESTRUCTION”export const DESTRUCTION: string;
DNS error code: channel is being destroyed.
export const EOF: string;
DNS error code: end of file.
export const FILE: string;
DNS error code: error reading configuration file.
FORMERR
Section titled “FORMERR”export const FORMERR: string;
DNS error code: DNS server reports query format error.
LOADIPHLPAPI
Section titled “LOADIPHLPAPI”export const LOADIPHLPAPI: string;
DNS error code: error loading iphlpapi.dll on Windows.
NODATA
Section titled “NODATA”export const NODATA: string;
DNS error code: DNS server returned no data.
export const NOMEM: string;
DNS error code: out of memory.
NONAME
Section titled “NONAME”export const NONAME: string;
DNS error code: non-existent host name.
NOTFOUND
Section titled “NOTFOUND”export const NOTFOUND: string;
DNS error code: domain name not found (ENOTFOUND).
NOTIMP
Section titled “NOTIMP”export const NOTIMP: string;
DNS error code: DNS server does not implement requested operation.
NOTINITIALIZED
Section titled “NOTINITIALIZED”export const NOTINITIALIZED: string;
DNS error code: resolver library not initialized.
REFUSED
Section titled “REFUSED”export const REFUSED: string;
DNS error code: DNS server refused query.
SERVFAIL
Section titled “SERVFAIL”export const SERVFAIL: string;
DNS error code: DNS server returned general failure.
TIMEOUT
Section titled “TIMEOUT”export const TIMEOUT: string;
DNS error code: timeout contacting DNS servers.
ADDRGETNETWORKPARAMS
Section titled “ADDRGETNETWORKPARAMS”export const ADDRGETNETWORKPARAMS: string;
DNS error code: error finding network parameters on Windows.
promises
Section titled “promises”export const promises: DnsPromises;
Promise-based DNS API (node:dns/promises).
Default Export
Section titled “Default Export”default export
Section titled “default export”const _default: {
/** Lookup hint constant `ADDRCONFIG`. @since 0.0.0-alpha.2 */
readonly ADDRCONFIG: number;
/** Lookup hint constant `ALL`. @since 0.0.0-alpha.2 */
readonly ALL: number;
/** Error constant `BADFAMILY`. @since 0.0.0-alpha.2 */
readonly BADFAMILY: string;
/** Error constant `BADFLAGS`. @since 0.0.0-alpha.2 */
readonly BADFLAGS: string;
/** Error constant `BADHINTS`. @since 0.0.0-alpha.2 */
readonly BADHINTS: string;
/** Error constant `BADNAME`. @since 0.0.0-alpha.2 */
readonly BADNAME: string;
/** Error constant `BADQUERY`. @since 0.0.0-alpha.2 */
readonly BADQUERY: string;
/** Error constant `BADRESP`. @since 0.0.0-alpha.2 */
readonly BADRESP: string;
/** Error constant `BADSTR`. @since 0.0.0-alpha.2 */
readonly BADSTR: string;
/** Error constant `CANCELLED`. @since 0.0.0-alpha.2 */
readonly CANCELLED: string;
/** Error constant `CONNREFUSED`. @since 0.0.0-alpha.2 */
readonly CONNREFUSED: string;
/** Error constant `DESTRUCTION`. @since 0.0.0-alpha.2 */
readonly DESTRUCTION: string;
/** Error constant `EOF`. @since 0.0.0-alpha.2 */
readonly EOF: string;
/** Error constant `FILE`. @since 0.0.0-alpha.2 */
readonly FILE: string;
/** Error constant `FORMERR`. @since 0.0.0-alpha.2 */
readonly FORMERR: string;
/** Error constant `LOADIPHLPAPI`. @since 0.0.0-alpha.2 */
readonly LOADIPHLPAPI: string;
/** Error constant `NODATA`. @since 0.0.0-alpha.2 */
readonly NODATA: string;
/** Error constant `NOMEM`. @since 0.0.0-alpha.2 */
readonly NOMEM: string;
/** Error constant `NONAME`. @since 0.0.0-alpha.2 */
readonly NONAME: string;
/** Error constant `NOTFOUND`. @since 0.0.0-alpha.2 */
readonly NOTFOUND: string;
/** Error constant `NOTIMP`. @since 0.0.0-alpha.2 */
readonly NOTIMP: string;
/** Error constant `NOTINITIALIZED`. @since 0.0.0-alpha.2 */
readonly NOTINITIALIZED: string;
/** Error constant `REFUSED`. @since 0.0.0-alpha.2 */
readonly REFUSED: string;
/** `Resolver` constructor. @since 0.0.0-alpha.2 */
Resolver: typeof Resolver;
/** Error constant `SERVFAIL`. @since 0.0.0-alpha.2 */
readonly SERVFAIL: string;
/** Error constant `TIMEOUT`. @since 0.0.0-alpha.2 */
readonly TIMEOUT: string;
/** Lookup hint constant `V4MAPPED`. @since 0.0.0-alpha.2 */
readonly V4MAPPED: number;
/** Error constant `ADDRGETNETWORKPARAMS`. @since 0.0.0-alpha.2 */
readonly ADDRGETNETWORKPARAMS: string;
/** Get default `lookup()` result order. @since 0.0.0-alpha.2 */
getDefaultResultOrder: typeof getDefaultResultOrder;
/** Get configured DNS servers. @since 0.0.0-alpha.2 */
getServers: typeof getServers;
/** Resolve hostname via OS `getaddrinfo`. @since 0.0.0-alpha.2 */
lookup: typeof lookup;
/** Reverse-resolve address and port via OS `getnameinfo`. @since 0.0.0-alpha.2 */
lookupService: typeof lookupService;
/** Promise-based DNS API (`node:dns/promises`). @since 0.0.0-alpha.2 */
readonly promises: DnsPromises;
/** Resolve DNS records by type. @since 0.0.0-alpha.2 */
resolve: typeof resolve;
/** Resolve IPv4 (`A`) records. @since 0.0.0-alpha.2 */
resolve4: typeof resolve4;
/** Resolve IPv6 (`AAAA`) records. @since 0.0.0-alpha.2 */
resolve6: typeof resolve6;
/** Resolve `ANY` records. @since 0.0.0-alpha.2 */
resolveAny: typeof resolveAny;
/** Resolve `CNAME` records. @since 0.0.0-alpha.2 */
resolveCname: typeof resolveCname;
/** Resolve `MX` records. @since 0.0.0-alpha.2 */
resolveMx: typeof resolveMx;
/** Resolve `NAPTR` records. @since 0.0.0-alpha.2 */
resolveNaptr: typeof resolveNaptr;
/** Resolve `NS` records. @since 0.0.0-alpha.2 */
resolveNs: typeof resolveNs;
/** Resolve `PTR` records. @since 0.0.0-alpha.2 */
resolvePtr: typeof resolvePtr;
/** Resolve `SOA` record. @since 0.0.0-alpha.2 */
resolveSoa: typeof resolveSoa;
/** Resolve `SRV` records. @since 0.0.0-alpha.2 */
resolveSrv: typeof resolveSrv;
/** Resolve `TXT` records. @since 0.0.0-alpha.2 */
resolveTxt: typeof resolveTxt;
/** Reverse-resolve IP address to hostnames. @since 0.0.0-alpha.2 */
reverse: typeof reverse;
/** Set default `lookup()` result order. @since 0.0.0-alpha.2 */
setDefaultResultOrder: typeof setDefaultResultOrder;
/** Configure DNS servers. @since 0.0.0-alpha.2 */
setServers: typeof setServers;
};
export default _default;
Default export object providing the node:dns API.
