Implement a skeletal DNS client. Your client is similar in spirit to dig, although much less complete.
Your client should be fronted by a run.sh script, so that it can be invoked like this:
$ ./run.sh 8.8.8.8 cs.washington.edu ANY Querying 8.8.8.8 for ANY records for name cs.washington.edu Receiving answer Header: transid = 1 flags = 0x8180 numQuestions = 1 numAnswers = 16 numAuths = 0 numAdditional = 0 Answers: SOA cs.washington.edu LOC cs.washington.edu TXT cs.washington.edu MX cs.washington.edu MX cs.washington.edu MX cs.washington.edu MX cs.washington.edu MX cs.washington.edu MX cs.washington.edu A cs.washington.edu NS cs.washington.edu NS cs.washington.edu NS cs.washington.edu NS cs.washington.edu NS cs.washington.edu NS cs.washington.eduThe arguments are, in order, the IP address of the name server to which your client should send the query, the DNS name to resolve, and the type of query. You should handle query types A, AAAA, and ANY. You can rely on the IP address argument being an IP address (not a domain name). You don't have to deal with any errors in the arguments. (You do have to deal with the possibility there will be no response to your query, though.)
The output shows some of the information returned in the response. The header is dumped, in a crude fashion. For each resource record in the answer section, the type of the record and the name field from that record is printed. Nothing is printed about records in the query, authority, or additional information sections of the response.
You must implement on top of raw sockets, not using any library/package that provides more functionality than that.
You must not copy code from any source, except for code you may have written yourself.
Your code must run on attu on an account that has only the most basic, default environment -- just because it works for you doesn't mean it will for me, especially if you use an exotic language or toolset.
There is a run.sh that I used during development of the sample solution. It may or may not be useful.
There is a driver.sh that invokes run.sh on a number of sites for a number of query types.