This project implements a stub resolver client that is able to query either a recursive or authoritative DNS server.
- Specifying the server to query
- Specifying the port to send the query
- Any domain name and any RRTYPE can be encoded into a query
- The following RRTYPEs can be decoded: A, NS, CNAME, SOA, PTR, HINFO, MX, TXT, AFSDB, AAAA, SRV, NAPTR, CERT, DNAME
- UDP retry
- DNSSEC in no way shape or form
- Many RRTYPEs
- Any options on which flags to set, or how to display the data (dig has things like
+short
,+trace
,+norecurse
, etc.) - No TCP support
- Does not decode DNS options / special additionals
Run make to run the tests and compile not-dig. Either
$ make
or
$ make all
To run only the tests run $ make test
To remove the executables run $ make clean
Call the executable and optionally give it a port / server address, and provide the domain name and qtype.
$ not-dig [email protected] frazao.ca. a
; <<>> Not DiG 0.0.1 <<>> frazao.ca. A
;; global options: +cmd
;; Got answer:
;; ->> HEADER <<- opcode: QUERY status: NOERROR id: 61417
;; flags: aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
frazao.ca. IN A
;; ANSWER SECTION:
frazao.ca. 30 IN A 54.197.199.246
;; Query time: 11 msec
;; SERVER: 198.51.44.1#53
;; WHEN: Tue May 28 13:49:23 DST 2019
;; MSG SIZE rcvd: 43
How professional is this code base?
I decided to do this after reading through K&R C and doing some excercises. The quality of the C code is guaranteed to be poor.
Is this memory safe?
Almost certainly not, the number of segfaults and memory issues that I ran while developing this was staggering. I would be very surprised if there are not any remaining memory issues.
Why?
I wanted to practice my C programming and I wanted to learn more about socket networking.
Implement better command line options handlingDONE- Implement additional RRTYPEs
- Implement a recursive resolver server
- Implement a recursive resolver cache
- Implement an authoritative DNS server
- Expand scope of test suite
- Implement queries over TCP
- Implement dns trace funtionality
- Implement ability to specify DNS server by name instead of by IP
- Implement better input validation (e.g., autocorrect domains without terminal dot)