Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I see more and more servers that have no domain defined in the /etc/resolv.conf file. Only a search entry.
In what cases is this setup used ?
Are there any cases where it must not be used ?

nameserver xxx.xxx.xxx.xxx
nameserver yyy.yyy.yyy.yyy
nameserver zzz.zzz.zzz.zzz

search domain1 domain2 domain3 ...
share|improve this question
1  
From man resolv.conf : "domain Local domain name. Most queries for names within this domain can use short names relative to the local domain. If set to '.', the root domain is considered. If no domain entry is present, the domain is determined from the local hostname returned by gethostname(2); the domain part is taken to be everything after the first '.'. Finally, if the hostname does not contain a domain part, the root domain is assumed." –  schaiba May 6 at 11:13

1 Answer 1

up vote 4 down vote accepted

When you specify a domain it becomes the first search domain. This is the main use of setting the domain so you can get away most of the time with just the search entry.

Also the domain can be automatically determined from the host name of the machine if the name contains a .

The main difference without a domain would be local processes trying to determine a fully qualified domain name (FQDN). SMTP servers come to mind initially as something that might like to know the local FQDN but as time goes on the local host name and domains are relied on less and less as it's becoming meaningless to the service a machine actually represents in the real world due to things like NAT, virtual hosting and load balancers. This means most software provides alternative configuration options for domain names.

man resolv.conf

domain Local domain name.
Most queries for names within this domain can use short names relative to the local domain. If no domain entry is present, the domain is determined from the local hostname returned by gethostname(2); the domain part is taken to be everything after the first '.'. Finally, if the hostname does not contain a domain part, the root domain is assumed.

search Search list for host-name lookup.
The search list is normally determined from the local domain name; by default, it contains only the local domain name. 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. The search list is currently limited to six domains with a total of 256 characters.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.