Kubernetes DNS with CoreDNS: custom domains and upstream resolvers

Enterprise clusters often need pods to resolve internal domains through corporate DNS while keeping cluster service discovery intact. This page explains how to configure CoreDNS for that, which options fit which network, and what to confirm before changing production DNS.

On this page

CoreDNS custom domains in self-managed Kubernetes: when a cluster needs its own DNS routing

Teams need custom DNS routing when pods cannot resolve corporate or private zones, or when lookups slow down after a network change. CoreDNS is the cluster DNS service. It answers Service and Pod names under the cluster domain, and it forwards everything else to upstream resolvers defined in its configuration. When an internal zone such as a private company domain is not visible from the cluster, the usual fixes are a stub domain that sends queries for that zone to a specific internal DNS server, or a change to the upstream resolver list that CoreDNS uses for general queries. NodeLocal DNS Cache is a separate decision. It adds a caching agent on each node to cut latency and reduce load on CoreDNS, and it does not by itself make a private zone resolvable. Treat these as three different problems before changing anything.

The Corefile location depends on the Kubernetes version and the distribution. In kubeadm clusters it is usually a ConfigMap named coredns in the kube-system namespace, but K3s, RKE2, managed services and GitOps-managed clusters may store it differently. Confirm the plugin names and their behavior (for example forward, hosts and the kubernetes plugin options) against the CoreDNS documentation for the exact CoreDNS version your cluster ships. Also confirm how your distribution manages the ConfigMap, because a manual edit can be overwritten on upgrade or by a reconcile loop.

Ownership should sit with the platform team that operates the cluster network, with the network or DNS team consulted on which internal zones and resolvers are authoritative. Application teams should not edit the Corefile directly. Before a change, ask who owns the internal DNS servers, which zones must be forwarded, whether DNSSEC or split-horizon answers apply, and how a failed upstream will be detected. Test from a pod with nslookup or dig against the cluster resolver, not from a node, because node resolution often differs from pod resolution.

How a pod lookup travels from the workload to corporate and cluster DNS

The diagram starts at the pod's resolver configuration, which sends each query to the cluster DNS Service or a node-local cache. CoreDNS then decides from the Corefile whether the name belongs to the cluster zone, to a stub domain forwarded to an internal resolver, or to a public upstream. The trust boundary sits where queries leave the cluster network for corporate DNS, so check which zones cross it and which resolver answers them. The Corefile and forward settings are edited in the CoreDNS configuration, not in the pod.

Query path from a pod through cluster DNS to internal and public resolvers.

Which CoreDNS configuration option fits each enterprise DNS requirement

This table compares the four CoreDNS and cluster DNS options most enterprise teams weigh: private zone forwarding, upstream resolver changes, fixed hosts records and NodeLocal DNS Cache. Read each row by starting with the requirement, then check the Corefile or object change, the side effects beyond the target zone and the main trade-off before you choose.

RequirementOption and change madeEffect outside the target zoneMain trade-off
Resolve an internal private zone hosted on corporate DNSA forward block for the zone in the Corefile, or a stub domain in the cluster DNS configuration, pointing at the internal resolver addressesOnly names under that zone are routed differently. All other names keep the default upstream path, but the internal resolver must be reachable from every node that runs CoreDNS.Every new internal zone adds a block to maintain, and the internal resolver becomes a dependency for those names. Confirm the exact forward and stub syntax for your CoreDNS version.
Send all external name lookups to approved corporate resolversChange the upstream list in the forward plugin block for the root zone, replacing the default node or upstream resolversEvery external lookup from pods goes through the new resolvers, including lookups that services depend on for SaaS endpoints.Central control and logging of egress lookups, but a resolver outage or policy block affects the whole cluster. Test resolver health checks and timeouts before the change.
Return fixed addresses for a few internal service namesA hosts block in the Corefile listing the name and address pairs, with fallthrough so other names still resolveOnly the listed names change. Other lookups pass to the next plugin when fallthrough is set, which is easy to omit.Simple and fast, but records are static and must be edited by hand in the Corefile. Changes trigger a CoreDNS reload, so plan them through your normal change process.
Lower lookup latency and reduce load on CoreDNS podsDeploy NodeLocal DNS Cache as a DaemonSet that runs a cache on each node and intercepts pod lookups, configured with the cluster DNS addressEach node caches answers locally, so cache hits do not reach CoreDNS. Pods on the node are affected at the network path level.Adds a per-node component to run, monitor and upgrade. Confirm node network and iptables or IPVS requirements with the NodeLocal DNS Cache documentation for your version.

How ndots and search paths add latency to CoreDNS lookups

The ndots setting and the search domains in a pod's DNS configuration decide how many queries a short name generates before the intended name is tried. Kubernetes writes both into each pod's /etc/resolv.conf, and the resolver applies them on the client side, before CoreDNS sees a single question. If a name contains fewer dots than the ndots threshold, the resolver appends each search suffix in turn and sends those queries first, and only then tries the name as written. For a cluster Service name such as api.payments, that order is usually harmless. For an external name such as api.example.com with the common default of five dots in ndots, the resolver may send several failed lookups for names like api.example.com.payments.svc.cluster.local before the correct one, and it repeats this for both A and AAAA records.

Each extra query costs a round trip to CoreDNS and, when CoreDNS forwards it, a further trip to your upstream resolver, which is where NXDOMAIN answers add up at scale. The effect multiplies with request rate, so a service that calls external APIs many times per second can put far more load on cluster DNS than its application logs suggest. You can reduce this in several ways: end external names in a trailing dot so the resolver treats them as fully qualified, lower ndots through the pod's dnsConfig for workloads that mostly call external hosts, or add a dedicated search configuration for specific workloads. Each choice has a trade-off. A lower ndots value can break short Service names that depend on the search path, so test the workload's own name lookups after any change.

Measure before you change anything. Capture query counts from a representative pod with a tool such as dig or nslookup against the cluster DNS Service, and compare CoreDNS request metrics before and after a change. Check the defaults for your Kubernetes version and distribution in the pod DNS documentation, since search lists and ndots values can differ when a distribution or operator sets them. Confirm how your upstream resolvers handle the NXDOMAIN traffic that the search path generates, because that load falls on your network team's resolvers as well as on the cluster.

Configure CoreDNS stub domains and upstream resolvers step by step

