The dns.asyncresolver.Resolver Class

The async resolver is a subclass of dns.resolver.Resolver and has the same attributes. The methods are similar, but I/O methods like resolve() are asynchronous.

class dns.asyncresolver.Resolver(filename: str = '/etc/resolv.conf', configure: bool = True)[source]

Asynchronous DNS stub resolver.

filename, a str or file object, specifying a file in standard /etc/resolv.conf format. This parameter is meaningful only when configure is true and the platform is POSIX.

configure, a bool. If True (the default), the resolver instance is configured in the normal fashion for the operating system the resolver is running on. (I.e. by reading a /etc/resolv.conf file on POSIX systems and from the registry on Windows systems.)

async canonical_name(name: Union[, str])[source]

Determine the canonical name of name.

The canonical name is the name the resolver uses for queries after all CNAME and DNAME renamings have been applied.

name, a or str, the query name.

This method can raise any exception that resolve() can raise, other than dns.resolver.NoAnswer and dns.resolver.NXDOMAIN.

Returns a

async resolve(qname: Union[, str], rdtype: Union[dns.rdatatype.RdataType, str] = RdataType.A, rdclass: Union[dns.rdataclass.RdataClass, str] = RdataClass.IN, tcp: bool = False, source: Optional[str] = None, raise_on_no_answer: bool = True, source_port: int = 0, lifetime: Optional[float] = None, search: Optional[bool] = None, backend: Optional[dns._asyncbackend.Backend] = None) dns.resolver.Answer[source]

Query nameservers asynchronously to find the answer to the question.

backend, a dns.asyncbackend.Backend, or None. If None, the default, then dnspython will use the default backend.

See dns.resolver.Resolver.resolve() for the documentation of the other parameters, exceptions, and return type of this method.

async resolve_address(ipaddr: str, *args: Any, **kwargs: Any) dns.resolver.Answer[source]

Use an asynchronous resolver to run a reverse query for PTR records.

This utilizes the resolve() method to perform a PTR lookup on the specified IP address.

ipaddr, a str, the IPv4 or IPv6 address you want to get the PTR record for.

All other arguments that can be passed to the resolve() function except for rdtype and rdclass are also supported by this function.