The central file that controls your resolver setup is host.conf. It resides in /etc and tells the resolver which services to use, and in what order. Options in host.conf must occur on separate lines. Fields may be separated by white space (spaces or tabs). A hash sign (#) introduces a comment that extends to the next newline.
A sample file for vlager is shown below:
# /etc/host.conf # We have named running, but no NIS (yet) order bind hosts # Allow multiple addrs multi on # Guard against spoof attempts nospoof on # Trim local domain (not really necessary). trim vbrew.com.
网上关于这方面的结算少之又少，这篇文章 Configuring Name Server Lookups–resolv.conf 是唯一一篇让我觉得满意的，下面直接引用了，并且加上注解和说明。
When configuring the resolver library to use the BIND name service for host lookups, you also have to tell it which name servers to use. There is a separate file for this, called resolv.conf. If this file does not exist or is empty, the resolver assumes the name server is on your local host. If you run a name server on your local host, you have to set it up separately, as will be explained in the following section. If your are on a local network and have the opportunity to use an existing nameserver, this should always be preferred.
The most important option in resolv.conf is
nameserver, which gives the IP-address of a name server to use. If you specify several name servers by giving the nameserver option several times, they are tried in the order given. You should therefore put the most reliable server first. Currently, up to three name servers are supported.
The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all the name servers until a maximum number of retries are made.
If no nameserver option is given, the resolver attempts to connect to the name server on the local host.
Two other options,
searchdeal with default domains that are tacked onto a hostname if BIND fails to resolve it with the first query. The search option specifies a list of domain names to be tried. The list items are separated by spaces or tabs.
If no search option is given, a default search list is constructed from the local domain name by using the domain name itself, plus all parent domains up to the root. The local domain name may be given using the domain statement; if none is given, the resolver obtains it through the getdomainname(2) system call.
search和domain配置项有点类似于no host entry found exception handler。就是当nameserver返回找不到域名解析的时候，BIND会尝试使用这两个配置项再做一下尝试。但是它们提供的是主域名（顶级域名），用于方便使用 short name 查询。search的优先级高于domain，如果search没有配置，则会采用domain的配置。如果domain也没有配置，会使用
If this sounds confusing to you, consider this sample resolv.conf file for the Virtual Brewery:
# /etc/resolv.conf # Our domain domain vbrew.com # # We use vlager as central nameserver: nameserver 18.104.22.168
When resolving the name vale, the resolver would look up vale, and failing this, vale.vbrew.com, and vale.com.
- ping blog.arganzheng.me
- nslookup blog.arganzheng.me 22.214.171.124
- dig blog.arganzheng.me