Resolver Functions and The Default Resolver

dns.resolver.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)[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, *args, **kwargs)[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)[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, rdclass=<RdataClass.IN: 1>, tcp=False, resolver=None)[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 resolver is used.

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.)

Returns a dns.name.Name.

dns.resolver.query(qname, rdtype=<RdataType.A: 1>, rdclass=<RdataClass.IN: 1>, tcp=False, source=None, raise_on_no_answer=True, source_port=0, lifetime=None)[source]

Query nameservers to find the answer to the question.

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

dns.resolver.default_resolver = None

The default resolver.

dns.resolver.get_default_resolver()[source]

Get the default resolver, initializing it if necessary.

dns.resolver.reset_default_resolver()[source]

Re-initialize default resolver.

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