Options rotate in /etc/resolv.conf is not working for kubernetes pods

968 Views Asked by At

I have added one more nameserver and also rotate options so that for dns resolution, different name servers are picked using round robin fashion but it's picking first name server always. This is my resolv.conf

nameserver 10.96.0.10
nameserver 8.8.8.8
search measurement.svc.cluster.local svc.cluster.local cluster.local
options rotate timeout:1 ndots:5

Second nameserver is never getting picked. I tried running nslookup from kuberenetes pod multiple times. It's always picking first one and that's some cluster level default. Is there some additional configuration change required at k8s level or it has something to do with Coredns policy? I would really appreciate any help.

1

There are 1 best solutions below

3
Srividya On

When you specify multiple name servers in resolv.conf file with options rotate, the resolver library should rotate through each name server in order for each DNS query. However in your case, the second nameserver is being ignored.

This issue could be caused by several factors:

  1. Check if the second nameserver is configured correctly and is reachable.

  2. Ensure the network connectivity is not an issue and check network configuration and firewall settings.

  3. The issue might be caused by DNS caching also. The first name server could be cached and the resolver library might be using a cached response instead of rotating to the next server. Clear the DNS cache to see if it resolves the issue.

  4. Also, try to increase the timeout value in options timeout : 3 or 5 seconds. The first server might be responding faster than the second server, so the resolver library is continuously using the first one.