Skip to content

panacotar/rbdig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rbdig

A DNS lookup library for me to learn how DNS works. Inspired by dig CLI tool.
Can encode a domain name in the message and construct a valid DNS query. It also handles decoding of the DNS response raw packet. Currently, it supports only DNS queries for 'A' records.

Can output similar to dig (+noall, +short, +trace).

I wrote a companion article with my findings, and the building progress of this project.
https://organicdarius.com/blog/dns-lookup-from-scratch/

Thanks to Greg for his advice on this project.

Usage

Allow execution with chmod +x dig.rb.

# Recursive lookup, default output
./dig.rb example.com

# Recursive lookup, outputs the steps it takes
./dig.rb -t example.com

# Send a query to the 1.1.1.1 DNS server (Cloudflare's) for example.com
./dig.rb -a 1.1.1.1 example.com

Print usage info:

./dig.rb -h

Usage: rbdig.rb [options] [DOMAIN] [A]

Specific options:
    -a, --at [SERVER]                Specify the DNS server to query, example: rbdig.rb -a 8.8.8.8 example.com (default: 199.7.83.42)
    -s, --short                      Return only the found IP address (Default: false)
    -n, --noall                      Clears all displayed flags (Default: all)
    -t, --trace                      Enable tracing, showing the iterative queries, disabled when --at specified (Default: false)

Common options:
        --version                    Show version

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages