Node.js module

dns

The 'node:dns' module provides DNS lookup and resolution services. It supports synchronous and asynchronous methods to resolve host names, addresses, and service records.

Functions include lookup, resolve, reverse, and others for fetching various DNS record types like A, AAAA, CNAME, MX, PTR, SRV, and TXT.

Fully supported in Bun

Fully implemented. > 90% of Node.js's test suite passes.

Functions 21

  • dns.getDefaultResultOrder()

    Get the default value for order in lookup and dnsPromises.lookup().

  • dns.getServers()

    Returns an array of IP address strings, formatted according to RFC 5952, that are currently configured for DNS resolution.

  • dns.lookup()

    Resolves a host name (e.g.

  • dns.lookupService()

    Resolves the given address and port into a host name and service using the operating system's underlying getnameinfo implementation.

  • dns.resolve()

    Uses the DNS protocol to resolve a host name (e.g.

  • dns.resolve4()

    Uses the DNS protocol to resolve a IPv4 addresses (A records) for the hostname.

  • dns.resolve6()

    Uses the DNS protocol to resolve IPv6 addresses (AAAA records) for the hostname.

  • dns.resolveAny()

    Uses the DNS protocol to resolve all records (also known as ANY or * query).

  • dns.resolveCaa()

    Uses the DNS protocol to resolve CAA records for the hostname.

  • dns.resolveCname()

    Uses the DNS protocol to resolve CNAME records for the hostname.

  • dns.resolveMx()

    Uses the DNS protocol to resolve mail exchange records (MX records) for the hostname.

  • dns.resolveNaptr()

    Uses the DNS protocol to resolve regular expression-based records (NAPTR records) for the hostname.

  • dns.resolveNs()

    Uses the DNS protocol to resolve name server records (NS records) for the hostname.

  • dns.resolvePtr()

    Uses the DNS protocol to resolve pointer records (PTR records) for the hostname.

  • dns.resolveSoa()

    Uses the DNS protocol to resolve a start of authority record (SOA record) for the hostname.

  • dns.resolveSrv()

    Uses the DNS protocol to resolve service records (SRV records) for the hostname.

  • dns.resolveTlsa()

    Uses the DNS protocol to resolve certificate associations (TLSA records) for the hostname.

  • dns.resolveTxt()

    Uses the DNS protocol to resolve text queries (TXT records) for the hostname.

  • dns.reverse()

    Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of host names.

  • dns.setDefaultResultOrder()

    Set the default value of order in lookup and dnsPromises.lookup().

  • dns.setServers()

    Sets the IP address and port of servers to be used when performing DNS resolution.

Classes 1

Interfaces 26

Types 1

Variables 27

Namespaces 16

Other 1