• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# DNS
2
3<!--introduced_in=v0.10.0-->
4
5> Stability: 2 - Stable
6
7<!-- source_link=lib/dns.js -->
8
9The `dns` module enables name resolution. For example, use it to look up IP
10addresses of host names.
11
12Although named for the [Domain Name System (DNS)][], it does not always use the
13DNS protocol for lookups. [`dns.lookup()`][] uses the operating system
14facilities to perform name resolution. It may not need to perform any network
15communication. To perform name resolution the way other applications on the same
16system do, use [`dns.lookup()`][].
17
18```js
19const dns = require('dns');
20
21dns.lookup('example.org', (err, address, family) => {
22  console.log('address: %j family: IPv%s', address, family);
23});
24// address: "93.184.216.34" family: IPv4
25```
26
27All other functions in the `dns` module connect to an actual DNS server to
28perform name resolution. They will always use the network to perform DNS
29queries. These functions do not use the same set of configuration files used by
30[`dns.lookup()`][] (e.g. `/etc/hosts`). Use these functions to always perform
31DNS queries, bypassing other name-resolution facilities.
32
33```js
34const dns = require('dns');
35
36dns.resolve4('archive.org', (err, addresses) => {
37  if (err) throw err;
38
39  console.log(`addresses: ${JSON.stringify(addresses)}`);
40
41  addresses.forEach((a) => {
42    dns.reverse(a, (err, hostnames) => {
43      if (err) {
44        throw err;
45      }
46      console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
47    });
48  });
49});
50```
51
52See the [Implementation considerations section][] for more information.
53
54## Class: `dns.Resolver`
55<!-- YAML
56added: v8.3.0
57-->
58
59An independent resolver for DNS requests.
60
61Creating a new resolver uses the default server settings. Setting
62the servers used for a resolver using
63[`resolver.setServers()`][`dns.setServers()`] does not affect
64other resolvers:
65
66```js
67const { Resolver } = require('dns');
68const resolver = new Resolver();
69resolver.setServers(['4.4.4.4']);
70
71// This request will use the server at 4.4.4.4, independent of global settings.
72resolver.resolve4('example.org', (err, addresses) => {
73  // ...
74});
75```
76
77The following methods from the `dns` module are available:
78
79* [`resolver.getServers()`][`dns.getServers()`]
80* [`resolver.resolve()`][`dns.resolve()`]
81* [`resolver.resolve4()`][`dns.resolve4()`]
82* [`resolver.resolve6()`][`dns.resolve6()`]
83* [`resolver.resolveAny()`][`dns.resolveAny()`]
84* [`resolver.resolveCaa()`][`dns.resolveCaa()`]
85* [`resolver.resolveCname()`][`dns.resolveCname()`]
86* [`resolver.resolveMx()`][`dns.resolveMx()`]
87* [`resolver.resolveNaptr()`][`dns.resolveNaptr()`]
88* [`resolver.resolveNs()`][`dns.resolveNs()`]
89* [`resolver.resolvePtr()`][`dns.resolvePtr()`]
90* [`resolver.resolveSoa()`][`dns.resolveSoa()`]
91* [`resolver.resolveSrv()`][`dns.resolveSrv()`]
92* [`resolver.resolveTxt()`][`dns.resolveTxt()`]
93* [`resolver.reverse()`][`dns.reverse()`]
94* [`resolver.setServers()`][`dns.setServers()`]
95
96### `Resolver([options])`
97<!-- YAML
98added: v8.3.0
99changes:
100  - version: v14.18.0
101    pr-url: https://github.com/nodejs/node/pull/39610
102    description: The `options` object now accepts a `tries` option.
103  - version: v14.5.0
104    pr-url: https://github.com/nodejs/node/pull/33472
105    description: The constructor now accepts an `options` object.
106                 The single supported option is `timeout`.
107-->
108
109Create a new resolver.
110
111* `options` {Object}
112  * `timeout` {integer} Query timeout in milliseconds, or `-1` to use the
113    default timeout.
114  * `tries` {integer} The number of tries the resolver will try contacting
115    each name server before giving up. **Default:** `4`
116
117### `resolver.cancel()`
118<!-- YAML
119added: v8.3.0
120-->
121
122Cancel all outstanding DNS queries made by this resolver. The corresponding
123callbacks will be called with an error with code `ECANCELLED`.
124
125### `resolver.setLocalAddress([ipv4][, ipv6])`
126<!-- YAML
127added: v14.17.0
128-->
129
130* `ipv4` {string} A string representation of an IPv4 address.
131  **Default:** `'0.0.0.0'`
132* `ipv6` {string} A string representation of an IPv6 address.
133  **Default:** `'::0'`
134
135The resolver instance will send its requests from the specified IP address.
136This allows programs to specify outbound interfaces when used on multi-homed
137systems.
138
139If a v4 or v6 address is not specified, it is set to the default, and the
140operating system will choose a local address automatically.
141
142The resolver will use the v4 local address when making requests to IPv4 DNS
143servers, and the v6 local address when making requests to IPv6 DNS servers.
144The `rrtype` of resolution requests has no impact on the local address used.
145
146## `dns.getServers()`
147<!-- YAML
148added: v0.11.3
149-->
150
151* Returns: {string[]}
152
153Returns an array of IP address strings, formatted according to [RFC 5952][],
154that are currently configured for DNS resolution. A string will include a port
155section if a custom port is used.
156
157<!-- eslint-disable semi-->
158```js
159[
160  '4.4.4.4',
161  '2001:4860:4860::8888',
162  '4.4.4.4:1053',
163  '[2001:4860:4860::8888]:1053',
164]
165```
166
167## `dns.lookup(hostname[, options], callback)`
168<!-- YAML
169added: v0.1.90
170changes:
171  - version: v8.5.0
172    pr-url: https://github.com/nodejs/node/pull/14731
173    description: The `verbatim` option is supported now.
174  - version: v1.2.0
175    pr-url: https://github.com/nodejs/node/pull/744
176    description: The `all` option is supported now.
177-->
178
179* `hostname` {string}
180* `options` {integer | Object}
181  * `family` {integer} The record family. Must be `4`, `6`, or `0`. The value
182    `0` indicates that IPv4 and IPv6 addresses are both returned. **Default:**
183    `0`.
184  * `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple
185    flags may be passed by bitwise `OR`ing their values.
186  * `all` {boolean} When `true`, the callback returns all resolved addresses in
187    an array. Otherwise, returns a single address. **Default:** `false`.
188  * `verbatim` {boolean} When `true`, the callback receives IPv4 and IPv6
189    addresses in the order the DNS resolver returned them. When `false`,
190    IPv4 addresses are placed before IPv6 addresses.
191    **Default:** currently `false` (addresses are reordered) but this is
192    expected to change in the not too distant future. Default value is
193    configurable using [`dns.setDefaultResultOrder()`][] or
194    [`--dns-result-order`][]. New code should use `{ verbatim: true }`.
195* `callback` {Function}
196  * `err` {Error}
197  * `address` {string} A string representation of an IPv4 or IPv6 address.
198  * `family` {integer} `4` or `6`, denoting the family of `address`, or `0` if
199    the address is not an IPv4 or IPv6 address. `0` is a likely indicator of a
200    bug in the name resolution service used by the operating system.
201
202Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
203AAAA (IPv6) record. All `option` properties are optional. If `options` is an
204integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
205and IPv6 addresses are both returned if found.
206
207With the `all` option set to `true`, the arguments for `callback` change to
208`(err, addresses)`, with `addresses` being an array of objects with the
209properties `address` and `family`.
210
211On error, `err` is an [`Error`][] object, where `err.code` is the error code.
212Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
213the host name does not exist but also when the lookup fails in other ways
214such as no available file descriptors.
215
216`dns.lookup()` does not necessarily have anything to do with the DNS protocol.
217The implementation uses an operating system facility that can associate names
218with addresses, and vice versa. This implementation can have subtle but
219important consequences on the behavior of any Node.js program. Please take some
220time to consult the [Implementation considerations section][] before using
221`dns.lookup()`.
222
223Example usage:
224
225```js
226const dns = require('dns');
227const options = {
228  family: 6,
229  hints: dns.ADDRCONFIG | dns.V4MAPPED,
230};
231dns.lookup('example.com', options, (err, address, family) =>
232  console.log('address: %j family: IPv%s', address, family));
233// address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
234
235// When options.all is true, the result will be an Array.
236options.all = true;
237dns.lookup('example.com', options, (err, addresses) =>
238  console.log('addresses: %j', addresses));
239// addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
240```
241
242If this method is invoked as its [`util.promisify()`][]ed version, and `all`
243is not set to `true`, it returns a `Promise` for an `Object` with `address` and
244`family` properties.
245
246### Supported getaddrinfo flags
247<!-- YAML
248changes:
249  - version: v14.0.0
250    pr-url: https://github.com/nodejs/node/pull/32183
251    description: Added support for the `dns.ALL` flag.
252-->
253
254The following flags can be passed as hints to [`dns.lookup()`][].
255
256* `dns.ADDRCONFIG`: Limits returned address types to the types of non-loopback
257  addresses configured on the system. For example, IPv4 addresses are only
258  returned if the current system has at least one IPv4 address configured.
259* `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses were
260  found, then return IPv4 mapped IPv6 addresses. It is not supported
261  on some operating systems (e.g FreeBSD 10.1).
262* `dns.ALL`: If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
263  well as IPv4 mapped IPv6 addresses.
264
265## `dns.lookupService(address, port, callback)`
266<!-- YAML
267added: v0.11.14
268-->
269
270* `address` {string}
271* `port` {number}
272* `callback` {Function}
273  * `err` {Error}
274  * `hostname` {string} e.g. `example.com`
275  * `service` {string} e.g. `http`
276
277Resolves the given `address` and `port` into a host name and service using
278the operating system's underlying `getnameinfo` implementation.
279
280If `address` is not a valid IP address, a `TypeError` will be thrown.
281The `port` will be coerced to a number. If it is not a legal port, a `TypeError`
282will be thrown.
283
284On an error, `err` is an [`Error`][] object, where `err.code` is the error code.
285
286```js
287const dns = require('dns');
288dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
289  console.log(hostname, service);
290  // Prints: localhost ssh
291});
292```
293
294If this method is invoked as its [`util.promisify()`][]ed version, it returns a
295`Promise` for an `Object` with `hostname` and `service` properties.
296
297## `dns.resolve(hostname[, rrtype], callback)`
298<!-- YAML
299added: v0.1.27
300-->
301
302* `hostname` {string} Host name to resolve.
303* `rrtype` {string} Resource record type. **Default:** `'A'`.
304* `callback` {Function}
305  * `err` {Error}
306  * `records` {string[] | Object[] | Object}
307
308Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
309of the resource records. The `callback` function has arguments
310`(err, records)`. When successful, `records` will be an array of resource
311records. The type and structure of individual results varies based on `rrtype`:
312
313|  `rrtype` | `records` contains             | Result type | Shorthand method         |
314|-----------|--------------------------------|-------------|--------------------------|
315| `'A'`     | IPv4 addresses (default)       | {string}    | [`dns.resolve4()`][]     |
316| `'AAAA'`  | IPv6 addresses                 | {string}    | [`dns.resolve6()`][]     |
317| `'ANY'`   | any records                    | {Object}    | [`dns.resolveAny()`][]   |
318| `'CAA'`   | CA authorization records       | {Object}    | [`dns.resolveCaa()`][]   |
319| `'CNAME'` | canonical name records         | {string}    | [`dns.resolveCname()`][] |
320| `'MX'`    | mail exchange records          | {Object}    | [`dns.resolveMx()`][]    |
321| `'NAPTR'` | name authority pointer records | {Object}    | [`dns.resolveNaptr()`][] |
322| `'NS'`    | name server records            | {string}    | [`dns.resolveNs()`][]    |
323| `'PTR'`   | pointer records                | {string}    | [`dns.resolvePtr()`][]   |
324| `'SOA'`   | start of authority records     | {Object}    | [`dns.resolveSoa()`][]   |
325| `'SRV'`   | service records                | {Object}    | [`dns.resolveSrv()`][]   |
326| `'TXT'`   | text records                   | {string[]}  | [`dns.resolveTxt()`][]   |
327
328On error, `err` is an [`Error`][] object, where `err.code` is one of the
329[DNS error codes](#dns_error_codes).
330
331## `dns.resolve4(hostname[, options], callback)`
332<!-- YAML
333added: v0.1.16
334changes:
335  - version: v7.2.0
336    pr-url: https://github.com/nodejs/node/pull/9296
337    description: This method now supports passing `options`,
338                 specifically `options.ttl`.
339-->
340
341* `hostname` {string} Host name to resolve.
342* `options` {Object}
343  * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
344    When `true`, the callback receives an array of
345    `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings,
346    with the TTL expressed in seconds.
347* `callback` {Function}
348  * `err` {Error}
349  * `addresses` {string[] | Object[]}
350
351Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the
352`hostname`. The `addresses` argument passed to the `callback` function
353will contain an array of IPv4 addresses (e.g.
354`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
355
356## `dns.resolve6(hostname[, options], callback)`
357<!-- YAML
358added: v0.1.16
359changes:
360  - version: v7.2.0
361    pr-url: https://github.com/nodejs/node/pull/9296
362    description: This method now supports passing `options`,
363                 specifically `options.ttl`.
364-->
365
366* `hostname` {string} Host name to resolve.
367* `options` {Object}
368  * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
369    When `true`, the callback receives an array of
370    `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of
371    strings, with the TTL expressed in seconds.
372* `callback` {Function}
373  * `err` {Error}
374  * `addresses` {string[] | Object[]}
375
376Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the
377`hostname`. The `addresses` argument passed to the `callback` function
378will contain an array of IPv6 addresses.
379
380## `dns.resolveAny(hostname, callback)`
381
382* `hostname` {string}
383* `callback` {Function}
384  * `err` {Error}
385  * `ret` {Object[]}
386
387Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
388The `ret` argument passed to the `callback` function will be an array containing
389various types of records. Each object has a property `type` that indicates the
390type of the current record. And depending on the `type`, additional properties
391will be present on the object:
392
393| Type | Properties |
394|------|------------|
395| `'A'` | `address`/`ttl` |
396| `'AAAA'` | `address`/`ttl` |
397| `'CNAME'` | `value` |
398| `'MX'` | Refer to [`dns.resolveMx()`][] |
399| `'NAPTR'` | Refer to [`dns.resolveNaptr()`][] |
400| `'NS'` | `value` |
401| `'PTR'` | `value` |
402| `'SOA'` | Refer to [`dns.resolveSoa()`][] |
403| `'SRV'` | Refer to [`dns.resolveSrv()`][] |
404| `'TXT'` | This type of record contains an array property called `entries` which refers to [`dns.resolveTxt()`][], e.g. `{ entries: ['...'], type: 'TXT' }` |
405
406Here is an example of the `ret` object passed to the callback:
407
408<!-- eslint-disable semi -->
409```js
410[ { type: 'A', address: '127.0.0.1', ttl: 299 },
411  { type: 'CNAME', value: 'example.com' },
412  { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
413  { type: 'NS', value: 'ns1.example.com' },
414  { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
415  { type: 'SOA',
416    nsname: 'ns1.example.com',
417    hostmaster: 'admin.example.com',
418    serial: 156696742,
419    refresh: 900,
420    retry: 900,
421    expire: 1800,
422    minttl: 60 } ]
423```
424
425DNS server operators may choose not to respond to `ANY`
426queries. It may be better to call individual methods like [`dns.resolve4()`][],
427[`dns.resolveMx()`][], and so on. For more details, see [RFC 8482][].
428
429## `dns.resolveCname(hostname, callback)`
430<!-- YAML
431added: v0.3.2
432-->
433
434* `hostname` {string}
435* `callback` {Function}
436  * `err` {Error}
437  * `addresses` {string[]}
438
439Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The
440`addresses` argument passed to the `callback` function
441will contain an array of canonical name records available for the `hostname`
442(e.g. `['bar.example.com']`).
443
444## `dns.resolveCaa(hostname, callback)`
445<!-- YAML
446added: v14.17.0
447-->
448
449* `hostname` {string}
450* `callback` {Function}
451  * `err` {Error}
452  * `records` {Object[]}
453
454Uses the DNS protocol to resolve `CAA` records for the `hostname`. The
455`addresses` argument passed to the `callback` function
456will contain an array of certification authority authorization records
457available for the `hostname` (e.g. `[{critical: 0, iodef:
458'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
459
460## `dns.resolveMx(hostname, callback)`
461<!-- YAML
462added: v0.1.27
463-->
464
465* `hostname` {string}
466* `callback` {Function}
467  * `err` {Error}
468  * `addresses` {Object[]}
469
470Uses the DNS protocol to resolve mail exchange records (`MX` records) for the
471`hostname`. The `addresses` argument passed to the `callback` function will
472contain an array of objects containing both a `priority` and `exchange`
473property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
474
475## `dns.resolveNaptr(hostname, callback)`
476<!-- YAML
477added: v0.9.12
478-->
479
480* `hostname` {string}
481* `callback` {Function}
482  * `err` {Error}
483  * `addresses` {Object[]}
484
485Uses the DNS protocol to resolve regular expression based records (`NAPTR`
486records) for the `hostname`. The `addresses` argument passed to the `callback`
487function will contain an array of objects with the following properties:
488
489* `flags`
490* `service`
491* `regexp`
492* `replacement`
493* `order`
494* `preference`
495
496<!-- eslint-skip -->
497```js
498{
499  flags: 's',
500  service: 'SIP+D2U',
501  regexp: '',
502  replacement: '_sip._udp.example.com',
503  order: 30,
504  preference: 100
505}
506```
507
508## `dns.resolveNs(hostname, callback)`
509<!-- YAML
510added: v0.1.90
511-->
512
513* `hostname` {string}
514* `callback` {Function}
515  * `err` {Error}
516  * `addresses` {string[]}
517
518Uses the DNS protocol to resolve name server records (`NS` records) for the
519`hostname`. The `addresses` argument passed to the `callback` function will
520contain an array of name server records available for `hostname`
521(e.g. `['ns1.example.com', 'ns2.example.com']`).
522
523## `dns.resolvePtr(hostname, callback)`
524<!-- YAML
525added: v6.0.0
526-->
527
528* `hostname` {string}
529* `callback` {Function}
530  * `err` {Error}
531  * `addresses` {string[]}
532
533Uses the DNS protocol to resolve pointer records (`PTR` records) for the
534`hostname`. The `addresses` argument passed to the `callback` function will
535be an array of strings containing the reply records.
536
537## `dns.resolveSoa(hostname, callback)`
538<!-- YAML
539added: v0.11.10
540-->
541
542* `hostname` {string}
543* `callback` {Function}
544  * `err` {Error}
545  * `address` {Object}
546
547Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
548the `hostname`. The `address` argument passed to the `callback` function will
549be an object with the following properties:
550
551* `nsname`
552* `hostmaster`
553* `serial`
554* `refresh`
555* `retry`
556* `expire`
557* `minttl`
558
559<!-- eslint-skip -->
560```js
561{
562  nsname: 'ns.example.com',
563  hostmaster: 'root.example.com',
564  serial: 2013101809,
565  refresh: 10000,
566  retry: 2400,
567  expire: 604800,
568  minttl: 3600
569}
570```
571
572## `dns.resolveSrv(hostname, callback)`
573<!-- YAML
574added: v0.1.27
575-->
576
577* `hostname` {string}
578* `callback` {Function}
579  * `err` {Error}
580  * `addresses` {Object[]}
581
582Uses the DNS protocol to resolve service records (`SRV` records) for the
583`hostname`. The `addresses` argument passed to the `callback` function will
584be an array of objects with the following properties:
585
586* `priority`
587* `weight`
588* `port`
589* `name`
590
591<!-- eslint-skip -->
592```js
593{
594  priority: 10,
595  weight: 5,
596  port: 21223,
597  name: 'service.example.com'
598}
599```
600
601## `dns.resolveTxt(hostname, callback)`
602<!-- YAML
603added: v0.1.27
604-->
605
606<!--lint disable no-undefined-references list-item-bullet-indent-->
607* `hostname` {string}
608* `callback` {Function}
609  * `err` {Error}
610  * `records` <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type">&lt;string[][]&gt;</a>
611<!--lint enable no-undefined-references list-item-bullet-indent-->
612
613Uses the DNS protocol to resolve text queries (`TXT` records) for the
614`hostname`. The `records` argument passed to the `callback` function is a
615two-dimensional array of the text records available for `hostname` (e.g.
616`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
617one record. Depending on the use case, these could be either joined together or
618treated separately.
619
620## `dns.reverse(ip, callback)`
621<!-- YAML
622added: v0.1.16
623-->
624
625* `ip` {string}
626* `callback` {Function}
627  * `err` {Error}
628  * `hostnames` {string[]}
629
630Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
631array of host names.
632
633On error, `err` is an [`Error`][] object, where `err.code` is
634one of the [DNS error codes][].
635
636## `dns.setDefaultResultOrder(order)`
637<!-- YAML
638added: v14.18.0
639-->
640
641* `order` {string} must be `'ipv4first'` or `'verbatim'`.
642
643Set the default value of `verbatim` in [`dns.lookup()`][] and
644[`dnsPromises.lookup()`][]. The value could be:
645* `ipv4first`: sets default `verbatim` `false`.
646* `verbatim`: sets default `verbatim` `true`.
647
648The default is `ipv4first` and [`dns.setDefaultResultOrder()`][] have higher
649priority than [`--dns-result-order`][]. When using [worker threads][],
650[`dns.setDefaultResultOrder()`][] from the main thread won't affect the default
651dns orders in workers.
652
653## `dns.setServers(servers)`
654<!-- YAML
655added: v0.11.3
656-->
657
658* `servers` {string[]} array of [RFC 5952][] formatted addresses
659
660Sets the IP address and port of servers to be used when performing DNS
661resolution. The `servers` argument is an array of [RFC 5952][] formatted
662addresses. If the port is the IANA default DNS port (53) it can be omitted.
663
664```js
665dns.setServers([
666  '4.4.4.4',
667  '[2001:4860:4860::8888]',
668  '4.4.4.4:1053',
669  '[2001:4860:4860::8888]:1053',
670]);
671```
672
673An error will be thrown if an invalid address is provided.
674
675The `dns.setServers()` method must not be called while a DNS query is in
676progress.
677
678The [`dns.setServers()`][] method affects only [`dns.resolve()`][],
679`dns.resolve*()` and [`dns.reverse()`][] (and specifically *not*
680[`dns.lookup()`][]).
681
682This method works much like
683[resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
684That is, if attempting to resolve with the first server provided results in a
685`NOTFOUND` error, the `resolve()` method will *not* attempt to resolve with
686subsequent servers provided. Fallback DNS servers will only be used if the
687earlier ones time out or result in some other error.
688
689## DNS promises API
690<!-- YAML
691added: v10.6.0
692changes:
693  - version:
694    - v11.14.0
695    - v10.17.0
696    pr-url: https://github.com/nodejs/node/pull/26592
697    description: This API is no longer experimental.
698-->
699
700The `dns.promises` API provides an alternative set of asynchronous DNS methods
701that return `Promise` objects rather than using callbacks. The API is accessible
702via `require('dns').promises`.
703
704### Class: `dnsPromises.Resolver`
705<!-- YAML
706added: v10.6.0
707-->
708
709An independent resolver for DNS requests.
710
711Creating a new resolver uses the default server settings. Setting
712the servers used for a resolver using
713[`resolver.setServers()`][`dnsPromises.setServers()`] does not affect
714other resolvers:
715
716```js
717const { Resolver } = require('dns').promises;
718const resolver = new Resolver();
719resolver.setServers(['4.4.4.4']);
720
721// This request will use the server at 4.4.4.4, independent of global settings.
722resolver.resolve4('example.org').then((addresses) => {
723  // ...
724});
725
726// Alternatively, the same code can be written using async-await style.
727(async function() {
728  const addresses = await resolver.resolve4('example.org');
729})();
730```
731
732The following methods from the `dnsPromises` API are available:
733
734* [`resolver.getServers()`][`dnsPromises.getServers()`]
735* [`resolver.resolve()`][`dnsPromises.resolve()`]
736* [`resolver.resolve4()`][`dnsPromises.resolve4()`]
737* [`resolver.resolve6()`][`dnsPromises.resolve6()`]
738* [`resolver.resolveAny()`][`dnsPromises.resolveAny()`]
739* [`resolver.resolveCaa()`][`dnsPromises.resolveCaa()`]
740* [`resolver.resolveCname()`][`dnsPromises.resolveCname()`]
741* [`resolver.resolveMx()`][`dnsPromises.resolveMx()`]
742* [`resolver.resolveNaptr()`][`dnsPromises.resolveNaptr()`]
743* [`resolver.resolveNs()`][`dnsPromises.resolveNs()`]
744* [`resolver.resolvePtr()`][`dnsPromises.resolvePtr()`]
745* [`resolver.resolveSoa()`][`dnsPromises.resolveSoa()`]
746* [`resolver.resolveSrv()`][`dnsPromises.resolveSrv()`]
747* [`resolver.resolveTxt()`][`dnsPromises.resolveTxt()`]
748* [`resolver.reverse()`][`dnsPromises.reverse()`]
749* [`resolver.setServers()`][`dnsPromises.setServers()`]
750
751### `resolver.cancel()`
752<!-- YAML
753added: v14.17.0
754-->
755
756Cancel all outstanding DNS queries made by this resolver. The corresponding
757promises will be rejected with an error with code `ECANCELLED`.
758
759### `dnsPromises.getServers()`
760<!-- YAML
761added: v10.6.0
762-->
763
764* Returns: {string[]}
765
766Returns an array of IP address strings, formatted according to [RFC 5952][],
767that are currently configured for DNS resolution. A string will include a port
768section if a custom port is used.
769
770<!-- eslint-disable semi-->
771```js
772[
773  '4.4.4.4',
774  '2001:4860:4860::8888',
775  '4.4.4.4:1053',
776  '[2001:4860:4860::8888]:1053',
777]
778```
779
780### `dnsPromises.lookup(hostname[, options])`
781<!-- YAML
782added: v10.6.0
783-->
784
785* `hostname` {string}
786* `options` {integer | Object}
787  * `family` {integer} The record family. Must be `4`, `6`, or `0`. The value
788    `0` indicates that IPv4 and IPv6 addresses are both returned. **Default:**
789    `0`.
790  * `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple
791    flags may be passed by bitwise `OR`ing their values.
792  * `all` {boolean} When `true`, the `Promise` is resolved with all addresses in
793    an array. Otherwise, returns a single address. **Default:** `false`.
794  * `verbatim` {boolean} When `true`, the `Promise` is resolved with IPv4 and
795    IPv6 addresses in the order the DNS resolver returned them. When `false`,
796    IPv4 addresses are placed before IPv6 addresses.
797    **Default:** currently `false` (addresses are reordered) but this is
798    expected to change in the not too distant future. Default value is
799    configurable using [`dns.setDefaultResultOrder()`][] or
800    [`--dns-result-order`][]. New code should use `{ verbatim: true }`.
801
802Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
803AAAA (IPv6) record. All `option` properties are optional. If `options` is an
804integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
805and IPv6 addresses are both returned if found.
806
807With the `all` option set to `true`, the `Promise` is resolved with `addresses`
808being an array of objects with the properties `address` and `family`.
809
810On error, the `Promise` is rejected with an [`Error`][] object, where `err.code`
811is the error code.
812Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
813the host name does not exist but also when the lookup fails in other ways
814such as no available file descriptors.
815
816[`dnsPromises.lookup()`][] does not necessarily have anything to do with the DNS
817protocol. The implementation uses an operating system facility that can
818associate names with addresses, and vice versa. This implementation can have
819subtle but important consequences on the behavior of any Node.js program. Please
820take some time to consult the [Implementation considerations section][] before
821using `dnsPromises.lookup()`.
822
823Example usage:
824
825```js
826const dns = require('dns');
827const dnsPromises = dns.promises;
828const options = {
829  family: 6,
830  hints: dns.ADDRCONFIG | dns.V4MAPPED,
831};
832
833dnsPromises.lookup('example.com', options).then((result) => {
834  console.log('address: %j family: IPv%s', result.address, result.family);
835  // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
836});
837
838// When options.all is true, the result will be an Array.
839options.all = true;
840dnsPromises.lookup('example.com', options).then((result) => {
841  console.log('addresses: %j', result);
842  // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
843});
844```
845
846### `dnsPromises.lookupService(address, port)`
847<!-- YAML
848added: v10.6.0
849-->
850
851* `address` {string}
852* `port` {number}
853
854Resolves the given `address` and `port` into a host name and service using
855the operating system's underlying `getnameinfo` implementation.
856
857If `address` is not a valid IP address, a `TypeError` will be thrown.
858The `port` will be coerced to a number. If it is not a legal port, a `TypeError`
859will be thrown.
860
861On error, the `Promise` is rejected with an [`Error`][] object, where `err.code`
862is the error code.
863
864```js
865const dnsPromises = require('dns').promises;
866dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
867  console.log(result.hostname, result.service);
868  // Prints: localhost ssh
869});
870```
871
872### `dnsPromises.resolve(hostname[, rrtype])`
873<!-- YAML
874added: v10.6.0
875-->
876
877* `hostname` {string} Host name to resolve.
878* `rrtype` {string} Resource record type. **Default:** `'A'`.
879
880Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
881of the resource records. When successful, the `Promise` is resolved with an
882array of resource records. The type and structure of individual results vary
883based on `rrtype`:
884
885|  `rrtype` | `records` contains             | Result type | Shorthand method         |
886|-----------|--------------------------------|-------------|--------------------------|
887| `'A'`     | IPv4 addresses (default)       | {string}    | [`dnsPromises.resolve4()`][]     |
888| `'AAAA'`  | IPv6 addresses                 | {string}    | [`dnsPromises.resolve6()`][]     |
889| `'ANY'`   | any records                    | {Object}    | [`dnsPromises.resolveAny()`][]   |
890| `'CAA'`   | CA authorization records       | {Object}    | [`dnsPromises.resolveCaa()`][] |
891| `'CNAME'` | canonical name records         | {string}    | [`dnsPromises.resolveCname()`][] |
892| `'MX'`    | mail exchange records          | {Object}    | [`dnsPromises.resolveMx()`][]    |
893| `'NAPTR'` | name authority pointer records | {Object}    | [`dnsPromises.resolveNaptr()`][] |
894| `'NS'`    | name server records            | {string}    | [`dnsPromises.resolveNs()`][]    |
895| `'PTR'`   | pointer records                | {string}    | [`dnsPromises.resolvePtr()`][]   |
896| `'SOA'`   | start of authority records     | {Object}    | [`dnsPromises.resolveSoa()`][]   |
897| `'SRV'`   | service records                | {Object}    | [`dnsPromises.resolveSrv()`][]   |
898| `'TXT'`   | text records                   | {string[]}  | [`dnsPromises.resolveTxt()`][]   |
899
900On error, the `Promise` is rejected with an [`Error`][] object, where `err.code`
901is one of the [DNS error codes](#dns_error_codes).
902
903### `dnsPromises.resolve4(hostname[, options])`
904<!-- YAML
905added: v10.6.0
906-->
907
908* `hostname` {string} Host name to resolve.
909* `options` {Object}
910  * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
911    When `true`, the `Promise` is resolved with an array of
912    `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings,
913    with the TTL expressed in seconds.
914
915Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the
916`hostname`. On success, the `Promise` is resolved with an array of IPv4
917addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
918
919### `dnsPromises.resolve6(hostname[, options])`
920<!-- YAML
921added: v10.6.0
922-->
923
924* `hostname` {string} Host name to resolve.
925* `options` {Object}
926  * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record.
927    When `true`, the `Promise` is resolved with an array of
928    `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of
929    strings, with the TTL expressed in seconds.
930
931Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the
932`hostname`. On success, the `Promise` is resolved with an array of IPv6
933addresses.
934
935### `dnsPromises.resolveAny(hostname)`
936<!-- YAML
937added: v10.6.0
938-->
939
940* `hostname` {string}
941
942Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
943On success, the `Promise` is resolved with an array containing various types of
944records. Each object has a property `type` that indicates the type of the
945current record. And depending on the `type`, additional properties will be
946present on the object:
947
948| Type | Properties |
949|------|------------|
950| `'A'` | `address`/`ttl` |
951| `'AAAA'` | `address`/`ttl` |
952| `'CNAME'` | `value` |
953| `'MX'` | Refer to [`dnsPromises.resolveMx()`][] |
954| `'NAPTR'` | Refer to [`dnsPromises.resolveNaptr()`][] |
955| `'NS'` | `value` |
956| `'PTR'` | `value` |
957| `'SOA'` | Refer to [`dnsPromises.resolveSoa()`][] |
958| `'SRV'` | Refer to [`dnsPromises.resolveSrv()`][] |
959| `'TXT'` | This type of record contains an array property called `entries` which refers to [`dnsPromises.resolveTxt()`][], e.g. `{ entries: ['...'], type: 'TXT' }` |
960
961Here is an example of the result object:
962
963<!-- eslint-disable semi -->
964```js
965[ { type: 'A', address: '127.0.0.1', ttl: 299 },
966  { type: 'CNAME', value: 'example.com' },
967  { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
968  { type: 'NS', value: 'ns1.example.com' },
969  { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
970  { type: 'SOA',
971    nsname: 'ns1.example.com',
972    hostmaster: 'admin.example.com',
973    serial: 156696742,
974    refresh: 900,
975    retry: 900,
976    expire: 1800,
977    minttl: 60 } ]
978```
979
980### `dnsPromises.resolveCaa(hostname)`
981<!-- YAML
982added: v14.17.0
983-->
984
985* `hostname` {string}
986
987Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
988the `Promise` is resolved with an array of objects containing available
989certification authority authorization records available for the `hostname`
990(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue:
991'pki.example.com'}]`).
992
993### `dnsPromises.resolveCname(hostname)`
994<!-- YAML
995added: v10.6.0
996-->
997
998* `hostname` {string}
999
1000Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
1001the `Promise` is resolved with an array of canonical name records available for
1002the `hostname` (e.g. `['bar.example.com']`).
1003
1004### `dnsPromises.resolveMx(hostname)`
1005<!-- YAML
1006added: v10.6.0
1007-->
1008
1009* `hostname` {string}
1010
1011Uses the DNS protocol to resolve mail exchange records (`MX` records) for the
1012`hostname`. On success, the `Promise` is resolved with an array of objects
1013containing both a `priority` and `exchange` property (e.g.
1014`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
1015
1016### `dnsPromises.resolveNaptr(hostname)`
1017<!-- YAML
1018added: v10.6.0
1019-->
1020
1021* `hostname` {string}
1022
1023Uses the DNS protocol to resolve regular expression based records (`NAPTR`
1024records) for the `hostname`. On success, the `Promise` is resolved with an array
1025of objects with the following properties:
1026
1027* `flags`
1028* `service`
1029* `regexp`
1030* `replacement`
1031* `order`
1032* `preference`
1033
1034<!-- eslint-skip -->
1035```js
1036{
1037  flags: 's',
1038  service: 'SIP+D2U',
1039  regexp: '',
1040  replacement: '_sip._udp.example.com',
1041  order: 30,
1042  preference: 100
1043}
1044```
1045
1046### `dnsPromises.resolveNs(hostname)`
1047<!-- YAML
1048added: v10.6.0
1049-->
1050
1051* `hostname` {string}
1052
1053Uses the DNS protocol to resolve name server records (`NS` records) for the
1054`hostname`. On success, the `Promise` is resolved with an array of name server
1055records available for `hostname` (e.g.
1056`['ns1.example.com', 'ns2.example.com']`).
1057
1058### `dnsPromises.resolvePtr(hostname)`
1059<!-- YAML
1060added: v10.6.0
1061-->
1062
1063* `hostname` {string}
1064
1065Uses the DNS protocol to resolve pointer records (`PTR` records) for the
1066`hostname`. On success, the `Promise` is resolved with an array of strings
1067containing the reply records.
1068
1069### `dnsPromises.resolveSoa(hostname)`
1070<!-- YAML
1071added: v10.6.0
1072-->
1073
1074* `hostname` {string}
1075
1076Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
1077the `hostname`. On success, the `Promise` is resolved with an object with the
1078following properties:
1079
1080* `nsname`
1081* `hostmaster`
1082* `serial`
1083* `refresh`
1084* `retry`
1085* `expire`
1086* `minttl`
1087
1088<!-- eslint-skip -->
1089```js
1090{
1091  nsname: 'ns.example.com',
1092  hostmaster: 'root.example.com',
1093  serial: 2013101809,
1094  refresh: 10000,
1095  retry: 2400,
1096  expire: 604800,
1097  minttl: 3600
1098}
1099```
1100
1101### `dnsPromises.resolveSrv(hostname)`
1102<!-- YAML
1103added: v10.6.0
1104-->
1105
1106* `hostname` {string}
1107
1108Uses the DNS protocol to resolve service records (`SRV` records) for the
1109`hostname`. On success, the `Promise` is resolved with an array of objects with
1110the following properties:
1111
1112* `priority`
1113* `weight`
1114* `port`
1115* `name`
1116
1117<!-- eslint-skip -->
1118```js
1119{
1120  priority: 10,
1121  weight: 5,
1122  port: 21223,
1123  name: 'service.example.com'
1124}
1125```
1126
1127### `dnsPromises.resolveTxt(hostname)`
1128<!-- YAML
1129added: v10.6.0
1130-->
1131
1132* `hostname` {string}
1133
1134Uses the DNS protocol to resolve text queries (`TXT` records) for the
1135`hostname`. On success, the `Promise` is resolved with a two-dimensional array
1136of the text records available for `hostname` (e.g.
1137`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
1138one record. Depending on the use case, these could be either joined together or
1139treated separately.
1140
1141### `dnsPromises.reverse(ip)`
1142<!-- YAML
1143added: v10.6.0
1144-->
1145
1146* `ip` {string}
1147
1148Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
1149array of host names.
1150
1151On error, the `Promise` is rejected with an [`Error`][] object, where `err.code`
1152is one of the [DNS error codes](#dns_error_codes).
1153
1154### `dnsPromises.setDefaultResultOrder(order)`
1155<!-- YAML
1156added: v14.18.0
1157-->
1158
1159* `order` {string} must be `'ipv4first'` or `'verbatim'`.
1160
1161Set the default value of `verbatim` in [`dns.lookup()`][] and
1162[`dnsPromises.lookup()`][]. The value could be:
1163* `ipv4first`: sets default `verbatim` `false`.
1164* `verbatim`: sets default `verbatim` `true`.
1165
1166The default is `ipv4first` and [`dnsPromises.setDefaultResultOrder()`][] have
1167higher priority than [`--dns-result-order`][]. When using [worker threads][],
1168[`dnsPromises.setDefaultResultOrder()`][] from the main thread won't affect the
1169default dns orders in workers.
1170
1171### `dnsPromises.setServers(servers)`
1172<!-- YAML
1173added: v10.6.0
1174-->
1175
1176* `servers` {string[]} array of [RFC 5952][] formatted addresses
1177
1178Sets the IP address and port of servers to be used when performing DNS
1179resolution. The `servers` argument is an array of [RFC 5952][] formatted
1180addresses. If the port is the IANA default DNS port (53) it can be omitted.
1181
1182```js
1183dnsPromises.setServers([
1184  '4.4.4.4',
1185  '[2001:4860:4860::8888]',
1186  '4.4.4.4:1053',
1187  '[2001:4860:4860::8888]:1053',
1188]);
1189```
1190
1191An error will be thrown if an invalid address is provided.
1192
1193The `dnsPromises.setServers()` method must not be called while a DNS query is in
1194progress.
1195
1196This method works much like
1197[resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
1198That is, if attempting to resolve with the first server provided results in a
1199`NOTFOUND` error, the `resolve()` method will *not* attempt to resolve with
1200subsequent servers provided. Fallback DNS servers will only be used if the
1201earlier ones time out or result in some other error.
1202
1203## Error codes
1204
1205Each DNS query can return one of the following error codes:
1206
1207* `dns.NODATA`: DNS server returned answer with no data.
1208* `dns.FORMERR`: DNS server claims query was misformatted.
1209* `dns.SERVFAIL`: DNS server returned general failure.
1210* `dns.NOTFOUND`: Domain name not found.
1211* `dns.NOTIMP`: DNS server does not implement requested operation.
1212* `dns.REFUSED`: DNS server refused query.
1213* `dns.BADQUERY`: Misformatted DNS query.
1214* `dns.BADNAME`: Misformatted host name.
1215* `dns.BADFAMILY`: Unsupported address family.
1216* `dns.BADRESP`: Misformatted DNS reply.
1217* `dns.CONNREFUSED`: Could not contact DNS servers.
1218* `dns.TIMEOUT`: Timeout while contacting DNS servers.
1219* `dns.EOF`: End of file.
1220* `dns.FILE`: Error reading file.
1221* `dns.NOMEM`: Out of memory.
1222* `dns.DESTRUCTION`: Channel is being destroyed.
1223* `dns.BADSTR`: Misformatted string.
1224* `dns.BADFLAGS`: Illegal flags specified.
1225* `dns.NONAME`: Given host name is not numeric.
1226* `dns.BADHINTS`: Illegal hints flags specified.
1227* `dns.NOTINITIALIZED`: c-ares library initialization not yet performed.
1228* `dns.LOADIPHLPAPI`: Error loading `iphlpapi.dll`.
1229* `dns.ADDRGETNETWORKPARAMS`: Could not find `GetNetworkParams` function.
1230* `dns.CANCELLED`: DNS query cancelled.
1231
1232## Implementation considerations
1233
1234Although [`dns.lookup()`][] and the various `dns.resolve*()/dns.reverse()`
1235functions have the same goal of associating a network name with a network
1236address (or vice versa), their behavior is quite different. These differences
1237can have subtle but significant consequences on the behavior of Node.js
1238programs.
1239
1240### `dns.lookup()`
1241
1242Under the hood, [`dns.lookup()`][] uses the same operating system facilities
1243as most other programs. For instance, [`dns.lookup()`][] will almost always
1244resolve a given name the same way as the `ping` command. On most POSIX-like
1245operating systems, the behavior of the [`dns.lookup()`][] function can be
1246modified by changing settings in nsswitch.conf(5) and/or resolv.conf(5),
1247but changing these files will change the behavior of all other
1248programs running on the same operating system.
1249
1250Though the call to `dns.lookup()` will be asynchronous from JavaScript's
1251perspective, it is implemented as a synchronous call to getaddrinfo(3) that runs
1252on libuv's threadpool. This can have surprising negative performance
1253implications for some applications, see the [`UV_THREADPOOL_SIZE`][]
1254documentation for more information.
1255
1256Various networking APIs will call `dns.lookup()` internally to resolve
1257host names. If that is an issue, consider resolving the host name to an address
1258using `dns.resolve()` and using the address instead of a host name. Also, some
1259networking APIs (such as [`socket.connect()`][] and [`dgram.createSocket()`][])
1260allow the default resolver, `dns.lookup()`, to be replaced.
1261
1262### `dns.resolve()`, `dns.resolve*()` and `dns.reverse()`
1263
1264These functions are implemented quite differently than [`dns.lookup()`][]. They
1265do not use getaddrinfo(3) and they _always_ perform a DNS query on the
1266network. This network communication is always done asynchronously, and does not
1267use libuv's threadpool.
1268
1269As a result, these functions cannot have the same negative impact on other
1270processing that happens on libuv's threadpool that [`dns.lookup()`][] can have.
1271
1272They do not use the same set of configuration files than what [`dns.lookup()`][]
1273uses. For instance, _they do not use the configuration from `/etc/hosts`_.
1274
1275[DNS error codes]: #dns_error_codes
1276[Domain Name System (DNS)]: https://en.wikipedia.org/wiki/Domain_Name_System
1277[Implementation considerations section]: #dns_implementation_considerations
1278[RFC 5952]: https://tools.ietf.org/html/rfc5952#section-6
1279[RFC 8482]: https://tools.ietf.org/html/rfc8482
1280[`--dns-result-order`]: cli.md#cli_dns_result_order_order
1281[`Error`]: errors.md#errors_class_error
1282[`UV_THREADPOOL_SIZE`]: cli.md#cli_uv_threadpool_size_size
1283[`dgram.createSocket()`]: dgram.md#dgram_dgram_createsocket_options_callback
1284[`dns.getServers()`]: #dns_dns_getservers
1285[`dns.lookup()`]: #dns_dns_lookup_hostname_options_callback
1286[`dns.resolve()`]: #dns_dns_resolve_hostname_rrtype_callback
1287[`dns.resolve4()`]: #dns_dns_resolve4_hostname_options_callback
1288[`dns.resolve6()`]: #dns_dns_resolve6_hostname_options_callback
1289[`dns.resolveAny()`]: #dns_dns_resolveany_hostname_callback
1290[`dns.resolveCaa()`]: #dns_dns_resolvecaa_hostname_callback
1291[`dns.resolveCname()`]: #dns_dns_resolvecname_hostname_callback
1292[`dns.resolveMx()`]: #dns_dns_resolvemx_hostname_callback
1293[`dns.resolveNaptr()`]: #dns_dns_resolvenaptr_hostname_callback
1294[`dns.resolveNs()`]: #dns_dns_resolvens_hostname_callback
1295[`dns.resolvePtr()`]: #dns_dns_resolveptr_hostname_callback
1296[`dns.resolveSoa()`]: #dns_dns_resolvesoa_hostname_callback
1297[`dns.resolveSrv()`]: #dns_dns_resolvesrv_hostname_callback
1298[`dns.resolveTxt()`]: #dns_dns_resolvetxt_hostname_callback
1299[`dns.reverse()`]: #dns_dns_reverse_ip_callback
1300[`dns.setDefaultResultOrder()`]: #dns_dns_setdefaultresultorder_order
1301[`dns.setServers()`]: #dns_dns_setservers_servers
1302[`dnsPromises.getServers()`]: #dns_dnspromises_getservers
1303[`dnsPromises.lookup()`]: #dns_dnspromises_lookup_hostname_options
1304[`dnsPromises.resolve()`]: #dns_dnspromises_resolve_hostname_rrtype
1305[`dnsPromises.resolve4()`]: #dns_dnspromises_resolve4_hostname_options
1306[`dnsPromises.resolve6()`]: #dns_dnspromises_resolve6_hostname_options
1307[`dnsPromises.resolveAny()`]: #dns_dnspromises_resolveany_hostname
1308[`dnsPromises.resolveCaa()`]: #dns_dnspromises_resolvecaa_hostname
1309[`dnsPromises.resolveCname()`]: #dns_dnspromises_resolvecname_hostname
1310[`dnsPromises.resolveMx()`]: #dns_dnspromises_resolvemx_hostname
1311[`dnsPromises.resolveNaptr()`]: #dns_dnspromises_resolvenaptr_hostname
1312[`dnsPromises.resolveNs()`]: #dns_dnspromises_resolvens_hostname
1313[`dnsPromises.resolvePtr()`]: #dns_dnspromises_resolveptr_hostname
1314[`dnsPromises.resolveSoa()`]: #dns_dnspromises_resolvesoa_hostname
1315[`dnsPromises.resolveSrv()`]: #dns_dnspromises_resolvesrv_hostname
1316[`dnsPromises.resolveTxt()`]: #dns_dnspromises_resolvetxt_hostname
1317[`dnsPromises.reverse()`]: #dns_dnspromises_reverse_ip
1318[`dnsPromises.setDefaultResultOrder()`]: #dns_dnspromises_setdefaultresultorder_order
1319[`dnsPromises.setServers()`]: #dns_dnspromises_setservers_servers
1320[`socket.connect()`]: net.md#net_socket_connect_options_connectlistener
1321[`util.promisify()`]: util.md#util_util_promisify_original
1322[supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags
1323[worker threads]: worker_threads.md
1324