Resolver Functions and The Default Resolver

dns.resolver.resolve(qname: Union[dns.name.Name, 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) dns.resolver.Answer[source]

Query nameservers to find the answer to the question.

This is a convenience function that uses the default resolver object to make the query.

See dns.resolver.Resolver.resolve for more information on the parameters.

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

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

See dns.resolver.Resolver.resolve_address for more information on the parameters.

dns.resolver.canonical_name(name: Union[dns.name.Name, str]) dns.name.Name[source]

Determine the canonical name of name.

See dns.resolver.Resolver.canonical_name for more information on the parameters and possible exceptions.

dns.resolver.zone_for_name(name: Union[dns.name.Name, str], rdclass: dns.rdataclass.RdataClass = RdataClass.IN, tcp: bool = False, resolver: Optional[dns.resolver.Resolver] = None, lifetime: Optional[float] = None) dns.name.Name[source]

Find the name of the zone which contains the specified name.

name, an absolute dns.name.Name or str, the query name.

rdclass, an int, the query class.

tcp, a bool. If True, use TCP to make the query.

resolver, a dns.resolver.Resolver or None, the resolver to use. If None, the default, then the default resolver is used.

lifetime, a float, the total time to allow for the queries needed to determine the zone. If None, the default, then only the individual query limits of the resolver apply.

Raises dns.resolver.NoRootSOA if there is no SOA RR at the DNS root. (This is only likely to happen if you’re using non-default root servers in your network and they are misconfigured.)

Raises dns.resolver.LifetimeTimeout if the answer could not be found in the allotted lifetime.

Returns a dns.name.Name.

dns.resolver.query(qname: Union[dns.name.Name, 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) dns.resolver.Answer[source]

Query nameservers to find the answer to the question.

This method calls resolve() with search=True, and is provided for backwards compatibility with prior versions of dnspython. See the documentation for the resolve() method for further details.

dns.resolver.default_resolver: Optional[dns.resolver.Resolver] = None

The default resolver.

dns.resolver.get_default_resolver() dns.resolver.Resolver[source]

Get the default resolver, initializing it if necessary.

dns.resolver.reset_default_resolver() None[source]

Re-initialize default resolver.

Note that the resolver configuration (i.e. /etc/resolv.conf on UNIX systems) will be re-read immediately.