Debug Kubernetes Networking & DNS: Step-by-Step
In this article
This guide walks you through diagnosing and fixing common Kubernetes networking and DNS issues. You'll learn a systematic approach—from checking pod-to-pod connectivity to inspecting CoreDNS and service resolution—so you can quickly identify whether the problem is in your cluster's CNI, kube-proxy, or DNS configuration.
What You'll Need
- Access to a Kubernetes cluster (kubectl configured with appropriate permissions)
- Basic familiarity with kubectl commands and YAML manifests
- Optional: a tool like
netshootorbusyboxfor running diagnostic containers
Step-by-Step
- Verify the basics – Start by checking cluster health:
kubectl get nodesandkubectl get pods -A. Ensure all nodes are Ready and that core system pods (kube-system) are Running. If a node is NotReady, fix that first—networking issues often stem from node problems. - Check pod-to-pod connectivity – Deploy a simple test pod (e.g.,
kubectl run test --image=busybox -- sleep 3600) and try to ping or connect to another pod's IP. If that fails, the CNI (Container Network Interface) plugin may be misconfigured. Check CNI pods:kubectl get pods -n kube-system | grep -E 'calico|flannel|weave|cilium'and inspect their logs. - Test service connectivity – If pods can talk to each other but not to a Service, the issue is likely kube-proxy or the Service definition. Get the Service's ClusterIP:
kubectl get svc, then from a test pod runwget. If that fails, check kube-proxy pods:: kubectl get pods -n kube-system -l k8s-app=kube-proxyand their logs. - Inspect kube-proxy rules – On a node, run
iptables -L -n | grep(oripvsadm -L -nif using IPVS) to see if the Service's IP is present. If not, kube-proxy may not be running or the Service's selector doesn't match any pods. - Check DNS resolution – From a test pod, run
nslookup kubernetes.default.svc.cluster.local. If it fails, CoreDNS is likely down or misconfigured. Check CoreDNS pods:kubectl get pods -n kube-system -l k8s-app=kube-dnsand their logs. - Inspect CoreDNS config – View the CoreDNS ConfigMap:
kubectl get configmap -n kube-system coredns -o yaml. Ensure theforward . /etc/resolv.confline is present. If you've customized it, verify the syntax. - Test DNS from outside the cluster – If DNS works inside but not outside, the issue may be with upstream resolvers or network policy. Check the node's /etc/resolv.conf and ensure it's reachable.
- Check Network Policies – If you have NetworkPolicies, they may be blocking traffic. Run
kubectl get networkpolicies -Aand review them. Temporarily delete a policy to test if it's the cause. - Check for IP conflicts – If pods get duplicate IPs, routing breaks. Inspect the CNI's IPAM logs. For example, with Calico, check
calico-nodelogs for IP allocation errors. - Restart components as a last resort – After confirming configuration is correct, restarting CoreDNS or kube-proxy can resolve transient issues:
kubectl rollout restart deployment -n kube-system corednsandkubectl rollout restart daemonset -n kube-system kube-proxy.
Common Mistakes
- Ignoring node status – Networking problems often originate from a NotReady node, but people jump straight to DNS debugging.
- Using the wrong DNS name – For a service in another namespace, you must use
svc.namespace.svc.cluster.local, not justsvc. - Forgetting that ping uses ICMP – Some CNIs or cloud providers block ICMP. Use
wgetorncinstead of ping to test TCP connectivity. - Assuming DNS is the problem – If a service doesn't resolve, it might be because the service doesn't exist or has no endpoints. Check
kubectl get endpoints. - Overlooking firewall rules – Cloud security groups or node firewalls can block inter-node traffic, even if the CNI is fine.
Tips
- Use a dedicated debug pod with tools like
netshoot(from Docker) that includesdig,tcpdump, andcurl. - Check the CoreDNS metrics:
kubectl get svc -n kube-system kube-dnsand then curl the metrics endpoint if exposed. - When testing DNS, use
nslookupwith the full FQDN and also try the short name to isolate search domain issues. - Look at the kubelet logs on the node if pods can't get IPs:
journalctl -u kubelet -f. - If you're using a managed Kubernetes service (EKS, GKE, AKS), check the provider's documentation for known networking quirks.
Troubleshooting
If the steps above don't resolve the issue, try these additional checks:
- Check for resource exhaustion – If CoreDNS or kube-proxy pods are OOMKilled or evicted, increase their memory limits or reduce cluster load.
- Verify the CNI plugin is installed correctly – On each node, check that the CNI binary and configuration file exist (e.g., /etc/cni/net.d/).
- Look at the kube-proxy mode – If you're using IPVS, ensure the ipvsadm tool is installed and the kernel modules are loaded (
modprobe ip_vs). - Check for overlapping CIDRs – If your pod CIDR overlaps with your VPC or node CIDR, routing breaks. Verify with
kubectl cluster-info dump | grep -i cluster-cidr. - Use tcpdump – On the source and destination nodes, run
tcpdump -i any port 53to see if DNS queries are being sent and received. - If all else fails, recreate the affected pods – Sometimes a pod gets a stale DNS cache. Delete the pod and let the controller recreate it.
Frequently Asked Questions
Why can't my pod resolve external domain names?
This usually means CoreDNS can't forward queries to upstream resolvers. Check the forward directive in the CoreDNS ConfigMap and ensure the node's /etc/resolv.conf is correct. Also, verify that outbound UDP port 53 is allowed.
Why does my service work from one pod but not another?
This often points to a NetworkPolicy that allows traffic from specific pods only. Check for NetworkPolicies in the namespace and review their selectors. It could also be a DNS search domain issue if the pod is in a different namespace.
How do I test DNS without installing extra tools?
Use kubectl exec to run nslookup or cat /etc/resolv.conf in an existing pod. If your pod lacks those tools, use kubectl run -it --rm test --image=busybox -- nslookup kubernetes.default.
What does 'no such host' mean when resolving a service?
It means the DNS server doesn't have a record for that name. Check that the service exists and that its name is correct. If the service is in another namespace, you must use the fully qualified name.
Can I change the cluster DNS IP?
Yes, but it's not recommended. The DNS IP is set by the kubelet's --cluster-dns flag. Changing it requires restarting all kubelets and updating the CoreDNS service. It's easier to leave it as default.
Why does DNS work on the node but not in a pod?
This is usually because the pod's /etc/resolv.conf points to the kube-dns service IP, which may be unreachable due to a network policy or kube-proxy issue. Check the kube-dns service endpoints and test connectivity to the ClusterIP from the pod.