I have a mac and am using terminal to try out the dig command. I was trying to use the dig command from a tutorial, which stated that if I use the syntax given below

dig @www.google.com ns .

I should get all the information needed, instead I get the following output.

$dig @www.google.com ns . 
;<<>> DiG 9.8.3-P1 <<>> @www.google.com ns .
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

But when I use the command

dig www.google.com ns

I get the following output

; <<>> DiG 9.8.3-P1 <<>> www.google.com ns
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15350
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;www.google.com.            IN  NS
google.com.     60  IN  SOA ns3.google.com. dns-admin.google.com. 124846888 900 900 1800 60

So my question is why doesn't the first command work the same way as the second command?

Also when I used the first command format to query the root servers, I got a comprehensive reply. The output is shown below,

Again why the difference in output with the same command?

dig @a.root-servers.net ns .

; <<>> DiG 9.8.3-P1 <<>> @a.root-servers.net ns .
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9504
;; flags: qr aa rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
;; WARNING: recursion requested but not available

;.              IN  NS

.           518400  IN  NS  e.root-servers.net.
.           518400  IN  NS  h.root-servers.net.
.           518400  IN  NS  l.root-servers.net.
.           518400  IN  NS  i.root-servers.net.
.           518400  IN  NS  a.root-servers.net.
.           518400  IN  NS  d.root-servers.net.
.           518400  IN  NS  c.root-servers.net.
.           518400  IN  NS  b.root-servers.net.
.           518400  IN  NS  j.root-servers.net.
.           518400  IN  NS  k.root-servers.net.
.           518400  IN  NS  g.root-servers.net.
.           518400  IN  NS  m.root-servers.net.
.           518400  IN  NS  f.root-servers.net.

e.root-servers.net. 518400  IN  A
h.root-servers.net. 518400  IN  A
h.root-servers.net. 518400  IN  AAAA    2001:500:1::53
l.root-servers.net. 518400  IN  A
l.root-servers.net. 518400  IN  AAAA    2001:500:9f::42
i.root-servers.net. 518400  IN  A
i.root-servers.net. 518400  IN  AAAA    2001:7fe::53
a.root-servers.net. 518400  IN  A
a.root-servers.net. 518400  IN  AAAA    2001:503:ba3e::2:30
d.root-servers.net. 518400  IN  A
d.root-servers.net. 518400  IN  AAAA    2001:500:2d::d
c.root-servers.net. 518400  IN  A
c.root-servers.net. 518400  IN  AAAA    2001:500:2::c

I appreciate the help. Thanks.


The two commands means something very different, which is why you get differering results.

This command:

dig www.google.com ns

means that you want to query your locally defined DNS server about NS records for the host www.google.com.

The locally defined DNS server could be your ISP's DNS server for example. NS records are records describing which DNS servers hold authoritative records for the host.

The other command:

dig @www.google.com ns . 

means that you want to query www.google.com about the ns records for the name ".". As www.google.com is a web server and not a DNS server, you'll not get any reply to your query.

Then your final command:

dig @a.root-servers.net ns .

This means to query a.root-servers.net about ns records for the name "." (i.e. the most toplevel name, the root). "a.root-servers.net" is a DNS server, so it will reply to your query. It also happens to be a special DNS server in that it is one of the root servers that is in place specifically to give you DNS records for the root.

  • dig @www.google.com ns. is a typo of the OP: it should be spelled ... ns . (Ok it doesn't make a difference because @www.google.com doesn't make any sense) – klanomath Jun 16 '16 at 20:26
  • @jksoegaard Thank you for your detailed explanation, I really appreciate it. – Karish Jun 16 '16 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .