0

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

;; QUESTION SECTION:
;www.google.com.            IN  NS
;; AUTHORITY SECTION:
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

;; QUESTION SECTION:
;.              IN  NS

;; ANSWER SECTION:
.           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.

;; ADDITIONAL SECTION:
e.root-servers.net. 518400  IN  A   192.203.230.10
h.root-servers.net. 518400  IN  A   198.97.190.53
h.root-servers.net. 518400  IN  AAAA    2001:500:1::53
l.root-servers.net. 518400  IN  A   199.7.83.42
l.root-servers.net. 518400  IN  AAAA    2001:500:9f::42
i.root-servers.net. 518400  IN  A   192.36.148.17
i.root-servers.net. 518400  IN  AAAA    2001:7fe::53
a.root-servers.net. 518400  IN  A   198.41.0.4
a.root-servers.net. 518400  IN  AAAA    2001:503:ba3e::2:30
d.root-servers.net. 518400  IN  A   199.7.91.13
d.root-servers.net. 518400  IN  AAAA    2001:500:2d::d
c.root-servers.net. 518400  IN  A   192.33.4.12
c.root-servers.net. 518400  IN  AAAA    2001:500:2::c

I appreciate the help. Thanks.

0
1

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.

2
  • 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 .