dug
is a stripped-down Python implementation of dig
. When run normally, the program queries a given nameserver about a given hostname and prints the result. When run as a daemon, the program listens for data on a specific port, forwards that data to a given nameserver, and then returns the answer. If the debug flag is given, the program will print out each question and all of the resource records in each response.
dug
currently only knows how to handle A, NS, and CNAME requests/records. AAAA records are recognized but not acted upon.- The program assumes that only one question was asked in each datagram.
- If no A records are returned but NS records are included, the program assumes that the IP addresses of those nameservers are also included.
- This mode was designed to receive DNS datagrams created by
dig
, send them, and then hand the response back todig
. It's not really good for anything else. The listening port is specified by theMY_PORT
variable indug.py
- There is no threading or coordination of datagram IDs, so there will probably be issues if the program receives multiple packets at the same time when running as a daemon.
python dug.py [-d] hostname nameserver
to run normally
python dug.py [-d] -f nameserver
to run as a daemon
- Python 2.4 or later