Configure Linux / UNIX Dns Resolver To Append Domain Search Names And Path ( ndots options )
I‘m using CentOS Linux server version 5.x/6.x+. How do I configure a system so that the DNS resolver will append search path extensions to hostnames that have dots in them? For example, my domain name is test.com. when I query for mail hostname it should append .test.com and return the IP address of mail.test.com hostname.
You can easily configure the domain search list. The search list is normally determined from the local domain name; by default, it contains only the local domain name. [donotprint][/donotprint]This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found. For environments with multiple subdomains please read options ndots:n below to avoid man-in-the-middle attacks and unnecessary traffic for the root-dns-servers. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains are not local, and that queries will time out if no server is available for one of the domains.
Task: SETUP DNS SEARCH LIST FOR HOST-NAME LOOKUP
Open /etc/resolv.conf file, enter:
# vi /etc/resolv.conf
$ sudo vi /etc/resolv.conf
Now add search path as follows:
Save and close the file.
Optional ntdots configuration
Please note that you may also need to use ndots:n option to sets a threshold for the number of dots which must appear in a name given to query before an initial absolute query will be made. The default for n is “1”, meaning that if there are any dots in a name, the name will be tried first as an absolute name before any search list elements are appended to it. For example set ndots to 2 as follows, to answer nslookup f1.mail query to get IP for f1.mail.in.test.com hostname:
## config file - /etc/resolv.conf ##
search test.com in.test.com
Save and close the file.
$ host f1 $ host mail $ dig smtp
- The search list is currently limited to six domains with a total of 256 characters.
Help /etc/resolv.conf file overwritten by dhclient on a Linux based system
You may find that /etc/resolve.conf is being generated and overwritten by dhcp client, so any changes made to /etc/resolv.conf file will be subsequently overwritten. See how to fix this issue by reading the following tutorial: