System

How to improve DNS lookups on Linux system

Domain-Name-DNS-Lookup On Linux, listing multiple DNS servers in /etc/resolve.conf defines a primary DNS, secondary DNS, and so on. If the primary DNS becomes unavailable, the system uses the secondary. By default, this switch takes about five seconds: the system waits for a timeout before using the secondary. When such a failure occurs, applications that perform DNS lookups become slower than normal. This article explains how to improve DNS lookups on systems with more than one nameserver and reduce the impact of a primary DNS failure. Improving DNS lookup performance Edit /etc/resolv.conf and add the following options.

options rotate 
options timeout:1 attempts:5
options single-request-reopen

These options rotate through all nameservers, set the wait time to one second before trying the next nameserver, and force A and AAAA queries to use a single socket. * This change may still be insufficient for systems requiring very fast lookups. You may need to combine it with other methods, such as:

  1. Using a cluster (load balancing or HA).
  2. Changing the nameserver order in resolv.conf.
EOF.← Back to articles