Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/dns/resolve/index.md
6573 views
------{{AddonSidebar()}}
Resolves the given hostname to a DNS record.
This is an asynchronous function that returns a Promise.
Syntax
Parameters
hostname:
string. The hostname to resolve.
flags{{optional_inline}}:
arrayofstring. Flags to modify the way the hostname is resolved. Any omitted flags default tofalse. You can pass zero or more of the following flags:"allow_name_collisions": Allow name collision results which are normally filtered out."bypass_cache": Suppresses the internal DNS lookup cache."canonical_name": The canonical name of the specified host will be queried."disable_ipv4": Only IPv6 addresses will be returned."disable_ipv6": Only IPv4 addresses will be returned."disable_trr": Do not use the Trusted Recursive Resolver (TRR) for resolving the host name. A TRR enables resolving of host names using a dedicated DNS-over-HTTPS server."offline": Only literals and cached entries will be returned."priority_low": The request is given lower priority. If "priority_medium" is also given, the query is given medium priority."priority_medium": The request is given medium priority. If "priority_low" is also given, the query is given medium priority."speculate": Indicates that the request is speculative. Speculative requests return errors if prefetching is disabled by the browser's configuration.
Return value
A Promise that will be fulfilled with a DNSRecord object. This object can contain the following properties:
addresses:
arrayofstring. The IP addresses associated with this DNS record.
canonicalName:
string. The canonical name for this record. This is only included in the response if the"canonical_name"flag was passed toresolve().
isTRR:
boolean:trueif the record was retrieved using a Trusted Recursive Resolver (TRR).
Browser compatibility
{{Compat}}
Examples
Bypass the cache, and ask for the canonical name:
{{WebExtExamples}}