I've done something along these lines with a very simple DNS and DHCP server implementation as an Arduino library: https://github.com/pkulchenko/DHCPLite/. It is fairly short and while I don't claim it being fully correct, it was tested with different clients successfully; it was great learning experience.
I love this. DNS is something that, if you're online and visiting websites or even sshing into boxes a lot of the time, you're using, unless of course you carry around a list of IP addresses like the olden times. It is one of the many things that underpin the modern web and we take it for granted.
I still have one IP address lodged in my memory from 25+ years ago - sable, the university's key Unix server for students, on which I learned so much about Unix and the 1990s Internet.
(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.)
This is great. Incidentally, writing toy recursive resolvers is one of the primary methods I use to help me learn new languages. If you take the time to develop an understanding of the domain, I've found its an easily repeatable exercise and can be done in a couple of hours.
Julia's posts are always so informative; DNS being one of those topics which I presume so many developers are like myself and have "just enough knowledge to be dangerous" :-)
I have a slightly off topic but related query to new HTTPS RR and SVCB record types of DNS. Will these records allow me to host sites without a reverse proxy since both records can include port info.
It is very well intentioned, but unlikely to actually see adoption outside of internal network service discovery maybe (where mDNS already does a good job).
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.
I host a pi-hole instance in the cloud. It's only accessible to my Tailscale network, which means that I can't reach it on my TV - unless I write a DNS proxy. Maybe this'll be enough to get my ass in gear and actually write it for once.
The Pi-hole isn't hosted on my local network, but on my Tailscale network because it's running on a VPS. My router can't run Tailscale, so that's not possible.
Isn't the DNS design effectively its own proxy by the way resolvers forward requests towards more authoritative resolvers? On whatever local-network machine you would run your DNS proxy, you just run a DNS resolver in forwarding mode where all requests are sent to your pi-hole instance.
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.
This looks great. I've seen a few things in rest of comments but if anyone could share anything similar about networking or computer science topics in general I'd really appreciate it. It's weird looking back I learned so much stuff as a kid in the 90s that I wish I knew better now, from trying to be a wannabe hacker and always breaking stuff I had to figure out how to fix if I wanted to use it again. I never went to college for Comp Science or worked in IT or coding but now I want to make a career change. Even though I always had some personal projects or occasional freelance type web dev, I guess the more complicated stuff was abstracted away over the years and it was easier to do more with knowing less.
Same here. 1998 was the first time I touched a pc. Next 3 to 4 years were c & c++. Then WYSIWYG html editors. Then php. Then javascript & html n static stuff. No formal education related to computers. Although I am comfortable with my current job, but somewhere in the back of my mind I wish I was in IT, earning IT money.
I love all the series about writing your own X in 100 lines of code.
It gives you the understanding of technology and removes a lot of unnecessary details.
I just submitted this as its own post, because I thought it was so cool, but here's a complete operating system in 2000 lines of code: https://github.com/yhzhang0128/egos-2000
Egos is really neat, and super approachable. I did some documentation work for it last fall, and despite only having a weak grasp of operating systems I could easily understand the whole thing. I only needed to figure out a few common acronyms and magic numbers that weren’t explained.
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.
Bocker is in this same category...docker clone in bash that's helpful in seeing what's really happening underneath with nsenter, namespaces, network bridging, cgroups, etc.
Plug: I am a big fan of Build Your Own X educational projects. I have a build your own KV Store project. I have set up this project in TDD fashion with the tests. So, you start with simple functions, pass the tests, and the difficulty level goes up. There are hints if you get stuck (e.g. link). When all the tests pass, you will have written a persistent key-value store.
I really enjoyed this short series on making a dns server in python. It's very to the point and watchable. You can get through it in an evening or two.
A DNS resolver is both a client and a server -- for example Google's 8.8.8.8 (which this is a toy version of) is a server (you can query it with `dig @8.8.8.8 example.com`), but also a client of the various authoritative DNS servers that it fetches and caches records from.
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".
Nope, Google’s quad eights is “recursive DNS server”.
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.
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.
Yeah, I'll take a verbose but uncomplicated API any day of the week. Straight-forwardly named classes/functions, no surprising behavior, one concept == one name, and a good reference … that's how stuff gets done.
… always better than something that tries to hide things from you and does the wrong thing sometimes.
Enjoyed. I’ve been experimenting with parsing network protocols a lot lately with an eye to separating the parsing from the “logic” (usually combined in one handler). DNS (and DHCP) are the two I started with - having the flexibility to easily extend/alter the logic is useful from time to time (ala PiHole).
Over time I've learned to stop taking people like Julia Evans for granted.
Sometimes it feels like the Internet is an endless supply of brilliance and generosity and talent. But its not true! Not everyone creates, and not everyone who creates shares, and not everyone who shares shares freely. I feel overwhelmed by gratitude for Julia and (what I estimate to be) the mere ~100 creators in the world like her.
I can't check the code on my phone right now, but does it handle mDNS queries (xyz.local)? It's kind of a special case but really useful in a home setup.