1. Andrew Brown
  2. dns_resolver

Source

dns_resolver /

Filename Size Date modified Message
1.0 KB
added an example
17.5 KB
tweaked recursive label parsing so that the root returns "." instead of ""
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.

Requirements
------------
Python 2.6 or 2.7

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

Usage
-----
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 198.41.0.4, type:

::

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