On this page

    dns.resolve(hostname, rrtype?, callback): void
    Attributes
    hostname:string
    Host name to resolve.
    rrtype?:string
    Resource record type. Default: 'A'.
    callback:Function
    err:Error
    records:string[] | Object[] | Object

    Uses the DNS protocol to resolve a host name (e.g. 'nodejs.org') into an array of the resource records. The callback function has arguments (err, records). When successful, records will be an array of resource records. The type and structure of individual results varies based on rrtype:

    rrtyperecords containsResult typeShorthand method
    'A'IPv4 addresses (default)stringdns.resolve4()
    'AAAA'IPv6 addressesstringdns.resolve6()
    'ANY'any recordsObjectdns.resolveAny()
    'CAA'CA authorization recordsObjectdns.resolveCaa()
    'CNAME'canonical name recordsstringdns.resolveCname()
    'MX'mail exchange recordsObjectdns.resolveMx()
    'NAPTR'name authority pointer recordsObjectdns.resolveNaptr()
    'NS'name server recordsstringdns.resolveNs()
    'PTR'pointer recordsstringdns.resolvePtr()
    'SOA'start of authority recordsObjectdns.resolveSoa()
    'SRV'service recordsObjectdns.resolveSrv()
    'TLSA'certificate associationsObjectdns.resolveTlsa()
    'TXT'text recordsstring[]dns.resolveTxt()

    On error, err is an Error object, where err.code is one of the DNS error codes.