Skip to content

abouzkra/simple-dns-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simple-dns-resolver

Simple DNS Resolver

Overview

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.

Notes

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).

Usage

Compile it:

make

or

make re

Then run with a domain name:

./dns-resolve <domain-name>

Improvements

  • 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.
  • ...

Useful links

About

Simple DNS Resolver

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors