Docs / Troubleshooting / Fix Slow DNS Resolution on Linux Servers

Fix Slow DNS Resolution on Linux Servers

By Admin · Mar 15, 2026 · Updated Apr 23, 2026 · 409 views · 2 min read

Slow DNS resolution can make your entire server feel sluggish — every HTTP request, database connection, and API call starts with a DNS lookup. When DNS is slow, everything is slow. This guide covers diagnosing and fixing DNS performance issues on Linux servers.

Measuring DNS Performance

# Time a DNS lookup
time dig example.com
# Look at "Query time" at the bottom — should be under 50ms

# Test specific DNS servers
dig @1.1.1.1 example.com +stats
dig @8.8.8.8 example.com +stats
dig @127.0.0.53 example.com +stats  # systemd-resolved

# Multiple resolution methods
time getent hosts example.com
time nslookup example.com
time host example.com

# Check what's configured
cat /etc/resolv.conf
resolvectl status  # systemd-resolved
nmcli dev show | grep DNS

Common Causes and Fixes

1. Misconfigured resolv.conf

# Check current DNS configuration
cat /etc/resolv.conf

# Common issues:
# - Pointing to a slow/dead DNS server
# - Missing nameserver entries
# - search domain causing extra lookups

# Fix: Set fast public DNS
cat > /etc/resolv.conf  /etc/systemd/resolved.conf  /etc/resolv.conf

# Verify caching works
dig example.com  # First query: ~30ms
dig example.com  # Cached query: ~0ms

5. DNS Rate Limiting or Throttling

# Some DNS providers rate-limit heavy users
# Symptoms: DNS works fine initially, then gets slow

# Fix: Use multiple DNS providers with rotation
cat > /etc/resolv.conf  /etc/docker/daemon.json > /var/log/dns-latency.log
    sleep 60
done

# Alert if DNS is slow
dns_time=$(dig +noall +stats example.com | grep "Query time" | awk '{print $4}')
if [ "$dns_time" -gt 100 ]; then
    echo "DNS is slow: ${dns_time}ms" | mail -s "DNS Alert" admin@example.com
fi

Best Practices

  • Always run a local DNS cache (systemd-resolved or dnsmasq) on servers
  • Use multiple upstream DNS servers with the rotate option
  • Check for IPv6 issues — AAAA timeouts are the #1 cause of slow DNS on servers without IPv6
  • Set short timeouts: options timeout:2 attempts:2 prevents long waits for dead servers
  • Monitor DNS latency as part of your server monitoring
  • Use DNS over TLS/HTTPS for privacy and to prevent ISP DNS manipulation

Was this article helpful?