emilhernvall / dnsguide Goto Github PK
View Code? Open in Web Editor NEWA guide to writing a DNS Server from scratch in Rust
License: MIT License
A guide to writing a DNS Server from scratch in Rust
License: MIT License
Thanks a lot, with the help of you project I've been able (after some trial & error) to write my own DNS server implementation - altough I've decided to do it in C# (because that's what I'm learning right now) and not in Rust (also, copy-paste Rust code seemed too easy).
You can check it out at https://github.com/delneg/dns_server_csharp
There are also branches for each chapter, if you're interested
if (len & 0xC0) == 0xC0 {
// Update the buffer position to a point past the current
// label. We don't need to touch it any further.
if !jumped {
try!(self.seek(pos+2));
}
and
"" I mentioned earlier that each label is preceeded by a single byte length. The additional thing we need to consider is that if the two Most Significant Bits of the length is set, we can instead expect the length byte to be followed by a second byte. These two bytes taken together, and removing the two MSB's, indicate the jump position. In the example above, we've got 0xC00C. The bit pattern of the the two high bits expressed as hex is 0xC000 (in binary 11000000 00000000), so we can find the jump position by xoring our two bytes with this mask to unset them: 0xC00C ^ 0xC000 = 12. Thus we should jump to byte 12 of the packet and read from there. Recalling that the length the DNS header happens to be 12 bytes, we realize that it's instructing us to start reading from where the question part of the packet begins, which makes sense since the question starts with the query domain which in this case is "google.com". ""
Shoudnt we jump by the number indicated after the set flag? Why are we jumping from pos
to pos+2
?
I wanted to turn your server to a multithreaded one and I receive this error
An error occurred: Either the application has not called WSAStartup, or WSAStartup failed. (os error 10093) handle An error occurred: Either the application has not called WSAStartup, or WSAStartup failed.
I know this is not an issue with your code, help would be much appreciated
How writing similar program?
https://code.kryo.se/iodine/
for example without interface. in userspace for web (www/mastodon) or communicators
Hello. I am currently following your tutorial (great tutorial by the way), and am currently implementing the write methods for the stub resolver section. However, there is something that I don't quite understand: In chapter 1, the read_qname
function implemented this label compression idea by jumping to and reusing old labels. However, in chapter two, the write_qname
function doesn't implement the same idea. Did you just chose not to implement it, or is there something I am missing?
Thanks beforehand!
In read_u16 and read_u32 function, multiple borrowing error is occuring. How did you compile your code?
Forgive me if I misread, but as it is now this project doesn't seem to have a license associated with it. What do you find acceptable?
Pi-Hole does a great job, but its implementation is not over a thread-safe and blazing fast language like Rust.
It would be awesome to see the full DNS could integrate with it, and maybe embed a port of if in the long-term future.
I saw in your Hermes project you have caching. I have been using your dnsguide in implementing my own DNS server in python. Are you considering adding more parts to your guide such as how you dealt with caching?
I'm following your guide on my way to implementing my rust DNS server, but serval trials with your script on catching DNS querying packets lasted an empty query-packet.txt
.
nc -u -l 1053 google.com
I'm using Arch Linux and my netcat
version is GNU netcat 0.7.1. The proper way to catch the packet shall be as the following script, instead.
# use `-p` option explicitly
nc -u -l -p 1053 google.com
You might be using other versions of netcat
, or the (GNU version) netcat
itself had an update on its CLI. After all the script does not work on my environment, please take a look.
`; <<>> DiG 9.16.26 <<>> @127.0.0.1 -p 2053 www.twitch.tv
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50931
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0
;; QUESTION SECTION:
;www.twitch.tv. IN A
;; ANSWER SECTION:
www.twitch.tv. 3600 IN CNAME twitch.map.fastly.net.
;; AUTHORITY SECTION:
twitch.tv. 172800 IN NS ns-1450.awsdns-53.org.
twitch.tv. 172800 IN NS ns-1778.awsdns-30.co.uk.
twitch.tv. 172800 IN NS ns-219.awsdns-27.com.
twitch.tv. 172800 IN NS ns-664.awsdns-19.net.
;; Query time: 842 msec
;; SERVER: 127.0.0.1#2053(127.0.0.1)
;; WHEN: Mon Mar 14 00:06:10 India Standard Time 2022
;; MSG SIZE rcvd: 255`
why is this happening?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.