dns

A low-level, spec-complete DNS library for Go covering client, server, DNSSEC, and zone-file parsing.

Library
Go
vv1.1.73
8,789 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
65 /100 Good
Development Activity 56
Maintenance 16
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 85
Code Quality 88
Innovation 78
Learning Curve 65

github.com/miekg/dns is a complete, from-scratch DNS library for Go that supports both client- and server-side programming. Every standard resource record type is implemented as a native Go struct rather than stored in raw wire format, and the server API deliberately mirrors net/http — you register a Handler and call ListenAndServe — so building a DNS resolver or authoritative nameserver feels familiar to any Go developer.

Beyond basic query/response handling, the library covers the DNS ecosystem in depth: DNSSEC signing, validation, and key generation (RSA, ECDSA, Ed25519), AXFR/IXFR zone transfers, TSIG and SIG(0) message authentication, EDNS0 options (NSID, Cookies, Client Subnet), and DNS-over-TLS. It’s the DNS engine behind projects like CoreDNS, HashiCorp Consul, and dnscontrol, and while a faster v2 rewrite is now developed separately on Codeberg, this v1 package continues to receive fixes and remains one of the most widely used DNS libraries in the Go ecosystem.

What You Get

  • Native Go types for every DNS resource record, including all DNSSEC record types
  • A net/http-style server API (Handler, HandlerFunc, ListenAndServe) for building authoritative or forwarding nameservers
  • A full DNSSEC toolkit: zone signing, validation, and key generation for RSA, ECDSA, and Ed25519
  • Zone file parsing with support for $INCLUDE, $ORIGIN, $TTL, and $GENERATE directives
  • Built-in support for AXFR/IXFR transfers, TSIG/SIG(0) authentication, and DNS-over-TLS

Common Use Cases

  • Writing a custom authoritative or caching DNS server in Go
  • Programmatically querying and parsing DNS records from a Go application
  • Signing and validating DNSSEC zones as part of a DNS management pipeline
  • Building DNS-aware network tooling such as service discovery, load balancers, or security scanners
  • Parsing and generating BIND-style zone files

Under The Hood

Architecture

The library is organized as a flat, single-package layered design: types.go and the generated zmsg.go/ztypes.go (produced by msg_generate.go, which walks struct tags via go/types and code-generates Pack/Unpack methods) define every resource record as a native Go struct with wire (de)serialization baked in at compile time; msg.go implements the Msg envelope (header, question, answer, authority, additional sections) and its own Pack/Unpack logic on top of those RR types; client.go and server.go sit above that as thin transport layers — server.go’s Handler/HandlerFunc/ServeMux (in serve_mux.go, guarded by a sync.RWMutex for concurrent registration and lookup) deliberately mirror net/http’s handler contract, while dnssec.go, tsig.go, sig0.go, and xfr.go are separate, optional layers for signing/validation, message authentication, and zone transfers that depend on the core message types but not on each other. Changing the core RR interface or the generated Pack/Unpack contract would ripple through every record-type file and the code generator itself, but the transport and security layers stay cleanly separable from that core.

Tech Stack

Written in Go 1.25 with an unusually small dependency surface — go.mod declares only three direct requirements (golang.org/x/net, golang.org/x/sync, golang.org/x/sys), plus golang.org/x/tools and golang.org/x/mod as generate-time-only tool dependencies, so the runtime footprint is close to Go’s standard library alone. There’s no external database, ORM, or web framework involved — it’s a systems-level networking package covering UDP/TCP/DNS-over-TLS transport via net and crypto/tls, with go generate (msg_generate.go) as the only build step beyond go build. CI runs via GitHub Actions (a standard Go test workflow plus a CodeQL static-analysis workflow), and a fuzzing target (fuzz.go, gated behind a fuzz build tag) exercises the Msg Pack/Unpack round trip.

Code Quality

Testing uses Go’s standard testing package exclusively (no third-party assertion library) across dozens of _test.go files totaling roughly 294 Test functions, plus a dedicated example_test.go of runnable documentation examples and a fuzz target for the wire-format parser — a strong signal of care for a library whose core risk surface is untrusted-input parsing. Error handling is explicit and typed: a package-level Error type backs sentinel values like ErrShortRead, and parse failures are wrapped with fmt.Errorf(”…: %w”, err) rather than swallowed or logged silently. Naming is idiomatic Go, the generated files (zmsg.go, ztypes.go, zduplicate.go) are clearly marked as such and checked in rather than built on the fly, and CI runs both tests and static analysis on every change.

What Makes It Unique

The API’s central design choice is treating every DNS resource record as a native, typed Go struct instead of exposing raw wire bytes, combined with a net/http-shaped server contract (Handler, HandlerFunc, ListenAndServe) — so a Go developer already familiar with net/http can write a DNS server with almost no new mental model. Getting started is a single dns.NewRR(…) call or a few struct-literal field assignments, and the same Msg type serves both client queries and server responses. This isn’t algorithmically novel — it’s a faithful, complete implementation of a decades-old protocol — but generating typed RRs and Pack/Unpack methods from struct tags rather than hand-writing or reflecting them at runtime is a deliberate, well-executed engineering tradeoff that keeps the public API both exhaustive and fast.

Used by 16 apps in this directory

Go
48%
GPL 3.0

Netdata

Devops · Monitoring

81,111

Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.

View details
93
Repo Health
86
Technical
70
Dependency
Built with
Go 48%
C 29%
Rust 15%
Updated 6 days ago
Python
39%
Apache 2.0

OpenSandbox

Developer Tools · Security

16,116

Secure, fast, and extensible sandbox runtime for AI agents with multi-language SDKs and Docker/Kubernetes runtimes.

View details
85
Repo Health
81
Technical
70
Dependency
Built with
Python 39%
Go 36%
Updated 6 days ago
Go
85%
MIT

Statusnook

Monitoring

988

Deploy a self-hosted status page with endpoint monitoring and automatic HTTPS in minutes, with no external dependencies required.

View details
35
Repo Health
49
Technical
73
Dependency
Built with
Go 85%
CSS 10%
Updated 1 years ago
Go
90%
BSD 3

tau

Devops

5,180

Open-source, Git-native platform-as-a-service for building, deploying, and scaling fullstack apps on your own infrastructure with no DevOps required.

View details
71
Repo Health
82
Technical
65
Dependency
Built with
Go 90%
Updated 2 months ago
Go
94%
MIT

Traefik

Automation · Devops · Security

65,344

A cloud-native reverse proxy and load balancer that auto-configures itself from Docker, Kubernetes, and other orchestrators — zero manual routing required.

View details
93
Repo Health
85
Technical
64
Dependency
Built with
Go 94%
Updated 1 weeks ago
Go
98%
Other

Tyk API Gateway

Developer Tools · Devops

10,869

Cloud-native, high-performance open-source API gateway for REST, GraphQL, gRPC, and TCP — built in Go since 2014 with no feature lockout.

View details
97
Repo Health
78
Technical
67
Dependency
Built with
Go 98%
Updated 1 weeks ago
Go
86%
Apache 2.0

Uncloud

Devops

5,572

Deploy and scale containerised apps across any servers without Kubernetes or Swarm overhead

View details
83
Repo Health
78
Technical
67
Dependency
Built with
Go 86%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers