1

I want to make a relative path DNS query with dig. I have referenced the following documentation for dig(1) and resolv.conf(5).

dig(1) says:

+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.

resolv.conf(5) says:

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.

My /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

But running dig abc on a CentOS Linux release 7.6.1810 (Core) 64 bit OS results:

; <<>> 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

My expection is that abc should be suffixed with nonexist.com. and abc.nonexist.com. is used in the DNS query. But the above QUESTION SECTION has abc. instead of abc.nonexist.com.

Can anyone point out what is wrong with my setup?

Jingguo Yao
  • 7,320
  • 6
  • 50
  • 63

1 Answers1

2

dig(1) says:

+[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

Dusan Bajic
  • 10,249
  • 3
  • 33
  • 43