HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
paulc
dnslib
Python2020–2022
paulc / dnslib

dnslib

A Python library to encode/decode DNS wire-format packets

3Distinct people
3Mentions
0Explicit recommenders
327GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A Python library to encode/decode DNS wire-format packets

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month3 dated mentions

Observed mentions: 2020-10-15 05:06:43 UTC to 2022-02-02 00:18:15 UTC.

012020-10-01 00:00:00 UTC to 2020-11-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsOct 20202020-11-01 00:00:00 UTC to 2020-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-12-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-01-01 00:00:00 UTC to 2021-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-02-01 00:00:00 UTC to 2021-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-03-01 00:00:00 UTC to 2021-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-04-01 00:00:00 UTC to 2021-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-05-01 00:00:00 UTC to 2021-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-06-01 00:00:00 UTC to 2021-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsJun 20212021-07-01 00:00:00 UTC to 2021-08-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-08-01 00:00:00 UTC to 2021-09-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-09-01 00:00:00 UTC to 2021-10-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-10-01 00:00:00 UTC to 2021-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-11-01 00:00:00 UTC to 2021-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-12-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2022-02-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022-02-01 00:00:00 UTC to 2022-03-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsFeb 2022

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Oct 20202020-10-01 00:00:00 UTC2020-11-01 00:00:00 UTC101
Nov 20202020-11-01 00:00:00 UTC2020-12-01 00:00:00 UTC000
Dec 20202020-12-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
Jan 20212021-01-01 00:00:00 UTC2021-02-01 00:00:00 UTC000
Feb 20212021-02-01 00:00:00 UTC2021-03-01 00:00:00 UTC000
Mar 20212021-03-01 00:00:00 UTC2021-04-01 00:00:00 UTC000
Apr 20212021-04-01 00:00:00 UTC2021-05-01 00:00:00 UTC000
May 20212021-05-01 00:00:00 UTC2021-06-01 00:00:00 UTC000
Jun 20212021-06-01 00:00:00 UTC2021-07-01 00:00:00 UTC000
Jul 20212021-07-01 00:00:00 UTC2021-08-01 00:00:00 UTC000
Aug 20212021-08-01 00:00:00 UTC2021-09-01 00:00:00 UTC000
Sep 20212021-09-01 00:00:00 UTC2021-10-01 00:00:00 UTC000
Oct 20212021-10-01 00:00:00 UTC2021-11-01 00:00:00 UTC000
Nov 20212021-11-01 00:00:00 UTC2021-12-01 00:00:00 UTC000
Dec 20212021-12-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
Jan 20222022-01-01 00:00:00 UTC2022-02-01 00:00:00 UTC101
Feb 20222022-02-01 00:00:00 UTC2022-03-01 00:00:00 UTC101

What Hacker News says

3 sources
Simple python version which does a bit more validation (checks response matches query) and also supports CNAMEs and different record types (37 lines - using dnslib library) - though there is still a lot of logic missing (handling failed NSs, IPv6 only NSs, cycles etc) from dnslib import DNSRecord,DNSError,QTYPE ROOT_NS='198.41.0.4' def find_cname(a,qtype,cname): for r in a.rr: if QTYPE[r.rtype] == qtype and r.rname == cname: return str(r.rdata) elif QTYPE[r.rtype] == 'CNAME' and r.rname == cname: return find_cname(a,qtype,str(r.rdata)) return resolve(str(r.rdata),qtype,ROOT_NS) def resolve(name,qtype='A',ns=ROOT_NS): print(f"dig -r @{ns} {name} {qtype}") q = DNSRecord.question(name,qtype) a = DNSRecord.parse(q.sen
Read the rest
d(ns)) if q.header.id != a.header.id: raise DNSError('Response transaction id does not match query transaction id') for r in a.rr: if QTYPE[r.rtype] == qtype and r.rname == name: return str(r.rdata) elif QTYPE[r.rtype] == 'CNAME' and r.rname == name: return find_cname(a,qtype,str(r.rdata)) for r in a.ar: if QTYPE[r.rtype] == 'A': return resolve(name,qtype,str(r.rdata)) for r in a.auth: if QTYPE[r.rtype] == 'NS': return resolve(name,qtype,resolve(str(r.rdata),'A',ROOT_NS)) raise ValueError("Cant resolve domain") if __name__ == '__main__': import sys def get_arg(i,d): try: return sys.argv[i] except IndexError: return d print(resolve(get_arg(1,"google.com"), get_arg(2,"A"), get_arg(3,ROOT_NS))) Disclaimer: I am author of dnslib [https://github.com/paulc/dnslib] Edit: Better CNAME support
In A toy DNS resolver
Have you ever wanted to build a toy nameserver that returns funny programmatic results? Then have a look at Python’s dnslib. Example where the magic happens in ~40 lines of code: https://github.com/paulc/dnslib/blob/master/dnslib/shellreso... Hurricane Electric can sit in front of it if you like (and your records are dynamically generated but bounded to a known finite set), god bless them <salute>: https://dns.he.net/ Example where you might want this: you wrote a nameserver that runs arbitrary shell commands!
In Why might you run your own DNS server?

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.