Simple DNS Resolver
This project is a simple DNS response parser written in C. It sends a DNS query and parses the server’s response, extracting useful information from the Resource Records (RRs).
Currently, my code only supports:
- A (Type 1) : IPv4 address records
- CNAME (Type 5) : Canonical name (alias) records
These are probably enough to resolve most common domain names into IP addresses.
Note that the current program sends DNS queries directly to the local router (the DNS server provided by my ISP). This works for basic testing, but it is not flexible.
An improvement would be to dynamically fetch DNS servers (e.g., from /etc/resolv.conf on Linux) or allow the user to specify a DNS server (such as 8.8.8.8 for Google DNS or 1.1.1.1 for Cloudflare).
Compile it:
make
or
make re
Then run with a domain name:
./dns-resolve <domain-name>
- Dynamically fetching DNS servers
- Support for additional record types:
- AAAA (IPv6)
- MX (Mail Exchange)
- NS (Name Server)
- PTR (Reverse DNS)
- Error handling and timeouts.
- More robust query building.
- ...