19

I am just curious if you could use dig to check if a certain nameserver responds to recursive queries.

Thanks!

4 Answers 4

24

Use dig and check the status of the RD and RA bits in the response.

By default dig will send a recursive query (RD set in the query header) unless you set the +norecurse command line flag.

If the server supports recursive queries the response will have the "recursion available" RA bit set in the response headers.

The RA bit is the diagnostic test for recursive query support.

14

See if you can query it for a DNS entry for which it is not authoritative, e.g., try: host www.cnn.com ns.example.com, where ns.example.com is the name server you're testing. If it doesn't respond to recursive queries, you will get a REFUSED.

$ host www.cnn.com. ns1.example.com
Using domain server:
Name: ns1.example.com
Address: 192.168.183.130#53
Aliases:

Host www.cnn.com not found: 5(REFUSED)

whereas a DNS server that does recursive queries:

$ host www.cnn.com. 8.8.8.8
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:

www.cnn.com has address 157.166.255.18
www.cnn.com has address 157.166.255.19
www.cnn.com has address 157.166.226.25
www.cnn.com has address 157.166.226.26
3
  • Thanks a lot @cjc. I also figured out another method but using dig. Try to lookup a domain to a nameserver that is non-authorative to the domain. If it doesn't return anything, then it's not responding to recursive queries.
    – Mikko
    Mar 20, 2012 at 23:28
  • @Mikko, yes, both dig and host (and the now deprecated nslookup) are DNS query tools. All of them are sufficient for determining whether a DNS server is allowing recursive queries from your IP address.
    – cjc
    Mar 21, 2012 at 0:42
  • this is wrong - REFUSED is also the response code you get if you ask an authoritative name server for information about a domain for which it doesn't have a zone file.
    – Alnitak
    Nov 7, 2013 at 20:41
4

Another option, use an online checker such as:

http://www.intodns.com/

0

According to Alnitak's answer a simple script can be written using the dnspython module:

import dns, dns.resolver

domain = "www.cnn.com"
nameserver_ip = "8.8.8.8"

message = dns.message.make_query(domain, rdtype=dns.rdatatype.A, ednsflags=dns.flags.RA)
resp = dns.query.udp(message, nameserver_ip)
if resp.rcode() != 0:
    print("Nameserver responds to recursive queries.")

You must log in to answer this question.

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