Search code examples
linuxsocketsunixnetwork-programmingdns

What will timeout value specified in /etc/resolv.conf do?


For example, resolv.conf in /etc/ looks like this:-

search example.com 
nameserver 172.16.1.254
nameserver 172.16.2.254
options timeout:3
options attempts:2

Here, timeout 3 means 3 seconds. But, what is the significance for timeout value? Is it the time taken to connect to DNS server? OR Is it the time allowed to wait for DNS server to return IP address value for a URL?


Solution

  • Yes exactly. Timeout value is time to resolving IP address from hostname through DNS. server,timeout option is to reduce hostname lookup time

    timeout:n
    sets the amount of time the resolver will wait for a
    response from a remote name server before retrying the
    query via a different name server.  Measured in
    seconds, the default is RES_TIMEOUT (currently 5, see
    <resolv.h>).  The value for this option is silently
    capped to 30.
    

    Refer http://man7.org/linux/man-pages/man5/resolver.5.html for more information