Interview Prep/Linux/Networking, DNS and firewalls

DNS lookups take exactly 5 seconds before succeeding.

IntermediateTroubleshootingNetworking, DNS and firewalls
Answer

Likely causes → The first nameserver in resolv.conf is dead and the resolver times out (default 5 s) before trying the next. Also common: parallel A/AAAA queries dropped by a firewall/conntrack race.

Diagnose →

cat /etc/resolv.conf
for ns in $(awk '/^nameserver/{print $2}' /etc/resolv.conf); do dig +time=2 +tries=1 example.com @$ns | grep -E 'status|Query time'; done

Fix → Remove the dead nameserver; add options timeout:1 attempts:2 rotate, or single-request-reopen for the A/AAAA issue.

Prevent → Monitor each resolver; run a local caching resolver (systemd-resolved, dnsmasq, unbound).

All Linux questions Roadmap: Linux

More on Networking, DNS and firewalls