Member-only story

Disabling IPv6 for DNS on self-hosted Kubernetes

tjtharrison
1 min readSep 25, 2023

--

I recently noticed that some lookups on my cluster were failing due to them being resolved as IPv6 rather than IPv4.

In the interest of simplicity and to save investigating this further, I would like for all DNS lookups on my cluster to resolve to the IPv4 address of the destination.

Luckily this is a quick fix if you are using coredns for your DNS resolution in your cluster.

Photo by Uriel SC on Unsplash

The fix

The only change required is to add the following line to your coredns configuration:

rewrite stop type AAAA A

To do this, edit the configmap coredns in the kube-system namespace:

kubectl edit cm -n kube-system coredns

Add the above line to the top of the configuration for port .:53 — Eg as below:

apiVersion: v1
data:
Corefile: |
.:53 {
rewrite stop type AAAA A
errors
health {
lameduck 5s
}

Save the config map before restarting the deployment using the below command:

kubectl rollout restart deployment coredns -n kube-system

You should now find that all DNS requests in your cluster resolve to IPv4 addresses

--

--

tjtharrison
tjtharrison

Written by tjtharrison

DevSecOps | Security | Infrastructure

No responses yet