search domain1[ domain2[ .... [ domain6]]]
The search entry defines for the resolver daemon several domain names for the requests to the DNS name server(s).
The following must be observed here:
A maximum of one search entry can be valid in the configuration file /etc/resolv.conf. If the configuration file contains several search entries but no domain entries, the last search entry applies.
domain and search entries invalidate each other, so if there are several domain and search entries in the configuration file, the domain entry and search entry which apply are those which are not followed by a further domain or search entry.
The function of the search entry depends on whether or not the DNS name specified in the DNS request contains a dot (.).
Function of the search entry if the specified DNS name includes a dot:
If a DNS request for a specific name cannot be successfully answered by the DNS server, the DNS resolver daemon issues a new DNS request with name.domain1 to the DNS server.
If even this DNS request cannot be successfully answered by the DNS server, the DNS resolver repeats the DNS request with the next domain name domainx (x = 2 - 6) defined in the search entry. This is repeated until either the DNS request is successfully answered by the DNS server or no further domain names are defined in the search entry.
Example
The following example shows the requests generated by the DNS resolver daemon to a DNS server:
Entry in the /etc/resolv.conf configuration file:
search mch.fj.example fj.example
Name specified by the user:
my.host
Names generated by the DNS resolver daemon for requests to a DNS server:
my.host
my.host.mch.
fj.examplemy.host.
fj.example
Function of the search entry if the specified DNS name does not include a dot:
A DNS request with name.domain1 is initially issued to the DNS server. If this DNS request is not successfully answered by the DNS server, the DNS resolver daemon then repeats the request using the next domain name domainx (x = 2 to 6) defined in the search entry. This is repeated until either the DNS request is successfully answered by the DNS server or no further domain names are defined in the search entry.
If no DNS request has been successfully answered by the DNS server after all domain names defined in the search statement have been processed, a DNS request is issued with name.
Example
The following example shows the requests generated by the DNS resolver daemon to a DNS server.
Entry in the /etc/resolv.conf: configuration file:
search mch.fj.example fj.example
Name specified by the user:
myhost
Names generated by the DNS resolver daemon for requests to a DNS server:
myhost.mch.
fj.examplemyhost.
fj.examplemyhost