dnslib
Simple library to encode/decode DNS wire-format packets
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 dnslibuv
uv add dnslibpoetry
poetry add dnslibInstalling 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
Tags
More Name Service (DNS) packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
dnspythondnspython is a DNS toolkit that handles…
permissive · top 1,000 on PyPI
fqdnValidates fully-qualified domain names (FQDNs)…
copyleft · top 1,000 on PyPI
netaddrRepresents and manipulates IPv4, IPv6, MAC…
permissive · top 5,000 on PyPI
publicsuffix2Extracts the public suffix and registrable…
copyleft · top 5,000 on PyPI
publicsuffixlistParses the Public Suffix List to extract the…
copyleft · top 5,000 on PyPI
nslookupProvides high-level DNS lookups (A, AAAA, and…
copyleft · top 15,000 on PyPI
pycarespycares provides a Python interface to c-ares,…
permissive · top 5,000 on PyPI
xdrlib3Encodes and decodes XDR (External Data…
permissive · top 15,000 on PyPI
aws-cdk.aws-route53Provides Python constructs to define and manage…
permissive · top 15,000 on PyPI
aiodnsProvides asynchronous DNS resolution for…
permissive · top 5,000 on PyPI
dns-lexicondns-lexicon provides a unified Python interface…
permissive · top 15,000 on PyPI
mda-xdrlibProvides the xdrlib module for encoding and…
permissive · top 15,000 on PyPI
cbor2Encodes and decodes CBOR (Concise Binary Object…
permissive · top 1,000 on PyPI
google-cloud-dnsPython client library for Google Cloud DNS API…
permissive · top 15,000 on PyPI