Pods Inherit the Node's DNS Resolvers, Including Any ISP Blocklist

In progress Kubernetes Networking Linux

CoreDNS answers cluster names (my-db.default.svc.cluster.local) itself and forwards every other query to the resolvers in the node's /etc/resolv.conf. If the node asks the home router, and the router asks the ISP, every pod gets the ISP's answers, blocked domains included. An app that worked once then fails with vague connection errors.

How ISPs Block Domains

ISPs rarely inspect traffic to block a site. They use DNS sinkholing: their resolver returns a wrong address (or nothing) for a blocked domain. The symptom in an app is a failed TCP connection (ConnectToTcpHostAsync failed), not a clear DNS error.

dig example.org                 # through the default resolver
dig @1.1.1.1 example.org        # through a public resolver: compare the answers

Different answers for the same name point at the resolver.

Fixing It Where It Lasts

Options that persist:

  • Node level: set the resolvers in the network configuration (dns-nameservers 1.1.1.1 8.8.8.8 with resolvconf, a static /etc/resolv.conf when no tool manages it, or DNS= in systemd-resolved).
  • Cluster level: change the forward line of the CoreDNS Corefile (forward . 1.1.1.1 8.8.8.8) to stop depending on the node's file at all.
  • Network level: hand out a public resolver in the router's DHCP settings.

After changing the node's resolvers, restart CoreDNS (kubectl -n kube-system rollout restart deployment coredns): it reads them at startup.

References

Review cards

Flashcard Why might an application that worked once suddenly fail with vague connection errors in a Kubernetes pod?

The application might be using the node's DNS resolvers, which could include ISP blocklists, causing the pod to receive incorrect or blocked DNS responses.

Flashcard How can an ISP block a domain using DNS sinkholing?

An ISP can block a domain by returning a wrong address or no address for the blocked domain in its DNS responses.