c0nrad's c0rner

Learning and learning

Mar 12, 2026 - 1 minute read - programming dns

Recursive Dns Resolver

Overview

Today’s project is to make yesterday’s stub resolver a recursive resolver. Specifically I want to start with the root.hints and go down the chain till I get the A record for c0nrad.io.

https://gist.github.com/c0nrad/8497352c18d27b93c67a530663335a55

Steps

  1. Ask D.ROOT-SERVERS.NET (NASA) for the NS record of .io
  2. Ask a0.nic.io for the NS of c0nrad.io
  3. Ask ns-1089.awsdns-08.org for the A record of c0nrad.io

Learnings / Refreshers

  • 13 DNS Root servers
    • On ubuntu, you can view the seed /usr/share/dns/root.hints
  • By default, no additional data when getting the .com gtld-servers.net servers because the message size is greater than 512 bytes.
    • I used the EDNS(0) OPT additional record to get 4092 bytes
  • In-Bailiwick vs. Out-of-Bailiwick
    • “Bail” owner, “wick” city? In-zone response
    • When querying a0.nic.io for NS of c0nrad.io, it returns ns-1089.awsdns-08.org, but no additional data with the A record of the NS. So you have to start a subquery.
    • When querying D.ROOT-SERVERS.NET for the NS, it’ll staple the A records in the additional data.
  • When working with an API that has you register callbacks (client.onmessage(callbck)), and you want a send(message) -> response API, you can wrap the api in a new Promise(resolve, reject)