Intermittent DNS failures in EKS: it was ndots and conntrack exhaustion, not CoreDNS

Random "Temporary failure in name resolution" errors on EKS turned out to be two problems stacked together: the Kubernetes ndots default multiplying DNS queries, and the EC2 connection-tracking limit dropping packets. This article shows how I found both with node exporter and Grafana, and the four changes that fixed them.

Cloud & DevOps Architect | RHCA | OpenShift, Kubernetes, AWS, GCP, Terraform, GitOps

The symptom

Our EKS services kept failing to resolve hostnames, and the same error came back at random: "Temporary failure in name resolution". The DevOps team had seen it before and worked around it each time. When I took over as Cloud Architect, the ask was to fix it permanently.
Nothing looked broken. Pods were healthy, the cluster was stable, the CoreDNS replicas were running, and there were no crashes and no alerts. The metrics told a different story: about 80% of our DNS queries were coming back with the NXDOMAIN response code.
It turned out to be two separate problems stacked on top of each other. The first was a Kubernetes DNS default. The second sat below Kubernetes, at the EC2 networking layer.

Finding 1: ndots=5 turned one hostname into a DNS storm

When I traced DNS query volume by hostname, one name accounted for 80 to 90% of all queries: our RabbitMQ endpoint,  rabbitmq.eu-west-1.aws.company.production . It has four dots, and Kubernetes pods default to  ndots:5 , so the resolver does not treat it as fully qualified. Every pod's  /etc/resolv.conf  looks like this:
search default.svc.cluster.local svc.cluster.local cluster.local eu-west-1.compute.internal
nameserver 172.20.0.10
options ndots:5
If a name has fewer dots than  ndots , the resolver appends each search domain in turn before trying the name as written. For our RabbitMQ host, that meant four failed lookups before the correct one:
rabbitmq.eu-west-1.aws.company.production.default.svc.cluster.local NXDOMAIN
rabbitmq.eu-west-1.aws.company.production.svc.cluster.local NXDOMAIN
rabbitmq.eu-west-1.aws.company.production.cluster.local NXDOMAIN
rabbitmq.eu-west-1.aws.company.production.eu-west-1.compute.internal NXDOMAIN
rabbitmq.eu-west-1.aws.company.production OK
Each attempt is sent twice, as an A and an AAAA query, so every valid lookup generated 4 to 8 extra queries. RabbitMQ is used by nearly every service, so we were not just resolving DNS, we were manufacturing DNS traffic.

The quick fix: a trailing dot

As a fast mitigation I added a trailing dot to the hostname:  rabbitmq.eu-west-1.aws.company.production. . The dot marks the name as fully qualified, so the resolver skips the search list. The NXDOMAIN flood dropped immediately and CoreDNS CPU fell by about 50%.

Benchmark

I measured the effect with an async Python resolver that honours  /etc/resolv.conf , issuing N concurrent queries for the same host from inside a pod:
#!/usr/bin/env python3
import argparse
import asyncio
import time

import dns.asyncresolver

async def main() -> None:
parser = argparse.ArgumentParser(
description="Measure DNS lookup time using the current resolv.conf (ndots/search)."
)
parser.add_argument("host", help="Hostname to resolve")
parser.add_argument("-n", "--queries", type=int, default=100,
help="Number of concurrent queries (default: 100)")
parser.add_argument("-t", "--timeout", type=float, default=2.0,
help="Per-query timeout in seconds (default: 2.0)")
args = parser.parse_args()

resolver = dns.asyncresolver.Resolver() # respects ndots/search
resolver.timeout = args.timeout
resolver.lifetime = args.timeout
resolver.use_edns = False

async def one_query() -> None:
try:
await resolver.resolve(args.host, "A", search=True)
except Exception:
pass # only timing matters here

tasks = [asyncio.create_task(one_query()) for _ in range(args.queries)]
start = time.monotonic()
await asyncio.gather(*tasks)
elapsed = time.monotonic() - start
print(f"{args.queries} queries for '{args.host}' in {elapsed:.3f}s ({elapsed/args.queries:.4f}s/query)")

if __name__ == "__main__":
asyncio.run(main())
Queries
Hostname form
Total time
Time per query
100
without trailing dot
2.207 s
0.0221 s
100
with trailing dot
0.399 s
0.0040 s
10
without trailing dot
0.302 s
0.0302 s
10
with trailing dot
0.095 s
0.0095 s
Lookups were roughly 3x to 5x faster with the trailing dot, depending on the number of concurrent queries, and the NXDOMAIN traffic dropped by almost half.

Finding 2: the real bottleneck was conntrack exhaustion at the EC2 layer

The trailing dot removed most of the noise, but I did not want to stop at one hostname. While investigating, I first looked at CoreDNS and NodeLocal DNS metrics, and they did not explain everything. The breakthrough came when I started correlating the DNS failures with instance-level network limits that AWS enforces below Kubernetes.
The EC2 ENA driver exposes these limits as counters through  ethtool . Each  *_allowance_exceeded  counter records packets queued or dropped because the instance hit a limit, and in a healthy cluster all of them stay at zero:
Metric
What it counts
 linklocal_allowance_exceeded 
Packets dropped because traffic to link-local services (DNS, IMDS, Amazon Time Sync) exceeded the packets-per-second limit
 conntrack_allowance_exceeded 
Packets dropped because the connection-tracking limit was exceeded and new connections could not be established
 conntrack_allowance_available 
Connections that can still be tracked before reaching the limit (Nitro instances only)
 pps_allowance_exceeded 
Packets queued or dropped because the bidirectional packets-per-second limit was exceeded
 bw_in_allowance_exceeded  /  bw_out_allowance_exceeded 
Packets queued or dropped because inbound or outbound aggregate bandwidth exceeded the instance limit
My first suspect was  linklocal_allowance_exceeded , because DNS traffic counts against the fixed link-local limit of 1024 packets per second, which does not grow with instance size. That panel stayed at zero. The counter that was rising was  conntrack_allowance_exceeded : the nodes were running out of connection-tracking capacity and dropping packets.
That explains why DNS failed while CPU, memory and pod-level metrics all looked healthy. The bottleneck was below Kubernetes, and it fits Finding 1: every extra NXDOMAIN lookup is another UDP flow the node has to track.
To catch it, I built a Grafana dashboard that puts the number of "Temporary failure in name resolution" errors found in the application logs next to these node-level network metrics. Every time the errors appeared in the logs, the rate of packets dropped because connection tracking was exceeded increased at the same time. That correlation is what pointed me to conntrack rather than to CoreDNS. I no longer have the raw graphs from the incident, so I am not quoting figures here. In your own cluster, look for a sustained non-zero rate on this metric for the affected nodes.

How to capture the network allowance metrics

The pipeline is: the ENA driver exposes the counters through  ethtool , node exporter collects them, Prometheus scrapes them and Grafana draws them. On Amazon Linux EKS nodes  ethtool  is installed by default, so the only change is enabling the  ethtool  collector in node exporter. Add these arguments to the node exporter container:
containers:
- args:
- --collector.ethtool
- --collector.ethtool.device-include=(eth|em|eno|ens|enp)[0-9s]+
- --collector.ethtool.metrics-include=.*
After the rollout the metrics appear in Prometheus with a  node_ethtool_  prefix. Build one time series panel per metric, split by node, so you can line up saturation with DNS errors and latency.
The available tracking capacity is a gauge, so it can be charted directly:
node_ethtool_conntrack_allowance_available{job="node-exporter"}
The  *_allowance_exceeded  metrics are counters that only ever increase, so chart them as a per-second rate:
sum by (instance) (
rate(node_ethtool_conntrack_allowance_exceeded{job="node-exporter"}[1m])
)
Repeat the same counter-to-rate pattern for the other four metrics:
  •  node_ethtool_bw_in_allowance_exceeded 
  •  node_ethtool_bw_out_allowance_exceeded 
  •  node_ethtool_pps_allowance_exceeded 
  •  node_ethtool_linklocal_allowance_exceeded 
Any sustained non-zero rate means that instance is hitting an EC2 networking limit.

Correlating DNS errors with the drops

The metrics alone do not tell you whether the drops are hurting DNS. The step that made the link for me was counting the resolution errors in the application logs and plotting them on the same time axis as the network panels. My logs are in Loki, and this query counts the errors per namespace in 5-minute windows:
sum by (namespace) (
count_over_time(
{namespace!="", namespace!="monitoring"}
|= "Temporary failure in name resolution"
[5m]
)
)
The dashboard has three sections, so you can read down from symptom to cause:
  1. DNS errors: the query above by namespace and in total, plus the raw log lines.
  1. DNS queries in detail: the top source IPs and the top hostnames by query rate, built from the CoreDNS and NodeLocal DNSCache logs, plus the DNS request rate per node and per job.
  1. Network metrics: one panel per ENA allowance counter from the table above.
When the error count in section 1 rose, the conntrack drop panel in section 3 rose with it, while the link-local panel stayed at zero. The dashboard is available to import; see "Get the dashboard" below.

Get the dashboard

The full EKS DNS Visibility dashboard (16 panels) is published as a GitHub gist:  EKS_DNS_Visibility.json .
To use it:
  1. Download the JSON from the gist.
  1. In Grafana, go to Dashboards > New > Import and upload the file.
  1. The panels use Prometheus and Loki, so if a panel shows no data, open it and point it at your own data sources.
The panels that matter most for this problem are the DNS error count from the logs, the conntrack drop rate, and the link-local drop rate. Put them on the same time range, and you can see whether the errors line up with the drops.

The fix: four changes

The root cause was too many DNS flows per node, so the fix combined removing needless queries with giving DNS more room. We made four changes:
  1. Use fully qualified names with a trailing dot for external hostnames, such as  rabbitmq.eu-west-1.aws.company.production. . This removes the search-domain expansion entirely and is the cheapest change.
  1. Lower  ndots  to 2 for workloads that mostly call external hosts, so names with two or more dots are tried as written first.
  1. Install NodeLocal DNSCache, which runs a DNS cache on every node so most queries are answered locally instead of going to CoreDNS. Pods then query the caching agent on their own node instead of the CoreDNS service IP, which avoids iptables DNAT rules and connection tracking. The Kubernetes docs list this as a motivation: skipping DNAT and connection tracking reduces conntrack races and stops UDP DNS entries from filling up the conntrack table. That is exactly the failure mode we hit.
  1. Increase the number of CoreDNS replicas so the load is spread across more pods. We went from 3 replicas to 5.

Setting ndots in the pod spec

spec:
dnsConfig:
options:
- name: ndots
value: "2"
The AWS EKS best practices guide recommends the same two options for reducing CoreDNS load: lower  ndots , or fully qualify domain names with a trailing dot.

Results and how to tell which problem you have

After the four changes, the DNS failures stopped and the developers stopped pinging me about name resolution. I did not keep the before/after graphs from the incident, so I am not quoting conntrack figures. The measured result I can show is the  ndots  benchmark in Finding 1: lookups were 3x to 5x faster and CoreDNS CPU fell by about 50% after the trailing dot.
If you see intermittent DNS failures on EKS, use the signal you observe to pick the fix:
Signal
What it means
Where to look first
High share of NXDOMAIN responses, concentrated on a few hostnames
Search-domain expansion from  ndots:5 
Trailing dot or lower  ndots 
 linklocal_allowance_exceeded  above zero
DNS, IMDS or time sync traffic exceeds the fixed 1024 packets-per-second link-local limit
More CoreDNS replicas, NodeLocal DNSCache,  ndots 
 conntrack_allowance_exceeded  above zero
The node cannot track any more connections
Fewer DNS flows ( ndots , trailing dot, NodeLocal DNSCache), or a larger instance
 pps ,  bw_in  or  bw_out  allowance exceeded above zero
The instance is hitting its packet or bandwidth limit
A larger or different instance type, or less load on the node
The link-local limit is the one exception to instance sizing: it is fixed at 1024 packets per second, so a bigger instance does not raise it.

Takeaways

If you are debugging intermittent DNS failures on EKS, do not stop at CoreDNS metrics.
  • Check which hostnames dominate your DNS traffic and how many of the responses are NXDOMAIN. The  ndots:5  default is right for in-cluster service discovery but expensive for external names.
  • Check the instance-level network allowance counters. All  *_allowance_exceeded  metrics should stay at zero, and any sustained non-zero rate is a bottleneck below Kubernetes that pod metrics will not show.
  • Alert on both, so the next rollout that introduces a bad hostname or an overloaded node shows up before users notice: the NXDOMAIN ratio in CoreDNS, and any  node_ethtool_*_allowance_exceeded  rate above zero.
The smallest defaults can cause the biggest reliability problems.

References

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article