An interface to GNU adns - python3 port

pip install adns==1.4-py1


Build Instructions

First, you gotta have the adns_ libraries installed somewhere. Maybe
your OS vendor has it packaged already.

.. _adns:

For adns-python-1.2.0 and newer, you *must* have at least adns-1.2.

Second, you gotta have Distutils_, which comes in Python 1.6 and up. If you
have Python 1.5.2, *upgrade already*!

.. _Distutils:

Then, you can build and install::

    $ python build
    # python install # this is as root; use su or sudo

Other useful things::

    $ python bdist # make a binary distribution
    $ python bdist_rpm # make an RPM

RTFM for Distutils for more options.


See the included test programs for examples. A simple interactive
example that uses synchronous queries::

    >>> import adns
    >>> s=adns.init()
    >>> s.synchronous('',adns.rr.MX)
    (0, None, 1107034862, ((50, ('', 0,
    ((2, ''),))),))

Results are generally returned as a 4-tuple: status, CNAME, expires, answer

status is the adns status, enumerated in adns.status.

CNAME is the CNAME of the answer, if any (None if the query target is not a

expires is the time (in ticks) that the answer's TTL expires.

answer is what you really want. Since queries generally can return more than
one answer, answer is returned as an n-tuple. The format of each item in the
tuple depends on what type of RR was requested.::

    >>> s.synchronous('',adns.rr.MXraw)
    (0, None, 1107034862, ((50, ''),))

In this case, MXraw returns only the MX data (priority and hostname). MX
does further expansions upon the hostname, returning a tuple of hostname,
status for the following data, and then a tuple of rr.ADDR answers, which
are the address class and the IP address, i.e.::

    >>> s.synchronous('',adns.rr.ADDR)
    (0, None, 1107034862, ((2, ''),))

and compare to::

    >>> s.synchronous('',adns.rr.A)
    (0, None, 1107034862, ('',))

Prefer to use exceptions to processing status codes? adns.exception(status)
will raise an appropriate exception. Sometimes you need to have the result,
even when there is an exceptional condition. The exceptions are:

* Error

  * NotReadyError
  * LocalError
  * RemoteError

    * RemoteConfigError
    * RemoteFailureError
    * RemoteTempError

  * QueryError
  * PermanentError

    * NXDomain
    * NoData

For asynchronous examples, see,, and is very outdated in terms of actual working blacklists,
but may still be instructive.

adns-python-1.2.0 and newer *requires* at least adns-1.2. For adns-1.1
and older, use adns-python-1.1.1.

	Andy Dustman <>
	January 27, 2007