Lines Matching refs:dns
7 <!-- source_link=lib/dns.js -->
9 The `dns` module enables name resolution. For example, use it to look up IP
13 DNS protocol for lookups. [`dns.lookup()`][] uses the operating system
16 system do, use [`dns.lookup()`][].
19 const dns = require('dns');
21 dns.lookup('example.org', (err, address, family) => {
27 All other functions in the `dns` module connect to an actual DNS server to
30 [`dns.lookup()`][] (e.g. `/etc/hosts`). Use these functions to always perform
34 const dns = require('dns');
36 dns.resolve4('archive.org', (err, addresses) => {
42 dns.reverse(a, (err, hostnames) => {
54 ## Class: `dns.Resolver`
63 [`resolver.setServers()`][`dns.setServers()`] does not affect
67 const { Resolver } = require('dns');
77 The following methods from the `dns` module are available:
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()`]
146 ## `dns.getServers()`
167 ## `dns.lookup(hostname[, options], callback)`
193 configurable using [`dns.setDefaultResultOrder()`][] or
194 [`--dns-result-order`][]. New code should use `{ verbatim: true }`.
216 `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
221 `dns.lookup()`.
226 const dns = require('dns');
229 hints: dns.ADDRCONFIG | dns.V4MAPPED,
231 dns.lookup('example.com', options, (err, address, family) =>
237 dns.lookup('example.com', options, (err, addresses) =>
251 description: Added support for the `dns.ALL` flag.
254 The following flags can be passed as hints to [`dns.lookup()`][].
256 * `dns.ADDRCONFIG`: Limits returned address types to the types of non-loopback
259 * `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses were
262 * `dns.ALL`: If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
265 ## `dns.lookupService(address, port, callback)`
287 const dns = require('dns');
288 dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
297 ## `dns.resolve(hostname[, rrtype], callback)`
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()`][] |
331 ## `dns.resolve4(hostname[, options], callback)`
356 ## `dns.resolve6(hostname[, options], callback)`
380 ## `dns.resolveAny(hostname, callback)`
398 | `'MX'` | Refer to [`dns.resolveMx()`][] |
399 | `'NAPTR'` | Refer to [`dns.resolveNaptr()`][] |
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.r…
426 queries. It may be better to call individual methods like [`dns.resolve4()`][],
427 [`dns.resolveMx()`][], and so on. For more details, see [RFC 8482][].
429 ## `dns.resolveCname(hostname, callback)`
444 ## `dns.resolveCaa(hostname, callback)`
460 ## `dns.resolveMx(hostname, callback)`
475 ## `dns.resolveNaptr(hostname, callback)`
508 ## `dns.resolveNs(hostname, callback)`
523 ## `dns.resolvePtr(hostname, callback)`
537 ## `dns.resolveSoa(hostname, callback)`
572 ## `dns.resolveSrv(hostname, callback)`
601 ## `dns.resolveTxt(hostname, callback)`
620 ## `dns.reverse(ip, callback)`
636 ## `dns.setDefaultResultOrder(order)`
643 Set the default value of `verbatim` in [`dns.lookup()`][] and
648 The default is `ipv4first` and [`dns.setDefaultResultOrder()`][] have higher
649 priority than [`--dns-result-order`][]. When using [worker threads][],
650 [`dns.setDefaultResultOrder()`][] from the main thread won't affect the default
651 dns orders in workers.
653 ## `dns.setServers(servers)`
665 dns.setServers([
675 The `dns.setServers()` method must not be called while a DNS query is in
678 The [`dns.setServers()`][] method affects only [`dns.resolve()`][],
679 `dns.resolve*()` and [`dns.reverse()`][] (and specifically *not*
680 [`dns.lookup()`][]).
700 The `dns.promises` API provides an alternative set of asynchronous DNS methods
702 via `require('dns').promises`.
717 const { Resolver } = require('dns').promises;
799 configurable using [`dns.setDefaultResultOrder()`][] or
800 [`--dns-result-order`][]. New code should use `{ verbatim: true }`.
826 const dns = require('dns');
827 const dnsPromises = dns.promises;
830 hints: dns.ADDRCONFIG | dns.V4MAPPED,
865 const dnsPromises = require('dns').promises;
1161 Set the default value of `verbatim` in [`dns.lookup()`][] and
1167 higher priority than [`--dns-result-order`][]. When using [worker threads][],
1169 default dns orders in workers.
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.
1234 Although [`dns.lookup()`][] and the various `dns.resolve*()/dns.reverse()`
1240 ### `dns.lookup()`
1242 Under the hood, [`dns.lookup()`][] uses the same operating system facilities
1243 as most other programs. For instance, [`dns.lookup()`][] will almost always
1245 operating systems, the behavior of the [`dns.lookup()`][] function can be
1250 Though the call to `dns.lookup()` will be asynchronous from JavaScript's
1256 Various networking APIs will call `dns.lookup()` internally to resolve
1258 using `dns.resolve()` and using the address instead of a host name. Also, some
1260 allow the default resolver, `dns.lookup()`, to be replaced.
1262 ### `dns.resolve()`, `dns.resolve*()` and `dns.reverse()`
1264 These functions are implemented quite differently than [`dns.lookup()`][]. They
1270 processing that happens on libuv's threadpool that [`dns.lookup()`][] can have.
1272 They do not use the same set of configuration files than what [`dns.lookup()`][]
1280 [`--dns-result-order`]: cli.md#cli_dns_result_order_order
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