This sequence takes a cluster from its current CoreDNS setup to one that forwards internal enterprise zones to the right resolvers, with a tested rollback and checks on service discovery before and after the change.

  1. Record the current Corefile and DNS service

    The cluster operator exports the coredns ConfigMap in kube-system and saves it to version control, then records the cluster DNS Service address with kubectl get svc -n kube-system kube-dns. Also record the CoreDNS Deployment replica count and image tag. The step is done when the saved Corefile, the Service ClusterIP and the image tag are stored together in the change record, so any later step can be reversed exactly.

  2. Map internal zones and resolvers

    Work with the network and identity teams to list every internal domain that pods or nodes must resolve, such as corporate zones, private cloud zones and Active Directory domains, and the authoritative DNS servers for each. Confirm which resolvers are reachable from the pod network and which only from node networks, since CoreDNS pods and kubelet-configured hosts can have different routes. The output is a table of zone, resolver IP addresses, protocol and the network path, reviewed before any configuration is written.

  3. Test each resolver from a debug pod

    Start a temporary debug pod in a test namespace and run nslookup or dig against each candidate resolver IP for a known name in every listed zone, over both UDP and TCP. Repeat the same lookups from a node through its host networking to compare the two paths. Record which resolvers answer, the response time and any timeouts. The step is done when every zone has at least one resolver that answers from pods, and any gaps have an owner and a fix before the Corefile is edited.

  4. Edit the Corefile in staging

    In a staging cluster that mirrors production networking, add a server block for each internal zone with a forward plugin pointing to its resolvers, keeping the default kubernetes cluster.local block and the forward . /etc/resolv.conf block unchanged. Validate the file with the team's review process and apply it. The step is done when the staging CoreDNS pods restart cleanly and show no parse errors in their logs.

  5. Roll out the change and verify lookups

    Apply the reviewed ConfigMap to production during an agreed change window and restart or reload CoreDNS according to the cluster's configuration. Run test lookups from a debug pod for internal zones, external names and in-cluster Service names such as kubernetes.default.svc.cluster.local. Confirm that existing workloads still resolve their Services by name. The step is done when all test names return the expected answers and an existing application's service discovery works as before.

  6. Check CoreDNS logs and metrics

    Review CoreDNS logs for SERVFAIL or forwarding errors over a period the team agrees, and check the Prometheus metrics that CoreDNS exposes, such as request counts, response codes and forward latency, if monitoring is in place. Compare them with the baseline recorded before the change. The step is done when error rates and latency match the baseline, or any deviation has a documented cause.

  7. Prepare and test the rollback

    Keep the saved Corefile from the first step ready to apply, and test the rollback in staging by restoring the previous ConfigMap and confirming that lookups return to the original behavior. Write down the exact commands and the owner who runs them. The step is done when the rollback has been rehearsed in staging and the team can apply it in production within the agreed change process.

  8. Confirm ndots and search path behavior

    Check how the pod ndots setting and search domains interact with the new forward zones, since long lookups can generate extra queries before a name resolves. Measure lookup latency for a few common names from a debug pod before and after the change, and note whether any application should use fully qualified names. The step is done when the team has a documented result for latency and search path behavior, and has confirmed that the change does not add surprising query volume for critical workloads.

Which resolver design fits on-premises, cloud-connected and air-gapped networks

On-premises clusters usually forward queries for the cluster domain to CoreDNS and send everything else to the corporate resolvers, typically Active Directory domain controllers or a pair of internal recursive servers. The corporate DNS team owns those servers, along with their zones, conditional forwarders and security policy. The cluster team owns the CoreDNS configuration, which should forward only the domains the enterprise needs (for example, an internal zone such as corp.example.internal as a stub domain) and leave the rest to the default forwarder.

  • Resolver chain: Pod, CoreDNS in kube-system, then the corporate recursive resolvers, which resolve internal names and forward external names.
  • Ownership: The network or DNS team owns the resolver IPs, zone data and forwarding rules; the platform team owns the Corefile and its change process.
  • Subnet paths: Allow UDP and TCP port 53 from the pod and node CIDRs to the resolver addresses, and confirm return traffic for TCP fallback on large responses.
  • Stub domains: Confirm which internal zones need stub or forward entries and whether DNSSEC validation on the corporate side affects responses.
  • Before the change: Ask the DNS team for the resolver addresses, rate limits on those servers and whether they accept queries from node subnets.

Before changing upstreams, confirm with the DNS team which servers are authoritative for each internal zone and which clients they accept queries from.

Security risks of changing cluster DNS in enterprise networks

CoreDNS sits between every pod and every upstream resolver, so a small change to its configuration can redirect lookups, expose internal names or hide evidence of abuse. The cards below cover the risks that appear most often when teams add stub domains and upstream resolvers, and the control to put in place for each one.

Stub domain pointing to an untrusted resolver

A stub domain sends every query for one zone to a resolver you name in the Corefile. If that resolver is not operated by your organization or a trusted provider, every pod that asks for names in that zone receives whatever answers it returns. Before adding a stub domain, confirm who operates the target resolver, that it is reachable only over links you control, and that the zone is one you own or have explicit rights to resolve. Document the owner of each stub domain next to its entry.

kubeadm init docs

DNS spoofing between pods and upstreams

Queries that leave the cluster over plain UDP can be altered or answered by anyone on the path, including a compromised node or network device. Changing resolvers or forwarding rules without reviewing the path can widen that exposure. Check which upstream addresses are reachable from pod networks, whether the resolvers you forward to support encrypted transport, and whether network policy limits who can send DNS to CoreDNS. Treat any new upstream as a new trust boundary.

Internal zone names exposed by broad forwarding

A forward directive that matches the root zone or a wide suffix sends internal service and host names to external resolvers, which discloses your internal naming scheme and hostnames. Scope each forward or stub block to the narrowest zone that works, and confirm that internal zones are answered only by internal resolvers. Review the output of a sample query for each internal zone from a workload namespace, and record which resolver answered it.

Corefile edits without change control

The Corefile is cluster-wide configuration, and a typo or an unreviewed plugin change can stop name resolution for every workload at once. Edits made directly with kubectl edit leave no approval record and no diff to review. Keep the Corefile in version control, require review by a second engineer for each change, and apply it through your normal deployment pipeline. Record who approved each change and link it to a ticket.

Workloads able to edit the CoreDNS ConfigMap

CoreDNS reads its configuration from a ConfigMap in the kube-system namespace. Any identity with update or patch rights on that ConfigMap can redirect DNS for the whole cluster, which makes it a high-value target. Limit write access to the ConfigMap to a small platform group, review RBAC bindings that grant rights in kube-system, and confirm that application service accounts cannot read or change it. Check the effective permissions with an access review rather than relying on the role names.

DNS query logging turned off

Without query logging, a malicious stub domain, a data exfiltration attempt through DNS or a misconfigured forwarder leaves no trace you can investigate. Enable the log plugin in the Corefile where your policy requires it, and set retention on the log store according to your records policy. Confirm that logs are shipped off the cluster so an attacker who controls a pod cannot remove them. Check the log volume before enabling it cluster-wide, since query logs grow with traffic.

Scaling CoreDNS and NodeLocal DNS Cache as the cluster grows

CoreDNS load grows with the number of queries each pod sends, not with the node count alone, so replica and resource decisions should start from the query rate your workloads generate. Four inputs drive that rate: the number of pods and Services that resolve names, the query rate per pod, the ndots and search path settings in each pod's resolv.conf, and the cache hit rate inside CoreDNS. A high ndots value, which is common in default pod configurations, makes a lookup for an external hostname try several cluster search suffixes before the final absolute name, multiplying the queries that reach CoreDNS. Before you change any replica count, measure these inputs on your own cluster using CoreDNS metrics such as request totals, response codes and latency, and confirm how your workloads use dnsConfig overrides.

Replica count, CPU and memory requests, and pod spreading all affect resilience as much as raw capacity. Running at least two replicas spread across nodes or zones means a single node failure does not remove every resolver, while CPU and memory requests that are too low let the scheduler place CoreDNS on crowded nodes where it slows under load. Pod anti-affinity or topology spread constraints keep replicas apart. Scale the Deployment or the autoscaler from observed latency and query volume, and check that requests reflect real usage so the scheduler and autoscaler respond to the right signal. Confirm the exact autoscaling options your CoreDNS version and distribution support before you rely on them.

NodeLocal DNS Cache runs a DNS cache on each node so many pod lookups are answered locally, which reduces traffic to the cluster DNS Service and cuts the effect of spikes from ndots amplification. The setup changes how traffic reaches the cache, so it depends on your network plugin and kube-proxy mode. Confirm the installation manifests, the listen address and the interaction with your CNI and kube-proxy version in the upstream documentation for your release before you roll it out, and test name resolution for both cluster and external domains on a canary node pool. Treat the cache as a change to the data path that needs its own rollback plan.

Limits to confirm in your environment before changing cluster DNS

Cluster DNS sits between pods, your CNI and kube-proxy, and the corporate resolvers your enterprise already depends on. The items below are the points where a change that looks correct in a lab can behave differently in your network, so confirm each one before you edit the CoreDNS configuration. This page does not publish performance figures for DNS latency or CoreDNS scaling, so measure those in your own environment.

CoreDNS version and plugin set

Confirm which CoreDNS version and which plugins your distribution ships before writing any Corefile change. Plugin availability and option names differ between releases, and a distribution may rewrite the ConfigMap during its own upgrades. Ask the vendor or check the distribution documentation for the exact CoreDNS version, then test your forward, rewrite and cache directives against that version. Record who owns the ConfigMap so a platform upgrade does not silently overwrite your stub domains.

Kubeadm HA docs

NodeLocal DNS Cache compatibility

Check whether NodeLocal DNS Cache is supported with your CNI plugin and your kube-proxy mode, including any kube-proxy replacement. The cache runs a link-local listener on each node and changes how queries reach CoreDNS, so a mismatch can break resolution for only some pods. Confirm this with your CNI vendor and your distribution before enabling it, and plan a rollback path that restores the original kube-dns service address.

Pod network access to corporate DNS

Verify that your corporate DNS servers accept queries from the pod network and the node network, not only from the hosts that sit in the server's allowed list. Firewalls, DNS policy engines and access control lists often permit queries from node addresses but drop traffic from pod CIDRs, or apply rate limits that a busy cluster will hit. Ask the network team to confirm the source addresses they will see after NAT, and test each forwarder from a pod before cutover.

Upstream TTL and caching behavior

Find out how long each upstream resolver caches records and what TTL it returns for names it owns. CoreDNS caches responses for the TTLs it receives, so a long upstream TTL, a short cache setting in CoreDNS, or a resolver that ignores TTLs will each change how quickly a DNS update takes effect. Confirm these values with the owners of the resolvers and decide how long your team can tolerate stale answers during a migration or failover.

Split-horizon name resolution

Confirm whether a name such as an internal service domain returns the same answer inside the cluster and outside it. Split-horizon zones often return different addresses on internal and external resolvers, and a stub domain or forward rule can send a pod to the wrong view. Build a list of names that must resolve identically from a pod, a node and a workstation, and test each one after the change.

Change windows and DNS ownership

Identify who owns the corporate DNS zones, who owns the CoreDNS ConfigMap and who approves changes that affect resolution for all workloads. A stub domain or forwarder change can affect every namespace at once, so agree on a change window, a named approver and a rollback owner before the work starts. Ask your team to confirm how these owners are documented and whether any change freeze overlaps the planned date.

What custom CoreDNS configuration costs and what the work needs from your team

What drives the cost and effort of a CoreDNS change?

The main drivers are how many domains and upstream resolvers are involved, how many clusters share the same configuration, and how much of the current DNS path is undocumented. A change that adds one stub domain to a single test cluster is small. A change that routes several internal zones, split-horizon names and corporate resolvers across multiple production clusters involves design, review, staged rollout and evidence gathering. Ask a partner to price these items separately: discovery of existing DNS flows, the Corefile design, the rollout plan, testing, and documentation for your operations team. Effort also rises when the cluster is installed with a distribution that manages CoreDNS through its own tooling, because the change has to fit that lifecycle rather than fight it.

Can our own platform team make a CoreDNS change without outside help?

Yes, a team with Kubernetes operations experience and access to the DNS servers can usually make a single, well-understood change. CoreDNS configuration is held in a ConfigMap and the plugins involved are documented upstream, so the mechanics are not the hard part. The harder work is knowing which resolvers are authoritative for which zones, what your DNS owners will accept, and how a failed resolution will show up in your monitoring. Teams often bring in outside help when the change spans several clusters, when they lack a test environment that matches production, or when they need written evidence for an internal review. Ask any partner to state in writing which parts they will hand over for your team to run.

What does the work need from network, DNS and platform owners?

Each group owns a different decision, and the project stalls if any of them is missing from the start. Network owners confirm routes from cluster nodes to the upstream resolvers and any firewall rules that allow DNS traffic over UDP and TCP. DNS owners confirm which zones they serve, which records must resolve from inside the cluster, and whether forwarding targets accept queries from the pod network. Platform owners decide how the CoreDNS Corefile is managed, who approves changes and how rollback works. Ask for a named owner in each group and a written list of the zones and resolver addresses in scope before the design starts.

How long does testing take with many zones and clusters?

Testing time grows with the number of zones, resolvers and clusters, and no fixed duration applies to every environment. Each zone needs positive and negative lookups from representative pods, and each upstream path needs a check for timeouts and failover. Multiple clusters multiply that work, because a configuration that passes on a lab cluster can still differ on a cluster with another node network or a different CoreDNS version. Ask a partner to provide a test matrix that lists zones, clusters and failure cases, and to say which of those tests run in a staging environment before production. Any timeline should come from that matrix, not from a general estimate.

Does a CoreDNS configuration change require downtime?

A well-planned change usually does not require a cluster outage, but DNS is in the path of almost every workload, so the rollout needs care. CoreDNS reloads its configuration when the Corefile changes, and a mistake can cause resolution failures for pods across the cluster within moments. Rollouts are safer when the change is validated in a staging cluster, applied to a subset of nodes or namespaces first where the design allows it, and reverted through a known configuration. Ask the partner to describe the rollback procedure, the monitoring that will show resolution errors, and the maintenance window, if one is needed, in writing.

What recurring work comes after the change is live?

After the first rollout, the recurring work is operational. Someone must review the Corefile when upstream resolvers or internal zones change, check CoreDNS upgrades against the Kubernetes version your cluster runs, and watch DNS error and latency metrics. If the cluster grows, CoreDNS capacity may need to be reviewed. Costs here are mostly internal staff time and any support retainer you choose. Ask a partner whether the handover includes runbooks, which alerts they recommend, and whether post-change support is included or quoted separately.

What should a CoreDNS work quote include?

A quote should follow from a written scope, and it should list each deliverable and who is responsible for it. Ask for the following items to appear explicitly:

  • The inventory of zones, upstream resolvers and clusters in scope
  • The target Corefile design and the reasons for each forwarding choice
  • The test matrix and the environments where tests run
  • The rollout and rollback steps, plus the monitoring to be used
  • The documentation and handover sessions for your DNS and platform teams
  • Any assumptions about access, change windows and approvals on your side
  • Any work excluded from scope, such as changes to upstream DNS servers

How DeployOpen works on this

DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside the client's own infrastructure, including cluster DNS. For CoreDNS work, we start from how your internal domains, resolvers and workloads actually query names, then build and test the change in your environment before handover.

How we scope

  • We inventory internal domains, upstream resolvers and the workloads that generate the most DNS queries.
  • Most engagements are fixed-scope, with the CoreDNS changes, test cases and deliverables agreed in writing before work starts.
  • The written scope names which clusters, stub domains and NodeLocal DNS settings are in and out of the work.

How we build

  • We stage Corefile changes for stub domains and upstream forwarding in a non-production cluster first.
  • We test name resolution from pods with search path and ndots settings, checking internal, external and cluster-local names.
  • We review CoreDNS replica count and resource settings against your cluster size and document the results of load checks.

How we hand over

  • You receive the final Corefile, ConfigMap and manifests, with a record of each change and its reason.
  • We document the test cases used to verify resolution, so your platform team can repeat them after future changes.
  • Handover covers the runbook for resolver failures, cache behavior and the steps to roll back a DNS change.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, covering CoreDNS version changes as your clusters move between minor releases.
  • We can retest DNS behavior after network, resolver or cluster-size changes, using the same test cases from handover.
  • Ask any provider to confirm which CoreDNS versions and Kubernetes versions your current distribution ships before the work is scoped.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.