如何使用 dig 进行相对路径 DNS 查询?
How to make relative path DNS query with dig?
我想使用 dig
进行相对路径 DNS 查询。我参考了 dig(1)
和 resolv.conf(5)
.
的以下文档
dig(1) 说:
+ndots=D
Set the number of dots that have to appear in name to D for it to be considered absolute. The default value is that defined using
the ndots statement in /etc/resolv.conf, or 1 if no ndots statement is
present. Names with fewer dots are interpreted as relative names and
will be searched for in the domains listed in the search or domain
directive in /etc/resolv.conf.
domain Local domain name.
Most queries for names within this domain can use short names relative
to the local domain. If set to '.', the root domain is considered.
If no domain entry is present, the domain is determined from the local
hostname returned by gethostname(2); the domain part is taken to be
everything after the first '.'. Finally, if the hostname does not
contain a domain part, the root domain is assumed.
我的/etc/resolv.conf
:
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
domain nonexist.com
nameserver 100.100.2.136
nameserver 100.100.2.138
但是 运行 dig abc
CentOS Linux release 7.6.1810 (Core) 64 bit OS
结果:
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> abc
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13347
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;abc. IN A
;; AUTHORITY SECTION:
abc. 9080 IN SOA ac1.nstld.com. info.verisign-grs.com. 1573282493 1800 900 604800 86400
;; Query time: 0 msec
;; SERVER: 100.100.2.136#53(100.100.2.136)
;; WHEN: Sat Nov 09 15:23:42 CST 2019
;; MSG SIZE rcvd: 99
我的预期是 abc
后缀为 nonexist.com.
并且在 DNS 查询中使用 abc.nonexist.com.
。但是上面的 QUESTION SECTION
有 abc.
而不是 abc.nonexist.com.
任何人都可以指出我的设置有什么问题吗?
dig(1) 说:
+[no]search
Use [do not use] the search list defined by the searchlist or domain directive in resolv.conf (if any). The search list is not
used by default
我想使用 dig
进行相对路径 DNS 查询。我参考了 dig(1)
和 resolv.conf(5)
.
dig(1) 说:
+ndots=D
Set the number of dots that have to appear in name to D for it to be considered absolute. The default value is that defined using the ndots statement in /etc/resolv.conf, or 1 if no ndots statement is present. Names with fewer dots are interpreted as relative names and will be searched for in the domains listed in the search or domain directive in /etc/resolv.conf.
domain Local domain name.
Most queries for names within this domain can use short names relative to the local domain. If set to '.', the root domain is considered. If no domain entry is present, the domain is determined from the local hostname returned by gethostname(2); the domain part is taken to be everything after the first '.'. Finally, if the hostname does not contain a domain part, the root domain is assumed.
我的/etc/resolv.conf
:
options timeout:2 attempts:3 rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
domain nonexist.com
nameserver 100.100.2.136
nameserver 100.100.2.138
但是 运行 dig abc
CentOS Linux release 7.6.1810 (Core) 64 bit OS
结果:
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> abc
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13347
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;abc. IN A
;; AUTHORITY SECTION:
abc. 9080 IN SOA ac1.nstld.com. info.verisign-grs.com. 1573282493 1800 900 604800 86400
;; Query time: 0 msec
;; SERVER: 100.100.2.136#53(100.100.2.136)
;; WHEN: Sat Nov 09 15:23:42 CST 2019
;; MSG SIZE rcvd: 99
我的预期是 abc
后缀为 nonexist.com.
并且在 DNS 查询中使用 abc.nonexist.com.
。但是上面的 QUESTION SECTION
有 abc.
而不是 abc.nonexist.com.
任何人都可以指出我的设置有什么问题吗?
dig(1) 说:
+[no]search
Use [do not use] the search list defined by the searchlist or domain directive in resolv.conf (if any). The search list is not used by default