💡 Kubernetes CoreDNS Corefile Customization — Executive Summary
Technical architectural analysis, practical configuration manifests, and deployment instructions for Kubernetes CoreDNS Corefile Customization.
Docs
About resolv.conf
References and Guidelines (NOTE)
CoreDNS operation when using systemd-resolved on host
HostNode:
systemd-resolvedis fixed as/etc/resolv.conf = 127.0.0.53loopback address.- The actual resolve defined in
/etc/systemd/resolved.confis/var/run/systemd/resolve/resolv.conf.
Kubelet:
- Default mounts
/etc/resolv.confon HostNode. - Kublet cannot access the loopback address
127.0.0.53.
References and Guidelines (NOTE)
Kubernetes:
- Kubelet Configuration (v1beta1)
--resolv-conf=/var/run/systemd/resolve/resolv.conf
k3s:
bash
k3s server --resolv-conf $value
curl -sfL https://get.k3s.io | sh -s - server --resolv-conf $value
Features
Block AAAA=IPv6
References and Guidelines (NOTE)
Response when IPv6 outbound is blocked outside the node network
bash
data:
Corefile: |
.:53 {
...
template IN AAAA {
rcode NOERROR
}
...kubernetes
}
test
– Before change
bash
k exec -it dnsutils -- nslookup -type=aaaa bitbucket.org
>>>
Server: 10.43.0.10
Address: 10.43.0.10#53
Non-authoritative answer:
Name: bitbucket.org
Address: 2401:1d80:3224:2:0:bbc:1:df7c
Name: bitbucket.org
Address: 2401:1d80:3224::bbc:1:df7c
Name: bitbucket.org
Address: 2401:1d80:3224:1:0:bbc:1:df7c
<<<
– After changes
bash
k exec -it dnsutils -- nslookup -type=aaaa bitbucket.org
>>>
Server: 10.43.0.10
Address: 10.43.0.10#53
*** Can't find bitbucket.org: No answer
<<<
Specify name server other than resolv.conf
bash
#before
data:
Corefile: |
.:53 {
...
forward . /etc/resolv.conf
}
}
#after
data:
Corefile: |
.:53 {
...
forward . 8.8.8.8
}
}
Specify DNS when matching a specific domain
bash
Corefile: |
.:53 {
#...
}
# 추가: **.my.domain 도메인 우선 DNS 지정
my.domain:53 {
errors
cache 30
forward . $my_dns_ip
}
Feature
DNS separation and host override
bash
apiVersion: v1
data:
Corefile: |-
fredric18.internal:53 {
errors
cache 30
forward . 192.168.1.1
}
.:53 {
hosts {
192.168.118.13 rancher.mgnt.fredric18.uk
fallthrough
}
errors
health {
lameduck 10s
}
ready
kubernetes cluster.local cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus 0.0.0.0:9153
forward . 8.8.8.8
cache 30
loop
reload
loadbalance
}
kind: ConfigMap
metadata:
annotations:
meta.helm.sh/release-name: rke2-coredns
meta.helm.sh/release-namespace: kube-system
creationTimestamp: "2025-12-07T14:45:59Z"
labels:
app.kubernetes.io/instance: rke2-coredns
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: rke2-coredns
helm.sh/chart: rke2-coredns-1.43.302
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: CoreDNS
name: rke2-coredns-rke2-coredns
namespace: kube-system
resourceVersion: "140240348"
uid: 0cd77e69-2946-4914-9379-e25798e59646




Leave a Reply