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='/etc/resolv.conf', configure=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.)


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

resolve(qname, rdtype=<RdataType.A: 1>, rdclass=<RdataClass.IN: 1>, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None, search=None, backend=None)[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.

resolve_address(ipaddr, *args, **kwargs)[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.