If I have a nameserver with name ns1.mydomain.com
, and I want to query the IP for this name, but don't want to query the authoritative name servers for mydomain.com
. Can this be done with dig
, or similar command line tool?

- 121
- 7

- 557
- 2
- 4
- 9
4 Answers
If you want to know the name servers for a domain exmaple.com usually you need to first request the NS records dig ns example.com
then you can request the IP addresses for those NS records.
If you are asking how to determine what the name servers are for a domain you need to follow the standard resolution mechanism. So for the host ns1.example.com you would start asking by asking the root servers for the NS records for .com, then you would ask the .com servers for the NS records for example.com.

- 130,897
- 41
- 276
- 420
-
right, and then say that the NS record for example.com tells you the first nameserver is ns1.example.com. What next? How do you lookup the IP for that hostname, so you can resolve, say www.example.com? This is what leads to believe there is a special query "get the IP of a nameserver" which doesn't follow exactly the same route. Am I getting it wrong? – Alessandro Vernet May 13 '10 at 20:33
-
`dig ns example.com` doesn't tell me anything useful. Try for instance `dig ns ns1.google.com`. – Alessandro Vernet May 13 '10 at 20:54
-
also see my own answer to this question. That did it for me. – Alessandro Vernet May 13 '10 at 21:04
i don't know if i understand, but it seems you want dig ns1.mydomain.com
unless you want to query a specific server for the IP address of ns1.mydomain.com, in which case: dig @nsserverofchoice ns1.mydomain.com

- 2,720
- 18
- 12
To find name servers for domain in question:
host -t ns mydomain.com
To simply find IP of (for instance) dns2.mydomain.com:
host dns2.mydomain.com

- 1,216
- 1
- 11
- 12
To make this more practical, let's take google.com
as an example:
dig ns google.com
tells you that the name servers forgoogle.com
arens1.google.com
tons4.google.com
.- Google registered with their registrar (MarkMonitor) what the IP of
ns1.google.com
is. To look it up, rundig ns a.gtld-servers.net
to find the name servers for.com
. Among the list, there isa.gtld-servers.net
. - Finally, run
dig @a.gtld-servers.net ns1.google.com
. This will give you the IP addresses that Google registered with their registrar for their name servers (not the IP they defined in their own DNS, which, granted, should be the same).

- 557
- 2
- 4
- 9