This collaborative project is a toy DNS resolver written in C and based on Julia Evans' Implement DNS in a Weekend Python guide.
The program features DNSQuery
, DNSHeader
, DNSQuestion
, and DNSRecord
structs that maintain the various component parts of a DNS request and the parsed DNS response. At a high level, the program currently performs as follows:
- open a socket fild descriptor using
socket()
- instantiate and populate a
DNSQuery
struct with details about the DNS request using constructor functionNewDNSQuery()
- send above
DNSQuery
struct usingsendto()
- receive response with
recvfrom()
- close socket file descriptor with `close()
- parse response into
DNSHeader
,DNSQuestion
, andDNSRecord
structs
For working branch, see sendto.
The sandbox/
directory contains a number of DNS-related and DNS-adjacent experients and toy projects designed to improve intuition about networking in general and C's networking systems calls.