DNS query only works for Fully Qualified Domain Name (FQDN) but not short name

5

2

This is a Linux (Ubuntu 13.10) VM guest in the Windows host & environment. When doing DNS query, only the FQDN entries have returns while the short names are not (see below). Why is that?

My hostname -f is returning the FQDN for my VM with correct domain name, and my /etc/resolv.conf already has the search mycompany.com line. But still, short names are not working.

$ dig mySvr01 

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> mySvr01
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 27616
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;mySvr01.                  IN      A

;; Query time: 4 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Mon Mar 31 07:33:47 PDT 2014
;; MSG SIZE  rcvd: 41

$ dig mySvr01.mycompany.com 

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> mySvr01.mycompany.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7162
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
; mySvr01.mycompany.com.     IN      A

;; ANSWER SECTION:
mySvr01.mycompany.com. 3600 IN      A       10.192.78.38
mySvr01.mycompany.com. 3600 IN      A       10.192.78.66

;; Query time: 1 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Mon Mar 31 07:33:44 PDT 2014
;; MSG SIZE  rcvd: 86

xpt

Posted 2014-03-31T14:55:50.543

Reputation: 5 548

Answers

6

The dig command doesn't use the DNS search path to search for hosts, it just looks for the FQDN in DNS. This is because dig queries the name servers directly, instead of using the nsswitch method (which provides the search path functionality).

As you can see, a non-fqdn will not resolve with dig: mtak@gen1:~$ dig svc1 +short mtak@gen1:~$ dig svc1.int.mtak.nl +short 10.100.0.11 You can check if the DNS search path works properly by using the host command: mtak@gen1:~$ host svc1 svc1.int.mtak.nl has address 10.100.0.11

mtak

Posted 2014-03-31T14:55:50.543

Reputation: 11 805

5

This is an idiosyncrasy of dig's default behavior. It ignores the search and domain directives in /etc/resolv.conf unless you tell it to use them:

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

You can add "+search" to $HOME/.digrc to have it automatically look up short names.

Notabee

Posted 2014-03-31T14:55:50.543

Reputation: 51