Host name resolution rule order when there are search entries in the resolv.conf file:
The DNS configuration file is as follows:
# vi/etc/resolv.conf
# Generated by NetworkManager
search openstack.local dev.com example.local
NameServer 192.168.122.21
Example 1: Query the hostname, because there is no point after the host name, it is considered the hostname, so first add search in order to make each of the FQDN (fully qualified domain name) to query, fully qualified domain name query is not found, and then think the hostname is fully qualified domain name to query.
# host-a centos7-bind-1
Trying "centos7-bind-1.openstack.local"
Trying "centos7-bind-1.dev.com"
Trying "Centos7-bind-1.example.local"
Trying "centos7-bind-1";
connection timed out; No servers could is reached
Example 2: Query the hostname, because the host name in a bit (not at the end of a bit), it is considered to be a fully qualified domain name, first use it to query, query failure to take it as a hostname to do, add each of the search in the FQDN (fully qualified domain name) to query.
# host-a centos7-bind-1.com
Trying "centos7-bind-1.com"
Received 109 bytes from 192.168.122.21#53 in 177 Ms
Trying "centos7-bind-1.com.openstack.local"
Trying "centos7-bind-1.com.dev.com"
Trying " Centos7-bind-1.com.example.local "
Host centos7-bind-1.com not Found:3 (NXDOMAIN) Received the bytes from
192.168.122.21#53 in MS
Example 3: Query the hostname, because the host name in the end of a bit, it is considered to be a fully qualified domain name, only use it to query (no longer add each item in search). The number of queries will be related to the number of domain names in search.
# host-a centos7-bind-1.
Trying "Centos7-bind-1"
; connection timed out; Trying next Origin
Trying "centos7-bind-1"
;; connection Timed out; Trying next origin
trying "centos7-bind-1";
connection timed out; Trying next origin
trying " Centos7-bind-1 "
;; connection timed out; No servers could being reached
DNS Query tool: Introduction to host Command
Usage: host [-A] FQDN [server]
HOST-L domain [Server]
-A parameter: Displays all the details of the query.
-L parameter: Lists all host data managed by the domain if the following domain allows Allow-transfer.
Server parameters: This parameter is optional, when you want to use a non-/etc/resolv.conf DNS host, to query the host name and IP corresponding, you can use this parameter.
Host command Use example (lists all host data managed by the domain):
# host-l example.local 192.168.122.84
Using domain server:
name:192.168.122.84
Address: 192.168.122.84#53
Aliases:
example.local name server ns.example.local.
Dns.example.local has address 192.168.123.10
ns.example.local have address 192.168.122.84
Ns.example.local has IPV6 Address:: 1
sss.example.local has address 192.168.123.9
www.example.local have address 192.168.123.8