Why Use Custom DNS Zones in NodeLocal DNSCache?

NodeLocal DNSCache speeds up DNS resolution in Kubernetes by running a local CoreDNS instance on each node. Adding custom zones allows:

  • Fast resolution of static or internal domains
  • DNS overrides without relying on upstream resolvers
  • Separation of internal and external DNS logic

Step-by-Step Guide

1. Get the NodeLocal DNS ConfigMap

kubectl -n kube-system get configmap node-local-dns -o yaml > node-local-dns.yaml

2. Add Custom Zones

Inside the Corefile section, add your custom zone using the hosts plugin:

Corefile: |
  .:53 {
      errors
      cache {
        success 9984 30
        denial 9984 5
      }
      reload
      loop
      bind 169.254.20.10
      forward . /etc/resolv.conf
      prometheus :9253
      log
  }

  internal.zone.local:53 {
      hosts {
          10.10.10.10 service1.internal.zone.local
          10.10.10.11 service2.internal.zone.local
          fallthrough
      }
  }

Replace internal.zone.local with your desired DNS suffix.

3. Apply the Updated ConfigMap

kubectl apply -f node-local-dns.yaml

4. Restart the DaemonSet

kubectl -n kube-system rollout restart daemonset node-local-dns

5. Test

From any pod:

nslookup service1.internal.zone.local

Tips

  • Be cautious with overlapping zones — NodeLocal does not support all CoreDNS plugins.
  • You may need to modify the node-local-dns DaemonSet if your changes break compatibility.

Conclusion

Custom zones in NodeLocal DNSCache improve control over name resolution in your Kubernetes environment. They are particularly useful for hybrid or air-gapped environments.

→ Learn more: