Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A toy DNS resolver written in Rust

License

NotificationsYou must be signed in to change notification settings

aryan9600/dns-resolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dns-resolver is a toy DNS resolver. It can handle A, NS, CNAME and TXT records.Its a recursive resolver that can be used as DNS client or server. The server supportscaching via a fixed size LRU cache.

It's mainly written by understanding the contents ofhttps://implement-dns.wizardzines.com/book/intro.htmlandhttps://datatracker.ietf.org/doc/html/rfc1035. The primary goal of this projectis to understand how DNS works from the ground up and brush up on my Rust skills.

Usage

Client

Fetch the A records for google.com:

❯ cargo run --bin client google.com AQuerying 198.41.0.4for google.com about recordtype AQuerying 192.12.94.30for google.com about recordtype AQuerying 216.239.34.10for google.com about recordtype Aanswer(s): ["142.250.76.174"]

Fetch the CNAME records forwww.github.com:

❯ cargo run --bin client www.github.com CNAMEQuerying 198.41.0.4for www.github.com about recordtype CNAMEQuerying 192.12.94.30for www.github.com about recordtype CNAMEQuerying 205.251.193.165for www.github.com about recordtype CNAMEanswer(s): ["github.com"]

Server

Run the server:

❯ cargo run --bin server

Open another terminal window and usedig to access the server:

❯ dig @127.0.0.1 -p 3500 google.com A;<<>> DiG 9.10.6 <<>> @127.0.0.1 -p 3500 google.com A; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34233;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0;; QUESTION SECTION:;google.com.                    IN      A;; ANSWER SECTION:google.com.             300     IN      A       142.250.67.206;; Query time: 305 msec;; SERVER: 127.0.0.1#3500(127.0.0.1);; WHEN: Mon Jan 08 01:37:32 IST 2024;; MSG SIZE  rcvd: 44

About

A toy DNS resolver written in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp