chrome.dns

Description

Use the chrome.dns API for dns resolution.

Permissions

dns

Availability

Dev channel

To use this API, you must declare the "dns" permission in the manifest.

{
"name":"My extension",
...
"permissions":[
"dns"
],
...
}

Usage

The following code calls resolve() to retrieve the IP address of example.com.

service-worker.js:

constresolveDNS=async()=>{
letrecord=awaitchrome.dns.resolve('example.com');
console.log(record.address);// "192.0.2.172"
};
resolveDNS();

Types

ResolveCallbackResolveInfo

Properties

  • address

    string optional

    A string representing the IP address literal. Supplied only if resultCode indicates success.

  • resultCode

    number

    The result code. Zero indicates success.

Methods

resolve()

chrome.dns.resolve(
hostname: string,
)
: Promise<ResolveCallbackResolveInfo>

Resolves the given hostname or IP address literal.

Parameters

  • hostname

    string

    The hostname to resolve.

Returns

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年08月11日 UTC.