This is for educational purposes only. I'm currently learning about DNS, and every source I've read told pretty much this:

Assuming no cache hits at all, when asked to resolve a domain name, the DNS resolver will first contact a root name server, which will point him to a TLD name server, which will point him to the name server which is authoritative for the domain he's looking for.

Now, in my home laptop, my OS is pre-configured to use some DNS server, which I guess belongs to my ISP, and when I query something using nslookup, I immediately get the response.

I'm trying to imitate the behavior of a DNS resolver using nslookup. How can I do this?

Ok I know the domain names (and also IP addresses) of the root name servers. How do I go on from there?

My guess is that the DNS resolver, when contacting the root server, is asking for a A record, but when I try to do the same query, I get:

> www.google.com e.root-servers.net
Server:  e.root-servers.net
Addresses:  2001:500:a8::e

*** e.root-servers.net can't find www.google.com: No response from server
  • you can always tell nslookup what dns server to query by putting its ip address after the query nslookup example.com will execute the query against the google dns server at Nov 17, 2021 at 0:37

2 Answers 2


I'm not sure nslookup is the tool for the job. "dig" is probably better. Indeed you can see the whole workings of an authorative lookup and all steps with dig with a simple command -

 dig +trace www.google.com

If you have to use nslookup, We can do it like this -


Returns the names of the TLD servers, ie [a-m].root-servers.net. (if you don't want to use dig or don't know these and need to do it from first principles, these are hard coded into recursive DNS servers, so you would need to look at their config or find a trusted source)

We can then query this server and ask for the .com ns record like so -

 nslookup -type=ns com. a.root-servers.net

(I think you can leave out the . after com. - that end bit signifies its an absolute, not relative query). This returns a list of the .com nameservers -

;; Truncated, retrying in TCP mode.
Server:     a.root-servers.net

Non-authoritative answer:
*** Can't find com: No answer

Authoritative answers can be found from:
com nameserver = e.gtld-servers.net.
com nameserver = b.gtld-servers.net.
com nameserver = j.gtld-servers.net.
com nameserver = m.gtld-servers.net.
com nameserver = i.gtld-servers.net.
com nameserver = f.gtld-servers.net.
com nameserver = a.gtld-servers.net.
com nameserver = g.gtld-servers.net.
com nameserver = h.gtld-servers.net.
com nameserver = l.gtld-servers.net.
com nameserver = k.gtld-servers.net.
com nameserver = c.gtld-servers.net.
com nameserver = d.gtld-servers.net.
e.gtld-servers.net  internet address =
e.gtld-servers.net  has AAAA address 2001:502:1ca1::30
b.gtld-servers.net  internet address =
b.gtld-servers.net  has AAAA address 2001:503:231d::2:30
j.gtld-servers.net  internet address =
j.gtld-servers.net  has AAAA address 2001:502:7094::30
m.gtld-servers.net  internet address =
m.gtld-servers.net  has AAAA address 2001:501:b1f9::30
i.gtld-servers.net  internet address =
i.gtld-servers.net  has AAAA address 2001:503:39c1::30
f.gtld-servers.net  internet address =
f.gtld-servers.net  has AAAA address 2001:503:d414::30
a.gtld-servers.net  internet address =
a.gtld-servers.net  has AAAA address 2001:503:a83e::2:30
g.gtld-servers.net  internet address =
g.gtld-servers.net  has AAAA address 2001:503:eea3::30
h.gtld-servers.net  internet address =
h.gtld-servers.net  has AAAA address 2001:502:8cc::30
l.gtld-servers.net  internet address =
l.gtld-servers.net  has AAAA address 2001:500:d937::30
k.gtld-servers.net  internet address =
k.gtld-servers.net  has AAAA address 2001:503:d2d::30
c.gtld-servers.net  internet address =
c.gtld-servers.net  has AAAA address 2001:503:83eb::30
d.gtld-servers.net  internet address =
d.gtld-servers.net  has AAAA address 2001:500:856e::30

We can now repeat the same request from one of the "com" tld nameservers to get googls server -

 nslookup -type=ns google.com. a.gtld-servers.net

which returns

Server:     a.gtld-servers.net

Non-authoritative answer:
*** Can't find google.com.: No answer

Authoritative answers can be found from:
google.com  nameserver = ns2.google.com.
google.com  nameserver = ns1.google.com.
google.com  nameserver = ns3.google.com.
google.com  nameserver = ns4.google.com.
ns2.google.com  has AAAA address 2001:4860:4802:34::a
ns2.google.com  internet address =
ns1.google.com  has AAAA address 2001:4860:4802:32::a
ns1.google.com  internet address =
ns3.google.com  has AAAA address 2001:4860:4802:36::a
ns3.google.com  internet address =
ns4.google.com  has AAAA address 2001:4860:4802:38::a
ns4.google.com  internet address =

This record is interesting because it specifices the IP addresses for nsX.google.com (This is called a glue record, and is coded into the .com nameserver in this case, because otherwise there is a problem that you need nsX.google.com to find google.com, but first you need to find google.com to get to nsX.google.com...)

Lastly we can query one of Googles nameservers and get its address:

  nslookup  www.google.com.

Our answer:


Name:   www.google.com
Name:   www.google.com
Address: 2404:6800:4006:810::2004

If you are querying the root servers, then it should be for com. You then issue another lookup for google.com against one of the returned IP addresses. Then you can finally lookup www.google.com for a server from that final list.

What you are doing is asking the root server to recursively search for www.google.com, something which they are not set up for, they will only return the tld's.

You must log in to answer this question.

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