.github
stringToTTL: error when overflowing uint32 (#1698)
dnsutil
Fix typos (#1413)
.codecov.yml
Add codecov yaml to not fail the build (#600)
.gitignore
gitignore update
acceptfunc_test.go
Add a hook to catch invalid messages (#1568)
acceptfunc.go
Remove comment about checking zero bit. (#1491)
AUTHORS
add AUTHOR file
client_test.go
tests: skip unix socket tests for non *nix OSes (#1443)
client.go
fix Client xxxTimeout policy (#1700)
clientconfig_test.go
chore: don't use deprecated ioutil package (#1445)
clientconfig.go
Introduce a generic slice clone function (#1432)
CODEOWNERS
Add CODEOWNERS (#1042)
CONTRIBUTORS
Correctly set the Source IP to the received Destination IP (#524)
COPYRIGHT
Remove all copyright notices
dane.go
Improve performance by addressing some low hanging fruit. (#444)
defaults.go
IsDomainName: check for escape as last character (#1532)
dns_bench_test.go
ZoneParser: error on parsing an IPv6 address in an A record (#923)
dns_test.go
Improve IsFQDN performance (#1453)
dns.go
Fix Rdlength related parsing bug in RFC3597 records (#1214)
dnssec_keygen.go
Use ed25519 from Go standard lib (#1243)
dnssec_keyscan.go
Allow use of fs.FS for $INCLUDE and wrap errors (#1526)
dnssec_privkey.go
Use ed25519 from Go standard lib (#1243)
dnssec_test.go
MD5: remove keytag calculation (#1724)
dnssec.go
MD5: remove keytag calculation (#1724)
doc.go
Run gofmt -w -s *.go (#1408)
duplicate_generate.go
Tweaks (#1425)
duplicate_test.go
Implement SVCB (#1067)
duplicate.go
Doc updates (#1075)
dyn_test.go
Remove all copyright notices
edns_test.go
Add support for Compact Answers OK flag in EDNS (#1639)
edns.go
fix EDNS0 flags and MBZ in String() output (#1693)
example_test.go
Fix examples by using net.JoinHostPort (#1368)
format_test.go
Add checks on data length for A and AAAA records (#919)
format.go
Add checks on data length for A and AAAA records (#919)
fuzz_test.go
Spelling (#1222)
fuzz.go
Run gofmt -w -s *.go (#1408)
generate_test.go
chore: don't use deprecated ioutil package (#1445)
generate.go
Allow use of fs.FS for $INCLUDE and wrap errors (#1526)
go.mod
Bump golang.org/x/net from 0.57.0 to 0.58.0 in the all group (#1731)
go.sum
Bump golang.org/x/net from 0.57.0 to 0.58.0 in the all group (#1731)
hash.go
Add indentityHash for algos that don't need hashing (#1340)
issue_test.go
tests: reduce timeouts and iterations (#1175)
labels_test.go
CanonicalName should casefold non-US-ASCII chars (#1470)
labels.go
Remove space between NextLabel func and doc comment (#1410)
leak_test.go
Revert doh (#800)
length_test.go
Make the 900 number lower in this test (#1176)
LICENSE
Restructure license so Github will recognize it. (#1397)
listen_no_socket_options.go
Allow SO_REUSEADDR and SO_REUSEPORT to be set simultaneously (#1623)
listen_socket_options.go
Allow SO_REUSEADDR and SO_REUSEPORT to be set simultaneously (#1623)
Makefile.fuzz
Add fuzzing framework (#580)
Makefile.release
Spelling (#1222)
msg_generate.go
Annotate unpack* function errors with where the error happened. (#1590)
msg_helpers_test.go
Fix some lint checks by (go) staticcheck ./... (#1442)
msg_helpers.go
Avoid using a goto loop in unpackDataOpt (#1505)
msg_test.go
Add test for forward compression pointer (#1123)
msg_truncate_test.go
Fix typos (#1413)
msg_truncate.go
Update Truncate doc with compress behaviour (#1217)
msg.go
Make PackDomainName return error if the root label doesn't fit (#1702)
nsecx_test.go
Add a HashName benchmark
nsecx.go
Doc updates (#1075)
parse_test.go
fix(test): Increase RSA key length for sig0 (#1682)
privaterr_test.go
refactor: remove ParseZone and parseZone (#1099)
privaterr.go
Allow use of fs.FS for $INCLUDE and wrap errors (#1526)
README.md
Shorter v2 announcement
reverse.go
RFC 8490: Implement DSO type registry
rr_test.go
Eliminate lexer goroutines (#792)
sanitize_test.go
Tests updates (#556)
sanitize.go
Avoid calling RR.Header more than once per RR (#891)
scan_rr.go
Add RESINFO rr (#1641)
scan_test.go
Return error for empty target (#1627)
scan.go
stringToTTL: error when overflowing uint32 (#1698)
serve_mux_test.go
Rework and optimise ServeMux (#754)
serve_mux.go
answer queries with no matching handler with RcodeRefused (#1151)
server_test.go
Allow SO_REUSEADDR and SO_REUSEPORT to be set simultaneously (#1623)
server.go
MsgInvalidFunc: Make DefaultMsgInvalidFunc a variable. (#1690)
sig0_test.go
fix(test): Increase RSA key length for sig0 (#1682)
sig0.go
fix: input validation for RRSIG.Verify() (#1618)
smimea.go
Simplify and unify various returns (#893)
svcb_test.go
Add RFC 9540 oblivious services via service binding records (#1567)
svcb.go
Error: change a whole bunch error messages' prefix (#1657)
tlsa.go
Simplify and unify various returns (#893)
tmpdir_darwin_test.go
tests: skip unix socket tests for non *nix OSes (#1443)
tmpdir_test.go
tests: skip unix socket tests for non *nix OSes (#1443)
tsig_test.go
Make tsigGenerateProvider/TsigVerifyProvider public (#1382)
tsig.go
Make tsigGenerateProvider/TsigVerifyProvider public (#1382)
types_generate.go
Avoid using strings.Split (#1501)
types_test.go
Updates to LOC type RFC1876 (#1440)
types.go
RFC 8490: Implement DSO type registry
udp_no_control.go
Avoid sendmsg control messages on darwin (#1643)
udp_test.go
Run gofmt -w -s *.go (#1408)
udp.go
Avoid sendmsg control messages on darwin (#1643)
update_test.go
Use proper section names when producing dig-like output for UPDATEs (#1479)
update.go
Document how to create RRs without rdata (#1642)
version_test.go
Doc updates (#1075)
version.go
Release 1.1.73
xfr_test.go
Fix logic in xfr ReadMsg + add test (#1649)
xfr.go
Fix logic in xfr ReadMsg + add test (#1649)
zduplicate.go
Add RESINFO rr (#1641)
zmsg.go
Fix gogen diff
ztypes.go
Add RESINFO rr (#1641)

DNS version 2 is now available at https://codeberg.org/miekg/dns. This version should be 2x faster across the board. Further optimizations welcome.

The version here will only see specific fixes and nothing else. At some point this repo will be archived.

Alternative (more granular) approach to a 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. If there is stuff you should know as a DNS programmer there isn't a convenience function for it. Server side and client side programming is supported, i.e. you can build servers and resolvers with it.

We try to keep the "master" branch as sane as possible and at the bleeding edge of standards, avoiding breaking changes wherever reasonable. We support the last two versions of Go.

Goals

  • KISS;
  • Fast;
  • Small API. If it's easy to code in Go, don't make a function for it.

Users

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

Send pull request if you want to be listed here.

Features

  • UDP/TCP queries, IPv4 and IPv6
  • RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE (for all record types) are supported
  • Fast
  • Server side programming (mimicking the net/http package)
  • Client side programming
  • DNSSEC: signing, validating and key generation for DSA, RSA, ECDSA and Ed25519
  • EDNS0, NSID, Cookies
  • AXFR/IXFR
  • TSIG, SIG(0)
  • DNS over TLS (DoT): encrypted connection between client and server over TCP
  • DNS name compression

Have fun!

Miek Gieben - 2010-2012 - miek@miek.nl DNS Authors 2012-

Building

This library uses Go modules and uses semantic versioning. Building is done with the go tool, so the following should work:

go get github.com/miekg/dns
go build github.com/miekg/dns

Examples

A short "how to use the API" is at the beginning of doc.go (this also will show when you call godoc github.com/miekg/dns).

Example programs can be found in the github.com/miekg/exdns repository.

Supported RFCs

all of them

  • 103{4,5} - DNS standard
  • 1183 - ISDN, X25 and other deprecated records
  • 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 - there is no RRset type though, just []RR
  • 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 + validation functions
  • 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
  • 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 - edns-tcp-keepalive EDNS0 Option
  • 7553 - URI record
  • 7858 - DNS over TLS: Initiation and Performance Considerations
  • 7871 - EDNS0 Client Subnet
  • 7873 - Domain Name System (DNS) Cookies
  • 8080 - EdDSA for DNSSEC
  • 8490 - DNS Stateful Operations
  • 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)
  • 9460 - Service Binding and Parameter Specification via the DNS
  • 9461 - Service Binding Mapping for DNS Servers
  • 9462 - Discovery of Designated Resolvers
  • 9460 - SVCB and HTTPS Records
  • 9567 - DNS Error Reporting
  • 9606 - DNS Resolver Information
  • 9660 - DNS Zone Version (ZONEVERSION) Option
  • Draft - Compact Denial of Existence in DNSSEC

Loosely Based Upon