CoreDNS is an open-source DNS server written in Go that assembles its functionality from a chain of plugins, each handling one task such as serving zone data, forwarding queries, caching answers or exporting metrics. In DNS infrastructure, it is best known as the default cluster DNS service in Kubernetes, where it resolves service and pod names, but it also works as a general authoritative server, forwarder or caching resolver.
CoreDNS is a graduated project of the Cloud Native Computing Foundation, and its design favors small, composable features over the monolithic configuration of older servers such as BIND. That flexibility makes it lightweight and easy to extend, while some advanced resolver functions remain less mature than in specialized software.
How CoreDNS processes a query
CoreDNS processes a query by passing it through an ordered chain of plugins until one of them writes a response. Each plugin can answer the query, modify it, pass it to the next plugin or fall through when it has no matching data, which lets several data sources cooperate within one zone.
A crucial detail is that the execution order is fixed at compile time in a file named plugin.cfg, not by the order in which plugins appear in the configuration. Administrators who expect line order to matter are often surprised, for example when cache appears late in the file yet still runs before forward.
The following table traces a typical lookup through a Kubernetes-style plugin chain.
| Plugin | Action on the query | Outcome |
|---|---|---|
| errors and log | Record failures and query details | Observability |
| cache | Returns a stored answer if still valid | Fast response, no further work |
| kubernetes | Answers names inside the cluster domain | Service or pod address |
| forward | Sends other names to upstream resolvers | External answer, then cached |
| loop | Detects queries that return to the server | Prevents resolution loops |
The Corefile and server blocks
CoreDNS is configured through a text file called the Corefile, which contains one or more server blocks. Each block starts with the zones and port it serves, such as .:53 for all names on port 53, followed by the plugins enabled for that block and their arguments.
A minimal caching forwarder needs only a few lines: a block for the root zone, forward . 9.9.9.9 and cache 300. Separate blocks can serve different zones with different logic, for instance an internal zone from a file and everything else through an upstream resolver. The reload plugin detects changes to the Corefile and applies them gracefully without dropping in-flight queries.
| Plugin | Purpose | Typical setting |
|---|---|---|
| file | Serves an authoritative zone from a zone file | Internal company zone |
| forward | Proxies queries to upstream resolvers | Public or corporate resolvers |
| cache | Stores positive and negative answers | 30 to 300 seconds |
| kubernetes | Generates records from the Kubernetes API | cluster.local domain |
| rewrite | Changes query names or types | Migrating domain names |
| hosts | Answers from a hosts-format file | Static overrides |
| prometheus | Exposes metrics | Port 9153 |
| health and ready | Report liveness and readiness | Ports 8080 and 8181 |
CoreDNS as cluster DNS in Kubernetes
In Kubernetes, CoreDNS runs as a Deployment behind a Service usually named kube-dns, and every pod receives its address as the nameserver. The kubernetes plugin watches the API server and synthesizes records such as web.shop.svc.cluster.local, so service discovery works through ordinary DNS lookups without extra client libraries.
CoreDNS replaced the earlier kube-dns add-on, which combined dnsmasq with separate sidecar containers. The move brought a single binary, lower memory use and native metrics. Typical record types include A and AAAA records for services, SRV records for named ports and headless-service records that return individual pod addresses.
Performance in clusters is shaped by the ndots setting, which defaults to 5 in pod resolver configuration. A lookup of an external name with fewer dots is first tried against several search domains, so one application request can create multiple wasted queries. Remedies include fully qualified names with a trailing dot, a lower ndots value or the NodeLocal DNSCache add-on that caches answers on each node.
How CoreDNS compares with other DNS servers
CoreDNS sits between general-purpose authoritative servers and dedicated recursive resolvers. It is strongest where configuration must be dynamic and integrated with platforms, and weaker where full recursion or very large static zones are the priority.
| Server | Main role | Configuration style | Best fit |
|---|---|---|---|
| CoreDNS | Forwarding, authoritative, service discovery | Plugin chain in a Corefile | Containers and cloud platforms |
| BIND | Authoritative and recursive | Extensive named.conf syntax | Traditional enterprise and ISP zones |
| Unbound | Validating recursive resolver | Resolver-focused options | Caching and DNSSEC validation |
| dnsmasq | Lightweight forwarder with DHCP | Simple flat file | Small networks and routers |
Notably, CoreDNS is not a full recursive resolver by default: it normally forwards external queries to an upstream recursive service rather than walking the hierarchy from the root name servers itself. It can sign zones with the dnssec plugin, while validation of upstream answers is typically left to the upstream resolver.
Security, encryption and operational limits
CoreDNS supports encrypted transports in addition to classic UDP and TCP on port 53. Server blocks can listen with DNS over TLS on port 853, DNS over HTTPS and DNS over gRPC, and the forward plugin can send upstream queries over TLS to protect them on untrusted networks.
- Forwarding loops occur when the upstream points back to CoreDNS, often through a node resolver file; the loop plugin stops the server instead of amplifying traffic.
- Undersized replicas cause timeouts in large clusters, so replica counts should scale with node and pod numbers.
- Overly long cache times delay visibility of changed records, while very short ones increase upstream load.
- Custom plugins require recompiling, because plugins are linked into the binary rather than loaded at runtime.
Monitoring the request rate, latency and response codes through the Prometheus endpoint is the most reliable way to catch these problems early. A rising share of SERVFAIL or NXDOMAIN answers usually points to upstream failures or search-domain inflation.
Explained without jargon
CoreDNS is a program that translates names into addresses so that computers can find each other. When one part of an application asks where the database lives, CoreDNS looks up the name and replies with the right address.
It is built like a set of building blocks. Each block does one small job, such as remembering recent answers or asking another server for help, and administrators simply choose which blocks to use. This is why it fits so well inside modern container platforms, where names and addresses change constantly.
A typical use case
A software company runs about 300 microservices on a Kubernetes cluster with 40 nodes. Developers report occasional five-second delays when services call external payment APIs. Metrics from the CoreDNS prometheus plugin show that each external lookup produces four extra queries, caused by the default ndots value of 5 and three search domains.
The platform team adds a trailing dot to the external API hostnames, deploys NodeLocal DNSCache on every node and increases CoreDNS from two to four replicas. It also sets the cache plugin to 60 seconds and forwards external names to two upstream resolvers over DNS over TLS.
After the change, DNS query volume drops by about 70 percent, the five-second delays disappear and the p99 lookup latency inside the cluster falls to a few milliseconds.