1. Andrew Brown
  2. dns_resolver


dns_resolver /

Filename Size Date modified Message
1.0 KB
17.5 KB
DNS Iterative Resolver
By Andrew Brown

This program was written by scratch using only the DNS spec (rfc 1035).

This program implements the DNS protocol and communicates with DNS servers to
resolve a name. It opens a UDP socket to a server, forms a query, and sends it
off. It then receives and parses the answer from the server, and determines if
another query is necessary or if it got the answer.

Python 2.6 or 2.7

Tested on Linux. Should work on other platforms, but I haven't tried it.

To use the dns script, use this form:


    ./dns.py <root server> <name> <record type>
The root server is the starting point. It queries this server for an answer, but
if there is none, follows the given authorative answers and queries again.

name is the name to query, such as cs.duke.edu.

record type is the record type to query for, e.g. A or CNAME

For example, to query www.cs.duke.edu using, type:


    ./dns.py www.cs.duke.edu A