coredns/coredns
CoreDNS
CoreDNS is a DNS server written in Go that delivers its functionality through a chain of plugins. A Corefile declares which plugins handle which zones, and each plugin in the chain either answers a query, mutates the response, or hands the request to the next plugin. The project is a CNCF graduated project and is the default cluster DNS for Kubernetes.
What this codebase contains
This repository (github.com/coredns/coredns) holds:
- A small bootstrap binary (
coredns.go,coremain/) that starts the Caddy server framework with thednsserver type registered. - The DNS server type implementation in
core/dnsserver/, which parses Corefiles, builds plugin chains, and serves queries over UDP/TCP, DoT, DoH, DoH3, DoQ, and gRPC. - 60+ in-tree plugins under
plugin/covering everything from caching and forwarding to Kubernetes service discovery, DNSSEC signing, and observability. - A request abstraction in
request/that gives plugins a uniform view of the client query. - A large pool of shared packages under
plugin/pkg/that plugins can reuse. - An end-to-end test suite under
test/.
What it does
CoreDNS chains plugins to serve DNS, and each plugin does one job. The shipped plugins let you:
- Serve zone data from files (
file,auto,secondary) or from a backend like etcd, Kubernetes, AWS Route53, Azure DNS, Google Cloud DNS, or HashiCorp Nomad. - Forward queries to upstream resolvers over UDP/TCP/DoT (
forward,grpc). - Cache positive and negative responses (
cache). - Sign zones on the fly (
dnssec,sign). - Rewrite or transform questions and answers (
rewrite,template,header,minimal,loadbalance,dns64). - Enforce access policies (
acl,view,tsig). - Expose Prometheus metrics (
prometheus/metrics), structured query logs (log), errors (errors), and dnstap streams (dnstap). - Listen on additional transports: TLS for DoT (
tls), HTTPS for DoH (https), HTTP/3 for DoH3 (https3), QUIC for DoQ (quic), gRPC (grpc_server).
The complete in-tree plugin list lives in plugin.cfg.
How a request flows
graph LR
Client[DNS client] -->|query| Listener[core/dnsserver Server]
Listener -->|zone match| Chain[plugin chain]
Chain -->|ServeDNS| P1[plugin 1]
P1 -->|next| P2[plugin 2]
P2 -->|next| Pn[... plugin N]
Pn -->|response| Listener
Listener -->|reply| ClientThe server matches the query name against configured zones (longest suffix wins), then calls ServeDNS on the head of the plugin chain for that zone. Plugins handle the request or call plugin.NextOrFailure to defer to the next plugin. Order is fixed by plugin.cfg, not by the order plugins appear in the Corefile.
Quick links
| What | Where |
|---|---|
| Build it and run a Corefile | Getting started |
| Architecture in depth | Architecture |
| Definitions of project-specific terms | Glossary |
| Per-plugin docs (READMEs) | plugin/<name>/README.md and man/coredns-<name>.7 |
| External docs | https://coredns.io, https://coredns.io/plugins |
Project facts
- Language: Go (>= 1.25.0; tracked in
.go-versionandgo.mod) - License: Apache 2.0 (see
LICENSE) - Governance:
GOVERNANCE.md,CODEOWNERS - Build entry point:
coredns.go→coremain.Run()→caddy.Start(corefile) - Default Corefile:
whoami+loglistening on:53
For a quantitative snapshot of the codebase see By the numbers. For its history see Lore.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.