/etc/resolv.conf文件中的search项作用;如何保持resolv.conf文件内容不被修改
/etc/resolv.conf文件中的search项作用
resolv.conf文件中有search项时,主机名解析规则顺序:
DNS配置文件如下:
# cat /etc/resolv.conf ; generated by /usr/sbin/dhclient-script search aqiyi.domain aqiyi.virtual ksc.com nameserver 8.8.8.8
例1:查询主机名,因为主机名后面没有点,就认为是主机名,所以先添加search里的每一项依次组成FQDN(完全合格域名)来查询,完全合格域名查询未找到,就再认为主机名是完全合格域名来查询。
# host -a testttttttttt Trying "testttttttttt.aqiyi.domain" Trying "testttttttttt.aqiyi.virtual" Trying "testttttttttt.ksc.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14314 ;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;testttttttttt.ksc.com. IN ANY ;; ANSWER SECTION: testttttttttt.ksc.com. 3599 IN A 69.172.201.153 testttttttttt.ksc.com. 3599 IN NS ns1.uniregistrymarket.link. testttttttttt.ksc.com. 3599 IN NS ns2.uniregistrymarket.link. testttttttttt.ksc.com. 3599 IN SOA ns1.uniregistrymarket.link. hostmaster.hostingnet.com. 1555555555 10800 3600 604800 86400 testttttttttt.ksc.com. 3599 IN MX 1 mx247.in-mx.com. testttttttttt.ksc.com. 3599 IN MX 1 mx247.in-mx.net. Received 230 bytes from 8.8.8.8#53 in 625 ms
例2:查询主机名,因为主机名中有点(不是末尾有点),就认为是FQDN(完全合格域名)来查询。
# host -a testttttttttt.com Trying "testttttttttt.com" Host testttttttttt.com not found: 3(NXDOMAIN) Received 108 bytes from 8.8.8.8#53 in 43 ms Received 108 bytes from 8.8.8.8#53 in 43 ms
如何保持resolv.conf文件内容不被修改 (CentOS7)
当文件被dhcp服务管理时。通过dhcp配置文件设置dns地址和默认搜索域
# vim etc/dhcp/dhclient.conf interface "eth0" { supersede domain-name-servers 8.8.8.8 ; supersede domain-name "aqiyi.domain aqiyi.virtual" ; }
cat /etc/resolv.conf ; generated by /usr/sbin/dhclient-script search aqiyi.domain aqiyi.virtual nameserver 8.8.8.8
posted on 2020-09-13 21:45 zhangmingda 阅读(2306) 评论(0) 编辑 收藏 举报