Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Learning DNS in 10 years

Julia Evans
February 01, 2023

Learning DNS in 10 years

From RubyConf Mini 2022

Julia Evans

February 01, 2023
Tweet

More Decks by Julia Evans

Other Decks in Technology

Transcript

  1. notice when you're confused read the specification do experiments spy

    on it what's DNS? implement your own terrible version
  2. notice when you're confused read the specification do experiments spy

    on it what's DNS? implement your own terrible version
  3. “The TTL of this record is set from the minimum

    of the MINIMUM field of the SOA record and the TTL of the SOA itself, and indicates how long a resolver may cache the negative answer.”
  4. $ dig +all new.jvns.ca ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN,

    id: 23308 [redacted] ;; AUTHORITY SECTION: jvns.ca. 10800 IN SOA ns1.gandi.net. hostmaster.gandi.net. 1662903879 10800 3600 604800 10800
  5. def make_question_header(query_id) # id, flags, num questions, num answers, ...

    [query_id, 0x0100, 0x0001, 0x0000, 0x0000, 0x0000] .pack('nnnnnn') end
  6. def make_dns_query(domain, type) query_id = rand(65535) header = make_question_header(query_id) question

    = encode_domain_name(domain) + [type, 1].pack('nn') header + question end