KubernetesCXIII · Kubernetes DNS Advanced TroubleshootingDNS advanced troubleshooting
DNS security — DoH, response policy zones, and DNSSEC
What you'll learn
- Configure DNS-over-HTTPS for encrypted queries
- Apply RPZ for blocking malicious domains
- Understand DNSSEC for upstream verification
- Apply the operational discipline of DNS security
Prerequisites
Verified against Kubernetes 1.34.x · kubeadm 1.34.x · kubectl 1.34.x · etcd 3.6.x · CoreDNS 1.11.x · containerd 1.7.x / 2.x · 2026-08-16
DNS security in Kubernetes involves encrypting DNS queries, blocking malicious domains, and verifying upstream responses. This lesson walks DoH, RPZ, DNSSEC, and the discipline.
The DNS security threats
flowchart LR
A[DNS threats] --> B[Eavesdropping]
A --> C[Malicious domains]
A --> D[Upstream spoofing]
B --> B1[Plaintext queries reveal internal services]
C --> C1[Compromised Pods query C2 servers]
D --> D1[Attacker forges DNS responses]
The threats:
- Eavesdropping. Plaintext DNS queries reveal internal service names and dependencies.
- Malicious domains. Compromised Pods query command-and-control (C2) servers.
- Upstream spoofing. An attacker forges DNS responses; the resolver returns wrong addresses.
Each threat has a corresponding mitigation.
DoH (DNS-over-HTTPS)
forward . tls://1.1.1.1 {
tls_servername cloudflare-dns.com
prefer_health
}
The CoreDNS forward plugin supports TLS (DoT) and HTTPS (DoH):
- DoT (DNS-over-TLS). Port 853; encrypted.
- DoH (DNS-over-HTTPS). Port 443; encrypted, looks like HTTPS traffic.
Cloudflare (1.1.1.1), Google (8.8.8.8), and
Quad9 (9.9.9.9) support DoH.
# Verify DoH
dig @127.0.0.1 -p 53 +tls example.com
The query is encrypted between CoreDNS and the upstream.
RPZ (Response Policy Zones)
.:53 {
forward . 8.8.8.8
response-policy {
zone "rpz.example.com" {
policy NXDOMAIN
}
}
}
RPZ blocks resolution of malicious domains:
- The response-policy plugin checks every response against a zone file (RPZ).
- Domains in the RPZ are blocked (NXDOMAIN) or rewritten.
- Sources: Spamhaus, Malware Domain List, custom.
A Pod that queries a malicious domain gets NXDOMAIN; the C2 connection is broken.
DNSSEC
.:53 {
dnssec {
key file /etc/coredns/dnssec.keys
}
forward . 8.8.8.8
}
DNSSEC verifies upstream responses:
- The upstream DNS signs responses with DNSSEC keys.
- CoreDNS verifies the signatures.
- A forged response (without valid signature) is rejected.
DNSSEC prevents upstream spoofing but requires:
- The upstream DNS supports DNSSEC.
- CoreDNS has the trust anchors for the upstream’s DNSSEC keys.
The configuration trade-offs
flowchart LR
A[DoH] --> B[+ Encrypted upstream]
A --> C[- Slight latency overhead]
D[RPZ] --> E[+ Block malicious domains]
D --> F[- Need to maintain zone file]
G[DNSSEC] --> H[+ Verify upstream]
G --> I[- Upstream must support]
The trade-offs:
- DoH: Encrypted upstream, slight latency.
- RPZ: Block malicious domains, maintain zone file.
- DNSSEC: Verify upstream, upstream must support.
Each addresses a specific threat; combine them for defense in depth.
Quiz
Knowledge check · 4 questions
Q1. What threat does DNS-over-HTTPS between CoreDNS and its upstream address?
Q2. DNS-over-HTTPS validates that a response genuinely came from the zone's authoritative server.
Q3. Repair encrypted upstream resolution after switching CoreDNS to DNS-over-TLS.
CoreDNS is changed from `forward . 8.8.8.8` to `forward . tls://1.1.1.1` so that upstream queries are encrypted. Cluster names still resolve, but every external name now fails. CoreDNS logs repeat `x509: certificate is valid for cloudflare-dns.com, not 1.1.1.1`, and lookups for public names time out after several seconds.
Q4. Which port does DNS-over-TLS use, which Corefile directive supplies the name the upstream certificate must match, and what does DNSSEC protect against that DoT does not?
Passing score: 75%. Answers are checked in this browser.
The operational discipline
DNS security in production rests on five non-negotiable elements:
- DoH for sensitive traffic. Encrypt upstream queries.
- RPZ for known-malicious zones. Block C2 and phishing domains.
- DNSSEC where supported. Verify upstream responses.
- Monitor DNS security. Alert on RPZ hits, DNSSEC failures.
- Document the configuration. Zones, sources, upstreams.
DNS security is layered; each layer addresses a specific threat. The discipline is to enable the appropriate layers for the environment.