/etc/resolv.conf文件中的search项作用-不能去掉

resolv.conf文件中有search项时,主机名解析规则顺序: 
DNS配置文件如下:

# vi /etc/resolv.conf
# Generated by NetworkManager
search openstack.local dev.com example.local
nameserver 192.168.122.21

例1:查询主机名,因为主机名后面没有点,就认为是主机名,所以先添加search里的每一项依次组成FQDN(完全合格域名)来查询,完全合格域名查询未找到,就再认为主机名是完全合格域名来查询。

# 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 be reached

例2:查询主机名,因为主机名中有点(不是末尾有点),就认为是完全合格域名,先用它来查询,查询失败就把它当成是主机名来进行,添加search里的每一项组成FQDN(完全合格域名)来查询。

# 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 125 bytes from 192.168.122.21#53 in 55 ms

例3:查询主机名,因为主机名中末尾有点,则认为是完全合格域名,只用它来查询(不会再添加search里的每一项)。查询次数会与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 be reached

原始文章链接:https://blog.csdn.net/hxpjava1/article/details/80179235

猜你喜欢

转载自blog.csdn.net/evermet/article/details/84711465