How to Set Up DNS Lookup in Linux

Posted on in Categories , , , , , , , , , , , , last updated February 5, 2009

Q. How do I setup DNS Lookup under any Linux distribution ?

A. When an application (such as mail client or browser) makes a request which requires a DNS lookup, such programs send a resolution request to the local DNS resolver in the local operating system, which in turn handles the communications required. Under Linux resolver is configured via /etc/resolv.conf file. Open this file as a root user, enter:
# vi /etc/resolv.conf
Append or modify as follows into the file:

Save and close the file. Replace with your actual domain name. is first name server address. Save and close the file. Test setup, enter:
$ host
$ host -t ns

Sample output: name server name server name server

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

  1. A better setup is

    option rotate
    option timeout:1

    ‘rotate’ sets RES_ROTATE in _res.options, which causes round robin selection of nameservers from among those listed.
    ‘timeout’ 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.

Leave a Comment