6
85
Fork
You've already forked dns
39
  • Go 99.8%
  • Makefile 0.2%
2026年07月07日 10:26:57 +02:00
.forgejo/workflows remove fuzzing; too much power 2026年06月08日 13:09:26 +02:00
_doc Adding some hostname comparison functions to the v1-to-v2 doc. 2026年03月20日 08:49:54 +00:00
cmd chore: go generate 2026年06月23日 20:14:38 +02:00
deleg document deleg/svcb Parse 2026年07月03日 06:41:20 +02:00
dnsconf dnsconf: few fixes 2026年04月05日 15:10:20 +02:00
dnshttp Use existing test 2026年05月17日 16:43:41 +02:00
dnstest doc fix 2026年06月30日 11:09:41 +02:00
dnsutil docs 2026年07月07日 10:07:20 +02:00
internal pack: cant take compression shortcut 2026年06月08日 14:11:35 +02:00
pkg/pool Add pool.NewBuilder 2026年02月19日 07:47:10 +01:00
rdata docs tweak 2026年06月24日 07:21:30 +02:00
svcb document deleg/svcb Parse 2026年07月03日 06:41:20 +02:00
testdata zonemd: sign root zone 2025年11月04日 17:38:28 +01:00
.changelog.go.tmpl typo in changelog 2025年10月03日 18:35:01 +02:00
.gitattributes Remove generated attribute from non-generated file 2026年05月15日 21:52:54 -05:00
bench_test.go Fix broken things after moving UnpackName to unpack.Name 2025年08月30日 14:11:28 +02:00
CHANGELOG.md documentation 2026年01月06日 09:17:43 +01:00
ci_test.go Add ci check for fmt.Printf 2026年01月16日 13:47:58 +01:00
client.go Update comments on client.Exchange to refer to Msg.UDPSize rather than Msg.Bufsize. 2026年03月26日 17:43:02 +00:00
client_test.go doc: add client example for adding edns0 options 2026年01月18日 12:05:32 +01:00
clone_generate.go Add Data() method on RR 2026年01月28日 21:50:12 +01:00
compare_generate.go Merge pull request 'Use cmp.Compare to avoid converting everything to int' ( #836 ) from miek/26/mrt15zo/08 into main 2026年03月15日 09:34:30 +01:00
CONTRIBUTORS First code dump 2025年08月06日 08:11:49 +02:00
cookbook_test.go Added a couple of examples of fairly easy and common tasks 2026年02月27日 22:05:33 +01:00
COPYRIGHT Fix copyright 2025年09月04日 13:49:40 +02:00
dane.go Un-export CertificateToDANE 2025年08月16日 12:43:33 +02:00
dns.go rdata: correct error message 2026年03月07日 15:13:12 +01:00
dnssec.go typo 2026年06月25日 15:55:40 +02:00
dnssec_keygen.go doc improv. 2026年03月06日 09:18:44 +01:00
dnssec_keyscan.go doc improv. 2026年03月06日 09:18:44 +01:00
dnssec_privkey.go golanglint-ci: run it again 2025年12月14日 13:36:37 +01:00
dnssec_signer.go dnssec sign/verify: propagate error to caller 2026年04月01日 10:02:48 +02:00
dnssec_test.go remove md5 keytag test 2026年06月21日 15:34:39 +02:00
dnstest_generate.go Docs and clean up of comments 2025年10月06日 16:13:59 +02:00
dnsutil_generate.go Cleanup the signer code 2026年03月06日 07:51:52 +01:00
doc.go docs tweak 2026年06月24日 07:21:30 +02:00
dso_types.go Add Data() method on RR 2026年01月28日 21:50:12 +01:00
dsolen_generate.go dso: finish remaining types 2025年11月10日 06:57:44 +01:00
dsorr_generate.go Generate compare functions 2025年08月23日 09:42:16 +02:00
edns_types.go add EDE descriptions for Rate Limited, Over Quota and Negative Trust Anchor 2026年06月26日 14:59:04 +02:00
edns_types_test.go Finish PADDING EDNS0 option 2026年02月08日 19:03:42 +01:00
ednsrr_generate.go add EDNS0 unknown option code 2026年02月13日 16:48:06 +01:00
errors.go Cleanup the signer code 2026年03月06日 07:51:52 +01:00
generate.go DefaultMsgSize is now 1400 2026年02月28日 16:08:47 +01:00
go.mod Deps upgrade 2026年02月26日 11:12:50 +01:00
go.sum Deps upgrade 2026年02月26日 11:12:50 +01:00
headerpack.go Fix off-by-one in headerpack. 2026年04月01日 09:42:37 +02:00
len_generate.go Introduce RDATA next to RR 2025年12月12日 18:06:28 +01:00
LICENSE add status to the readme 2025年08月18日 07:28:14 +02:00
listen_no_socket_options.go Reapply "udp: use static buffers" 2025年12月15日 06:59:20 +01:00
listen_socket_options.go Reapply "udp: use static buffers" 2025年12月15日 06:59:20 +01:00
Makefile.release Release 0.6.9 2025年12月21日 10:57:56 +01:00
msg.go zodan 2026年03月10日 10:20:42 +01:00
msg_generate.go scan: generate SOA scan too 2026年03月15日 08:18:10 +01:00
msg_test.go Fix EDE ExtraText serialization 2026年05月15日 21:52:54 -05:00
nsecpack.go Run internal/analysis/modernize/cmd/modernize 2025年10月15日 09:03:57 +02:00
opt.go Govet changes 2026年03月08日 07:18:03 +01:00
optpack.go Implement the rest 2026年02月13日 17:00:29 +01:00
pack_generate.go Do cryptobyte conversion once 2026年02月21日 14:30:06 +01:00
parse_generate.go Remove type assertions 2026年02月05日 13:11:11 +01:00
parse_test.go add EDNS0 unknown option code 2026年02月13日 16:48:06 +01:00
rdata_generate.go Finishing touches on the whole thing 2026年01月29日 16:07:25 +01:00
rdata_test.go Remove cookbook.md in favor of adding example tests or doc comments on the correct types 2026年01月30日 13:45:50 +01:00
README.md README: add DNSieve to Users section 2026年05月10日 18:01:02 -06:00
response.go Finish unix domain socket support 2026年02月14日 14:16:37 +01:00
reverse.go Can have example functions on variables 2026年01月30日 14:37:02 +01:00
router Add zerr.go 2025年09月14日 08:26:44 +02:00
rr_generate.go Documentation updates 2026年02月21日 15:40:49 +01:00
rr_test.go fix yoopt 2026年01月29日 07:40:48 +01:00
scan.go ttl: use uint64 2026年06月03日 09:38:19 +02:00
scan_ednsrr.go Docs 2026年02月24日 07:19:33 +01:00
scan_generate.go scan: generate SOA scan too 2026年03月15日 08:18:10 +01:00
scan_rdata.go scan: generate SOA scan too 2026年03月15日 08:18:10 +01:00
scan_rr.go no pooling 2026年02月28日 08:12:04 +01:00
scan_test.go Add Unwrap() to dns.Error for errors.Is() support with Fmt()-wrapped sentinels 2026年02月19日 23:17:25 +02:00
serve_mux.go docs 2025年12月12日 08:08:54 +01:00
serve_mux_test.go Skip reflect perf testing by default 2025年08月17日 12:06:55 +02:00
server.go server: use same opcode as request on MsgReject* replies 2026年05月20日 13:28:10 -03:00
server_no_recvmmsg.go dns: server slight cleanups 2026年02月19日 07:43:11 +01:00
server_recvmmsg.go Use 1 slab of continuous memory 2026年02月19日 11:12:14 +01:00
server_test.go atomdns: allow listening on unix socket 2026年02月14日 13:04:23 +01:00
sig0.go Create setArcount 2026年02月22日 18:22:35 +01:00
sig0_signer.go More msg_helpers.go to internal/{un,}pack 2025年09月01日 20:22:45 +02:00
smimea.go Remove t from Header 2025年11月24日 16:22:48 +01:00
sort.go Make Prev/Next the same 2026年06月23日 06:43:34 +02:00
sort_rdata.go Move pool to pkg/pool 2026年01月09日 15:58:02 +01:00
sort_test.go Make Prev/Next the same 2026年06月23日 06:43:34 +02:00
string.go Add pool.NewBuilder 2026年02月19日 07:47:10 +01:00
tlsa.go Remove t from Header 2025年11月24日 16:22:48 +01:00
transfer.go Wrap errors using fmt.Errorf %w 2026年02月21日 16:02:54 +01:00
transfer_test.go test(ixfr): remove unexpected close of ResponseWriter 2026年02月06日 09:45:05 +01:00
transport.go Spellcheck from go report card 2026年01月30日 17:36:14 +01:00
tsig.go Create setArcount 2026年02月22日 18:22:35 +01:00
tsig_signer.go struct tags: domain-name -> name 2026年03月05日 08:27:27 +01:00
tsig_test.go Fix edns/tsig Extra and Pseudo section 2026年02月22日 17:51:07 +01:00
types.go Replace 4 16 bits with one 64 bit one 2026年02月22日 12:16:18 +01:00
types_test.go Add nxdomain example 2025年12月05日 16:10:02 +01:00
udp.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
udp_darwin.go Migrate from net.IP to netip.Addr 2025年12月10日 12:15:39 -08:00
udp_no_control.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
udp_session.go very minor cleanups 2026年03月07日 18:10:44 +01:00
udp_unix.go udp: optimize for IPv4, set control flags on darwin. 2025年09月15日 10:40:02 -07:00
update_test.go Add dynamic updates msg examples 2026年02月20日 21:48:11 +01:00
version.go Release 0.6.83 2026年06月26日 07:46:49 +02:00
zclone.go Add UPDATE-LEASE EDNS(0) resource record 2026年05月17日 15:45:19 -05:00
zcompare.go Make Prev/Next the same 2026年06月23日 06:43:34 +02:00
zdnstest.go Go gen + docs 2025年09月24日 13:24:39 +02:00
zdnsutil.go Make Prev/Next the same 2026年06月23日 06:43:34 +02:00
zdsolen.go dso: finish remaining types 2025年11月10日 06:57:44 +01:00
zdsorr.go dns: more dso types 2025年11月09日 19:43:26 +01:00
zednspack.go Add UPDATE-LEASE EDNS(0) resource record 2026年05月17日 15:45:19 -05:00
zednsrr.go Add UPDATE-LEASE EDNS(0) resource record 2026年05月17日 15:45:19 -05:00
zlen.go Introduce RDATA next to RR 2025年12月12日 18:06:28 +01:00
zmsg.go Be properly compliant 2026年03月05日 09:09:31 +01:00
zonemd.go Documentation 2026年02月19日 09:52:41 +01:00
zonemd_test.go Unknown types can be packed/unpacked 2025年12月03日 12:52:46 +01:00
zpack.go Perf: OPT/TSIG are popular too 2026年02月23日 15:30:04 +01:00
zparse.go Perf: OPT/TSIG are popular too 2026年02月23日 15:30:04 +01:00
zrdata.go Rename DELEGI to DELEGPARAM 2026年02月05日 17:35:45 +01:00
zrr.go Perf: OPT/TSIG are popular too 2026年02月23日 15:30:04 +01:00
zscan_rdata.go scan: generate SOA scan too 2026年03月15日 08:18:10 +01:00

Go Doc Build Status

Modern, lightweight DNS library

Less is more.

Complete and usable DNS library. All Resource Records are supported, including the DNSSEC types. It follows a lean and mean philosophy. Server side and client side programming is supported, i.e. you can build servers and resolvers with it.

Many convenience functions are included in dns, dnstest or otherwise in dnsutils. The RR's resource data (RDATA) is split off into its own package: rdata. This means accessing the RR's header and rdata is much simpler now. 1

We try to keep the "main" branch as sane as possible and at the bleeding edge of standards, avoiding breaking changes wherever reasonable. But because this version is young, we allow ourselves some more headroom for making backwards incompatible changes.

Example programs are included and benchmarked in cmd. cmd/atomdns is a full blown production ready name server. Because of these we are depending on a lot more external packages - at some point these servers will be split off.

This new version will not soon see a v1.0.0 release because I want to be able to still make changes. In a year or two (2028?) when things have stabilized it will be blessed with a v1.0.0.

Porting From v1

Everything from https://github.com/miekg/dns works. See README-v1-to-v2.md for the differences, if you are porting your application, in cookbook.go are some common recipes.

Performance

The performance should be roughly 2x across the board compared to v1 (also see below).

  • Serving DNS queries per second is ~2x (maybe more).
  • Parsing zones files in RRs per second is ~1.5x.
  • Memory usage can be ~0.5x due to rdata split off.

For developers please read the developer README.

Goals

  • KISS.
  • Everything is a resource record, EDNS0 pseudo RRs included.
    • Easy way to access RR's header and resource data (rdata).
  • Small API.
    • Package dnsutil contains functions that help programmers, but are not necessarily in scope the dns package.
    • Package dnstest contains functions and types that help you test, similar to the httptest package.
    • Package svcb holds all details of the SVCB/HTTPS record.
    • Pacakge deleg holds details for the DELEG record.
    • Many helper/debug functions are moved into internal packages, making the top-level much, much cleaner.
  • Fast.
    • recvmmsg(2) and TCP pipe=lining support.
    • The cmd/reflect server does ~420K/340K qps UDP/TCP respectively on the right hardware.
      • Since a46996c I can get ~400K (UDP) qps on my laptop (M2/Asahi Linux), also see 1766e44, 86b53fe and 06e5e0f.
      • On my Dell XPS 17 (Intel) it is similar-ish (~310K/250K qps UDP/TCP).
      • On other Intel/AMD hardware it is lower (~200K (UDP) qps) - yet to understand why.
    • See cmd/reflect and do a go build; make new.txt to redo the performance test. Requires dnsperf to be installed.
    • The SE zone (8M RRs) is parsed in ~11s (~730K RR/s), the CH zones (15M RRs) is parsed in ~14s (~1M RR/s). The main difference being that SE use algorithm 8, and CH algorithm 13 (shorter RRSIGs). See cmd/parse, tested with M2/Asahi Linux.

Users

A not-so-up-to-date-list-that-may-be-actually-current:

  • atomdns - included in cmd/atomdns - a high performance DNS server, based on the principles of CoreDNS, but faster and simpler.
  • dnscrypt-proxy - a flexible DNS proxy, with support for encrypted DNS protocols such as DNSCrypt v2, DOH, Anonymized DNSCrypt and ODOH.
  • DNSControl - DNSControl is an opinionated platform for seamlessly managing your DNS configuration across any number of DNS hosts, both in the cloud or in your own infrastructure.
  • Gonemaster - Gonemaster is a Go implementation of the DNS test framework Zonemaster engine and CLI.
  • DNSieve - a DNS filtering proxy that fans out queries to multiple upstream resolvers concurrently and enforces block-consensus.

Send pull request if you want to be listed here.

Comments

What users say:

miekg/dns is probably my favorite Go module in the open source ecosystem. It is very complete (every DNS rtype is defined) and strict (field names match the RFCs, etc). DNSControl has used miekg/dns since the first release.

Your library is a blast and I cannot thank you enough 🙏.

Features

  • UDP/TCP queries, recvmmsg(2), TCP query-pipelining, IPv4 and IPv6.
  • Fast.
  • RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE - for all record types) is supported.
  • Server side programming (mimicking the net/http package), with dns.Handle and dns.HandleFunc allowing for middleware servers.
  • Client side programming.
  • DNSSEC: signing, validating and key generation for DSA, RSA, ECDSA and Ed25519.
  • EDNS0, NSID, Cookies, etc, as pseudo RRs in the (fake) pseudo section.
  • AXFR/IXFR.
  • TSIG, SIG(0).
  • DNS over TLS (DOT): encrypted connection between client and server over TCP.
  • DNS over HTTP (DOH), see the dnshttp package.
  • Improved naming by embracing sub-packages.
  • Improved RRs, by having the rdata specified in an rdata package.
  • Examples included the cmd/ directory.
  • Escapes (\DDD and \x) in domain names is not supported (anymore) - the overhead (50-100%) was too high.
  • Easy way for custom RRs and EDNS0 pseudo RRs.

Have fun!

Miek Gieben - 2026- - miek@miek.nl

See anonymous users asking for support on why these kind of requests/issues usually get closed pretty swiftly.

Building/developing

This library uses Go modules and uses semantic versioning. Getting the code and working with the library is done via:

git clone git@codeberg.org:miekg/dns # use https if you don't have a codeberg account
cd dns
# $EDTIOR *.go

If you want to use codeberg/miekg/dns in your own project, just do a go get codeberg.org/miekg/dns@latest and import codeberg.org/miekg/dns in your Go files.

Examples

A short "how to use the API" is at the beginning of doc.go. The cmd/ directory contains a reflect example program that is used for benchmarking, and further has atomdns which is full fledged DNS server that is developed in tandem with the library.

Supported RFCs

all of them and then some

  • 103{4,5} - DNS standard
  • 1348 - NSAP record (removed the record)
  • 1982 - Serial Arithmetic
  • 1876 - LOC record
  • 1995 - IXFR
  • 1996 - DNS notify
  • 2136 - DNS Update (dynamic updates)
  • 2181 - RRset definition
  • 2537 - RSAMD5 DNS keys
  • 2065 - DNSSEC (updated in later RFCs)
  • 2671 - EDNS record
  • 2782 - SRV record
  • 2845 - TSIG record
  • 2915 - NAPTR record
  • 2929 - DNS IANA Considerations
  • 3110 - RSASHA1 DNS keys
  • 3123 - APL record
  • 3225 - DO bit (DNSSEC OK)
  • 340{1,2,3} - NAPTR record
  • 3445 - Limiting the scope of (DNS)KEY
  • 3596 - AAAA record
  • 3597 - Unknown RRs
  • 4025 - A Method for Storing IPsec Keying Material in DNS
  • 403{3,4,5} - DNSSEC
  • 4255 - SSHFP record
  • 4343 - Case insensitivity
  • 4408 - SPF record
  • 4509 - SHA256 Hash in DS
  • 4592 - Wildcards in the DNS
  • 4635 - HMAC SHA TSIG
  • 4701 - DHCID
  • 4892 - id.server
  • 5001 - NSID
  • 5155 - NSEC3 record
  • 5205 - HIP record
  • 5702 - SHA2 in the DNS
  • 5936 - AXFR
  • 5966 - TCP implementation recommendations
  • 6605 - ECDSA
  • 6672 - DNAME
  • 6725 - IANA Registry Update
  • 6742 - ILNP DNS
  • 6840 - Clarifications and Implementation Notes for DNS Security
  • 6844 - CAA record
  • 6891 - EDNS0 update
  • 6895 - DNS IANA considerations
  • 6944 - DNSSEC DNSKEY Algorithm Status
  • 6975 - Algorithm Understanding in DNSSEC
  • 7043 - EUI48/EUI64 records
  • 7314 - DNS (EDNS) EXPIRE Option
  • 7477 - CSYNC RR
  • 7828 - TCP-keepalive EDNS0 Option
  • 7553 - URI record
  • 7719 - DNS Terminology
  • 7858 - DNS over TLS: Initiation and Performance Considerations
  • 7871 - EDNS0 Client Subnet
  • 7873 - Domain Name System (DNS) Cookies
  • 8080 - EdDSA for DNSSEC
  • 8482 - Minimal Answers for ANY
  • 8484 - DOH
  • 8499 - DNS Terminology
  • 8659 - DNS Certification Authority Authorization (CAA) Resource Record
  • 8777 - DNS Reverse IP Automatic Multicast Tunneling (AMT) Discovery
  • 8914 - Extended DNS Errors
  • 8976 - Message Digest for DNS Zones (ZONEMD RR)
  • 9250 - DOQ (not implemented, waiting until Go supports QUIC)
  • 9461 - Service Binding Mapping for DNS Servers
  • 9462 - Discovery of Designated Resolvers
  • 9460 - SVCB and HTTPS Records
  • 9499 - DNS Terminology
  • 9567 - DNS Error Reporting
  • 9606 - DNS Resolver Information
  • 9660 - Zone version
  • 9715 - IP Fragmentation Avoidance in DNS over UDP
  • 9859 - DSYNC RR
  • draft-ietf-compact-denial - CO bit
  • draft-ietf-deleg - DELEG RR

  1. A function is put in dnsutils, unless (due to cyclic imports) it is utterly impossible to put it there. Only then it is put in the main dns package. ↩︎