How do I find the authoritative name-server for a domain name?

前端 未结 12 1964
你的背包
你的背包 2021-01-29 17:17

How can I find the origins of conflicting DNS records?

相关标签:
12条回答
  • 2021-01-29 17:30

    I have found that for some domains, the above answers do not work. The quickest way I have found is to first check for an NS record. If that doesn't exist, check for an SOA record. If that doesn't exist, recursively resolve the name using dig and take the last NS record returned. An example that fits this is analyticsdcs.ccs.mcafee.com.

    1. Check for an NS record

    host -t NS analyticsdcs.ccs.mcafee.com.

    1. If no NS found, check for an SOA record

    host -t SOA analyticsdcs.ccs.mcafee.com.

    1. If neither NS or SOA, do full recursive and take the last NS returned

    dig +trace analyticsdcs.ccs.mcafee.com. | grep -w 'IN[[:space:]]*NS' | tail -1

    1. Test that the name server returned works

    host analyticsdcs.ccs.mcafee.com. gtm2.mcafee.com.

    0 讨论(0)
  • 2021-01-29 17:36

    Unfortunately, most of these tools only return the NS record as provided by the actual name server itself. To be more accurate in determining which name servers are actually responsible for a domain, you'd have to either use "whois" and check the domains listed there OR use "dig [domain] NS @[root name server]" and run that recursively until you get the name server listings...

    I wish there were a simple command line that you could run to get THAT result dependably and in a consistent format, not just the result that is given from the name server itself. The purpose of this for me is to be able to query about 330 domain names that I manage so I can determine exactly which name server each domain is pointing to (as per their registrar settings).

    Anyone know of a command using "dig" or "host" or something else on *nix?

    0 讨论(0)
  • 2021-01-29 17:37

    You used the singular in your question but there are typically several authoritative name servers, the RFC 1034 recommends at least two.

    Unless you mean "primary name server" and not "authoritative name server". The secondary name servers are authoritative.

    To find out the name servers of a domain on Unix:

      % dig +short NS stackoverflow.com
     ns52.domaincontrol.com.
     ns51.domaincontrol.com.
    

    To find out the server listed as primary (the notion of "primary" is quite fuzzy these days and typically has no good answer):

    % dig +short  SOA stackoverflow.com | cut -d' ' -f1
    ns51.domaincontrol.com.
    

    To check discrepencies between name servers, my preference goes to the old check_soa tool, described in Liu & Albitz "DNS & BIND" book (O'Reilly editor). The source code is available in http://examples.oreilly.com/dns5/

    % check_soa stackoverflow.com
    ns51.domaincontrol.com has serial number 2008041300
    ns52.domaincontrol.com has serial number 2008041300
    

    Here, the two authoritative name servers have the same serial number. Good.

    0 讨论(0)
  • 2021-01-29 17:38

    I found that the best way it to add always the +trace option:

    dig SOA +trace stackoverflow.com
    

    It works also with recursive CNAME hosted in different provider. +trace trace imply +norecurse so the result is just for the domain you specify.

    0 讨论(0)
  • 2021-01-29 17:40

    You could find out the nameservers for a domain with the "host" command:

    [davidp@supernova:~]$ host -t ns stackoverflow.com
    stackoverflow.com name server ns51.domaincontrol.com.
    stackoverflow.com name server ns52.domaincontrol.com.
    
    0 讨论(0)
  • 2021-01-29 17:47

    The term you should be googling is "authoritative," not "definitive".

    On Linux or Mac you can use the commands whois, dig, host, nslookup or several others. nslookup might also work on Windows.

    An example:

    $ whois stackoverflow.com
    [...]
       Domain servers in listed order:
          NS51.DOMAINCONTROL.COM
          NS52.DOMAINCONTROL.COM
    

    As for the extra credit: Yes, it is possible.


    aryeh is definitely wrong, as his suggestion usually will only give you the IP address for the hostname. If you use dig, you have to look for NS records, like so:

    dig ns stackoverflow.com
    

    Keep in mind that this may ask your local DNS server and thus may give wrong or out-of-date answers that it has in its cache.

    0 讨论(0)
提交回复
热议问题