Interview Prep/Networking/DNS resolution failures

Every DNS lookup on a Linux host takes exactly 5 seconds before succeeding.

IntermediateTroubleshootingDNS resolution failures
Answer

Likely causes → The first nameserver in resolv.conf is dead and glibc waits timeout:5 before trying the next, or AAAA queries are dropped (parallel A/AAAA issue).

Diagnose →

cat /etc/resolv.conf
for ns in $(awk '/^nameserver/{print $2}' /etc/resolv.conf); do dig @$ns example.com +time=2 +tries=1 | grep 'Query time'; done
strace -f -e trace=network getent hosts example.com 2>&1 | head -40

Fix → Remove the dead server. Add options timeout:1 attempts:2 rotate while you fix the root cause, or single-request-reopen for the A/AAAA case.

Prevent → Monitor each resolver individually.

All Networking questions Roadmap: Networking for DevOps

More on DNS resolution failures