Implement DNS in a Weekend
implement-dns.wizardzines.com
implement-dns.wizardzines.com
Totally agree, and at the same time, it’s so painful that there’s a nice haiku —
It’s not DNS
There’s no way it’s DNS
It was DNSTo be fair, sometimes it's BGP.
(I'm not sure if I'd faced DNS issues that meant I needed to know that - but it was a time when dialup ISPs told you what to manually configure for your DNS rather than it being automatically assigned, so it all seemed a bit chunkier.)
https://github.com/DavidVentura/hackattic/blob/master/src/se...
It'll be interesting to see if the server implementation is complete enough to work with this client
Everything runs on 443 to avoid firewalls, moving services to new ports opens up the whackamole game of trying to find other unblocked ports and raises security implications.
Here is a more positive take for background on SVCB: https://www.isc.org/docs/2022-webinar-dns-scvb.pdf
It would be convenient if I didn't have to download the code to run it though - if it was in a GitHub repo it could provide links to hosted notebook services such as JupyterHub and Colab - then lazy people like myself could click those links to try out the notebooks in their browsers without downloading, unzipping and running Jupyter locally.
> then lazy people like myself could click those links to try out the notebooks in their browsers without downloading, unzipping and running Jupyter locally.
- Some time ago on HN I saw a free ad blocking DNS server (https://controld.com/free-dns)
- I had wondered what protocol the 'Private DNS' setting on my Pixel uses, but never got around to checking.
It turns out that it setting the 'Private DNS provider hostname' to x-oisd.freedns.controld.com just works: DNS-over-TLS and ad blocking.
The great examples of this are 'A from-scratch tour of Bitcoin in Python' https://karpathy.github.io/2021/06/21/blockchain/ and 'Let's build GPT: from scratch, in code, spelled out' https://youtu.be/kCc8FmEb1nY from Andrej Karpathy
I wonder if anybody tried to collect all such projects together and built his own 'Internet in just 100 lines of code'
Me too, they're a really good resource.
What are some other ones you've come across?
I've enjoyed doing stuff like this myself. I wrote an IP stack up to being able to ping an IP address. I had learnt all of this in university, but doing it myself really cemented the knowledge. Using a notebook and doing literate programming is a must. I pretend that I'm teaching someone else, even though I don't plan on ever sharing it really.
I especially like the chapter "A Python Interpreter Written in Python": https://aosabook.org/en/500L/a-python-interpreter-written-in...
https://www.youtube.com/playlist?list=PLBOh8f9FoHHhvO5e5HF_6...
Just a heads up incase Julia is reading :)
I implemented this as a command line tool because that's much easier to do in a Jupyter notebook environment, but you can also pretty easily transform it into a UDP server running on localhost and query it with dig in the same way that you would with 8.8.8.8. That's one of the bonus exercises at the end (Exercise 7).
I might end up bringing "convert it into a server" into the main content though because it's pretty easy to do and I think it makes the whole thing seem more "real".
Resolver is usually a part of operating system (sometimes) implementing DNS client functionality and serving as a link between a userland library providing, say, getaddrinfo(), and DNS implementation.
This one is even less than a resolver, it does not implement a library link. It’s a toy DNS client, implementing minimal functionality.
You are referring to a system's local resolver (which is obviously also a resolver, so you are right on this regard).
But still, this project is _also_ a resolver (although obviously not a complete one, it's a learning project).
Message query = new Message(data);
Header header = query.getHeader();
Record question = query.getQuestion();
Message response = new Message(query.getHeader().getID());
response.getHeader().setFlag(Flags.QR);
response.addRecord(question, Section.QUESTION);
Name name = question.getName();
int type = question.getType();
int dclass = question.getDClass();
String host = name.toString(true).toLowerCase();
...
response.addRecord(new ARecord(name, dclass, 300, "someIP"), Section.ANSWER);
...
response.getHeader().setFlag(Flags.AA);
return response.toWire(512);On one hand, like all Java code, this is really really verbose. But on the other, it's not that complicated—every line seems like it corresponds to some part of the DNS spec.
Verboseness doesn’t make something uneasy, it means you tell your IDE to autocomplete.
… always better than something that tries to hide things from you and does the wrong thing sometimes.