Skip to main content
Resolver - node__dns.d.ts - Node documentation
class Resolver

Usage in Deno

```typescript import { Resolver } from "node:node__dns.d.ts"; ```
An independent resolver for DNS requests. Creating a new resolver uses the default server settings. Setting the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v22.x/api/dns.html#dnssetserversservers) does not affect other resolvers: ```js import { Resolver } from 'node:dns'; const resolver = new Resolver(); resolver.setServers(['4.4.4.4']); // This request will use the server at 4.4.4.4, independent of global settings. resolver.resolve4('example.org', (err, addresses) => { // ... }); ``` The following methods from the `node:dns` module are available: * `resolver.getServers()` * `resolver.resolve()` * `resolver.resolve4()` * `resolver.resolve6()` * `resolver.resolveAny()` * `resolver.resolveCaa()` * `resolver.resolveCname()` * `resolver.resolveMx()` * `resolver.resolveNaptr()` * `resolver.resolveNs()` * `resolver.resolvePtr()` * `resolver.resolveSoa()` * `resolver.resolveSrv()` * `resolver.resolveTxt()` * `resolver.reverse()` * `resolver.setServers()`

Constructors

new
Resolver(options?: ResolverOptions)

Properties

Methods

cancel(): void
Cancel all outstanding DNS queries made by this resolver. The corresponding callbacks will be called with an error with code `ECANCELLED`.
setLocalAddress(
ipv4?: string,
ipv6?: string,
): void
The resolver instance will send its requests from the specified IP address. This allows programs to specify outbound interfaces when used on multi-homed systems. If a v4 or v6 address is not specified, it is set to the default and the operating system will choose a local address automatically. The resolver will use the v4 local address when making requests to IPv4 DNS servers, and the v6 local address when making requests to IPv6 DNS servers. The `rrtype` of resolution requests has no impact on the local address used.