resolving dns timeouts linux and mac

If your primary DNS server fails, it can leave your computer / server in quite a pickle.  Many services on servers require adequate DNS performance, and your desktop won’t browse without one.

Although DNS servers are very reliable these days, it is wise to use two at least.  But, that won’t do you much good as the OS will take up to 30 seconds before switching to the second one in the list EACH time a look up is called.  Improve this default behavior with this simple adjustment:

NOTE: As always, backup your configs of anything before making changes.  Save yourself the hassle if things do go as planned.

cp /etc/resolv.conf /etc/resolv.conf.org

Then, your favorite editor, open and edit the file:

/etc/resolv.conf

Ensure you have at least 2 DNS servers listed, then add this text on it’s own line:

options timeout:1

Snippet from the man page:

https://www.kernel.org/doc/man-pages/online/pages/man5/resolver.5.html

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.

- M3Server.com - Word Class Hosting