coredns-golang-dns
CoreDNS configuration and Go DNS programming. Use when writing Corefiles, patching CoreDNS in Kubernetes (kube-system ConfigMap, NodeHosts, rewrites, conditional forwarders), serving static A/AAAA/CNAME/SRV records, building Go DNS servers/interceptors with miekg/dns (split-horizon, conditional forward, response rewriting, transparent proxy), enabling DNS-over-TLS / DNS-over-HTTPS with cert-manager Certificates and trust-manager Bundles, or distributing CA trust for DoT/DoH clients.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- coredns-golang-dns
- license
- MIT
- version
- 1.0.0
- description
- CoreDNS configuration and Go DNS programming. Use when writing Corefiles, patching CoreDNS in Kubernetes (kube-system ConfigMap, NodeHosts, rewrites, conditional forwarders), serving static A/AAAA/CNAME/SRV records, building Go DNS servers/interceptors with miekg/dns (split-horizon, conditional forward, response rewriting, transparent proxy), enabling DNS-over-TLS / DNS-over-HTTPS with cert-manager Certificates and trust-manager Bundles, or distributing CA trust for DoT/DoH clients.
02 资源文件 20
- 资产文件assets/README.md373 B
- 参考文档references/coredns-corefile.md3.5 KB
- 参考文档references/coredns-kubernetes.md4.9 KB
- 参考文档references/coredns-static-records.md3.7 KB
- 参考文档references/coredns-tls-cert-manager.md7.1 KB
- 参考文档references/go-dns-interceptor.md5.7 KB
- 参考文档references/go-dns-miekg.md4.1 KB
- 参考文档references/go-dns-server.md5.4 KB
- 参考文档references/README.md424 B
- 参考文档references/troubleshooting.md5.7 KB
- 脚本scripts/go-dns-interceptor/go.mod327 B
- 脚本scripts/go-dns-interceptor/go.sum1.3 KB
- 脚本scripts/go-dns-interceptor/handler_test.go3.5 KB
- 脚本scripts/go-dns-interceptor/main.go4.2 KB
- 脚本scripts/go-dns-interceptor/README.md1.8 KB
- 脚本scripts/go-dns-interceptor/records.go3.2 KB
- 脚本scripts/go-dns-interceptor/resolver.yaml747 B
- 脚本scripts/instrument_service.py2.9 KB
- 脚本scripts/README.md426 B
- 脚本scripts/setup_jaeger.sh2.7 KB
03 SKILL.md 正文
CoreDNS & Go DNS
CoreDNS Corefile authoring, Kubernetes CoreDNS patching, static record serving,
DoT/DoH with cert-manager + trust-manager, and Go DNS server/interceptor
development with github.com/miekg/dns.
When to Use
- Editing the cluster CoreDNS ConfigMap (kube-system) to add forward zones, static hosts, rewrites, or stubdomains.
- Deploying a second CoreDNS instance as a custom resolver / interceptor in front of upstream DNS.
- Writing a Go service that answers DNS queries — split-horizon resolvers, conditional forwarders, response rewriters, captive-portal style interceptors, or test fixtures.
- Adding TLS to DNS endpoints (DoT 853, DoH 443/8443) and trusting the issuing CA cluster-wide.
Decision Tree
Static A/AAAA/CNAME inside cluster?
└─ Patch kube-system/coredns Corefile via `hosts` or `file` plugin
→ references/coredns-static-records.md
Override an external domain inside the cluster?
└─ `rewrite` or `template` plugin in CoreDNS
→ references/coredns-static-records.md
Intercept and conditionally rewrite responses?
└─ Build a Go forwarder in front of CoreDNS using miekg/dns
→ references/go-dns-interceptor.md + scripts/go-dns-interceptor/
DoT/DoH with valid certs?
└─ cert-manager Certificate → CoreDNS `tls`/`https` plugin
→ references/coredns-tls-cert-manager.md
└─ Distribute the CA via trust-manager Bundle for clients
→ references/coredns-tls-cert-manager.md
└─ CoreDNS forwarding to upstream DoT (tls:// + trust-manager bundle)
→ references/coredns-tls-cert-manager.md (Forwarding Upstream over DoT)
Something not working?
└─ Diagnostic recipes (rcodes, dig flags, metrics, DoT handshake)
→ references/troubleshooting.md
Quick Reference
| Topic | File |
|---|---|
| Corefile syntax, server blocks, plugin chain | references/coredns-corefile.md |
hosts, file, template, rewrite plugins |
references/coredns-static-records.md |
| Patching kube-system CoreDNS ConfigMap | references/coredns-kubernetes.md |
| DoT/DoH via cert-manager + trust-manager | references/coredns-tls-cert-manager.md |
miekg/dns quick start (server, client, RR) |
references/go-dns-miekg.md |
| Go DNS server with static records + forward | references/go-dns-server.md |
| DNS interception patterns (proxy, splice) | references/go-dns-interceptor.md |
| Working Go example | scripts/go-dns-interceptor/main.go |
| Debugging (NXDOMAIN/SERVFAIL, dig flags, DoT handshake, metrics) | references/troubleshooting.md |
Workflows
Add static records to in-cluster CoreDNS
- Inspect:
kubectl -n kube-system get cm coredns -o yaml. - Choose plugin —
hostsfor inline A/AAAA,filefor full zone,rewritefor response rewriting,templatefor synthesized RRs. Seereferences/coredns-static-records.md. - Patch via Kustomize/Helm overlay — see
references/coredns-kubernetes.mdfor recipes that survive cluster upgrades. - Roll:
kubectl -n kube-system rollout restart deploy/coredns. - Verify:
dig +short @<kube-dns-svc-ip> <name>from a debug pod.
Build a Go DNS interceptor
- Scaffold from
scripts/go-dns-interceptor/main.go. - Define static record map (A/AAAA/CNAME/TXT/SRV).
- For names not in the static map, forward upstream via
dns.Client. - Optionally rewrite responses (e.g. NXDOMAIN → synthesized A record).
- See
references/go-dns-interceptor.mdfor split-horizon, response rewriting, and transparent-proxy patterns.
Add TLS (DoT / DoH)
- Issue cert via cert-manager
Certificate(DNS SANs for the resolver name). - Mount Secret into CoreDNS pod, reference in
tls/httpsdirectives. - Distribute the issuing CA via trust-manager
Bundleso clients trust DoT. - See
references/coredns-tls-cert-manager.mdfor full manifests.
Important Notes
- CoreDNS plugin order is fixed at compile time, not by Corefile order.
The Corefile only enables/configures plugins. See
references/coredns-corefile.md. hostsplugin reloads its file every 5s by default — good for GitOps.kubectl editon the kube-system ConfigMap may be reverted by some installers (kubeadm phase, EKS addon, kops). Use the installer's overlay mechanism — seereferences/coredns-kubernetes.md.- For DoT, CoreDNS needs the cert + key, not just the cert. trust-manager distributes the CA to clients, not the leaf.
miekg/dnsrequires explicitm.SetReply(r)andm.Authoritative = truefor static answers, or downstream resolvers treat them as referrals.- Static record TTLs default to 3600s in CoreDNS
hostsplugin and 60s infileplugin's SOA — set explicitly for fast iteration.
04 同仓库更多 Skills
threejs
Build 3D web apps with Three.js (WebGL/WebGPU). Use for 3D scenes, animations, custom shaders, PBR materials, VR/XR experiences, games, data visualizations, product configurators.
media-processing
FFmpeg + ImageMagick media processing. This skill should be used when transcoding video/audio, resizing/cropping images, HLS/DASH, thumbnails, batch ops, or hardware-accelerated pipelines.
humanizer
Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, passive voice, negative parallelisms, and filler phrases.