skillfed

dnslib

Simple library to encode/decode DNS wire-format packets

dnslib v0.9.26 1.5M downloads/30d#3,837 on PyPI327
Permissive license BSD AGING released

What it is and what it does

dnslib is a pure-Python library for encoding and decoding DNS packets in wire format. It provides classes to represent DNS records, questions, and complete DNS packets, and can convert between wire format, Python objects, and textual representations (zone file and DiG formats). The library includes a server framework for building custom DNS resolvers and utilities for testing and proxying DNS traffic.

The package is in maintenance mode: the maintainer has decided to keep the existing API stable rather than pursue active development or modernization. It handles DNS packet parsing robustly (tested via fuzzing) and supports most standard DNS record types and operations defined in RFC1035. No runtime dependencies are required beyond Python itself.

Use it for:

  • Parse and inspect DNS packets captured from network traffic or test data for debugging and analysis.
  • Build custom DNS resolvers or mock DNS servers for testing applications that depend on DNS lookups.
  • Convert between DNS wire format and human-readable zone file or DiG format for inspection and manipulation.
  • Create DNS request and response packets programmatically for DNS client implementations or testing tools.
  • Implement DNS proxying or interception utilities for network monitoring or traffic redirection.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Encodes and decodes DNS wire-format packets, supporting creation of DNS requests and responses, and parsing of zone file and DiG formats.

Yes, if you need DNS packet encoding/decoding without external dependencies. The library is stable, permissively licensed, and has no known vulnerabilities. However, be aware it is in maintenance mode—no new features or API modernization are planned. It is suitable for production use in DNS tooling, testing, and custom resolver work, but do not expect active development or rapid responses to feature requests.

Install

dnslib on PyPI

pip

pip install dnslib

uv

uv add dnslib

poetry

poetry add dnslib

Installing dnslib

Before you install

Low install friction with a pure-Python wheel. Maintenance is in aging status; the maintainer has placed the package in maintenance mode, fixing minor bugs but not pursuing active development.

License in practice

BSD license permits commercial and private use with minimal restrictions, requiring only preservation of copyright and license notices.

Quickstart

import binascii
from dnslib import DNSRecord

packet = binascii.unhexlify(b'd5ad818000010005000000000377777706676f6f676c6503636f6d0000010001c00c0005000100000005000803777777016cc010c02c0001000100000005000442f95b68c02c0001000100000005000442f95b63c02c0001000100000005000442f95b67c02c0001000100000005000442f95b93')
d = DNSRecord.parse(packet)
print(d)

Verify before relying

  • Whether the package works with modern Python versions beyond those explicitly mentioned in the description
  • Performance characteristics when handling large numbers of DNS packets or complex zone files

Package facts

License BSD (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 529 days since the last release
Last repo commit
First released
Downloads 1,496,054/month — #3,837 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dnslib-0.9.26-py3-none-any.whl

Programming Language :: Python :: 2Programming Language :: Python :: 3Topic :: Internet :: Name Service (DNS)

Tags

DNS packet encoding decodingDNS wire format libraryDNS query response creationzone file parsingDNS resolver framework
dnsnetworkingpacket-parsing

More Name Service (DNS) packages