Skip to main content

Python asynchronous DNS client and server library.

Project description


Python asynchronous DNS client and server library. With async-dnspy clients you can make asynchronous DNS requests to any DNS server with raw DNS data. This gives you a chance to create your low level DNS query. You can even create invalid DNS query and test your DNS servers. Most important feature of async-dnspy is to make load testing on servers.

On the first release of async-dnspy TCP and UDP clients are available that connects, send and received response of raw DNS queries. There is already a decoder class that decodes raw data and creates you readable high level DNS message. It works on Python 3.5 or newer.

Online documentation is available on

With in next release TCP and UDP servers will be implemented.


From PyPI

$ pip install asyncdnspy

From source

Download the latest asyncdnspy library from:

Extract the source distribution and run:

$ python build
$ python install

Running Tests

The test suite can be run against a single Python version which requires pip install pytest and optionally pip install pytest-cov (these are included if you have installed dependencies from requirements.testing.txt)

To run the unit tests with a single Python version:

$ py.test tests -s -v

to also run code coverage:

$ py.test tests -s -v --cov-report html --cov=asyncdnspy

Getting the code

The code is hosted at Github.

Check out the latest development version anonymously with:

$ git clone
$ cd async-dnspy

Sample usage

I try to document as much as I can and unit tests have all the usages. Below you can find a single sample to get an idea how to TCP client to make a DNS A record query.

tcp_client = TCPClient('', 53)
dns_raw_message = DNSRawMessage()
data = dns_raw_message.query('', RecordType.a, SocketType.tcp)
_ = tcp_client.send(data)
response = tcp_client.receive()
dns_message = DNSMessageDecoder.decode(data, response, RecordType.a, SocketType.tcp)
ipv4_address = dns_message.answers[0].get_ipv4_address()


Contributions of any kind (bug fixes, new features…) are welcome! Please do open pull request with a clear description and adding unit tests.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for asyncdnspy, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size asyncdnspy-0.1.1-py3-none-any.whl (14.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page