Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Learning DNS in 10 years
Search
Julia Evans
February 01, 2023
Technology
260
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Learning DNS in 10 years
From RubyConf Mini 2022
Julia Evans
February 01, 2023
More Decks by Julia Evans
See All by Julia Evans
Blogging myths
jvns
0
3.7k
High Reliability Infrastructure migrations
jvns
10
14k
Building a Ruby profiler
jvns
2
430
Build impossible programs
jvns
23
95k
So you want to be a wizard
jvns
25
26k
Learning systems programming with Rust
jvns
14
8.3k
Systems programming is for everyone
jvns
12
3.2k
How to read your computer's mind
jvns
6
810
Why I ❤ Rust
jvns
50
55k
Other Decks in Technology
See All in Technology
コーチングの奥義 何もしないテクニック
jinwatanabe
0
140
私がブラウザを自作したくなった理由
supurazako
1
280
tamachi.go 誕生の裏側
rymiyamoto
1
190
自宅NWにISR4331を導入してみた話
okaits
0
120
会社紹介資料 / Sansan Company Profile
sansan33
PRO
24
430k
関東Kaggler会発表資料
takoi
1
270
ホームラボ紹介
y_sera15
0
220
My broken English still works: speaking at global OSS events
naruoga
0
120
2027年のMetricKit
kantacky
0
140
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
20k
作って理解するCoding Agent 〜フレームワークに頼らないピュア Python での実装〜
takapy
2
460
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
210
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Fireside Chat
paigeccino
42
4k
Faster Mobile Websites
deanohume
310
32k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.4k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
280
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
440
For a Future-Friendly Web
brad_frost
183
10k
Transcript
None
None
None
None
None
None
None
notice when you're confused read the specification do experiments spy
on it what's DNS? implement your own terrible version
None
None
None
None
None
notice when you're confused read the specification do experiments spy
on it what's DNS? implement your own terrible version
None
None
$ dig example.com example.com. 86400 IN A 93.184.216.34
$ dig example.com example.com. 86400 IN A 93.184.216.34
+noall +answer .digrc
None
None
None
None
None
browser resolver authoritative nameservers DNS query DNS query where's example.com?
where's example.com? 93.184.216.34! 93.184.216.34!
resolver browser what's the IP for example.com? hmm, I'll look
in my cache...
None
None
None
None
None
None
None
browser resolver authoritative nameservers DNS query DNS query where's new.jvns.ca?
where's new.jvns.ca? NXDOMAIN NXDOMAIN
None
None
None
“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.”
None
$ 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
None
None
None
None
None
None
None
None
browser resolver authoritative nameservers DNS query DNS query where's example.com?
where's example.com? 93.184.216.34! 93.184.216.34!
None
None
None
None
require 'socket' sock = UDPSocket.new sock.bind('0.0.0.0', 0) sock.connect('8.8.8.8', 53)
None
hex_string = "b9620100000100..." bytes = [hex_string].pack('H*') sock.send(bytes, 0)
b96201000001000000000000 076578616d706c6503636f6d0000010001
b96201000001000000000000 076578616d706c6503636f6d0000010001
b96201000001000000000000
def make_question_header(query_id) # id, flags, num questions, num answers, ...
[query_id, 0x0100, 0x0001, 0x0000, 0x0000, 0x0000] .pack('nnnnnn') end
b96201000001000000000000 076578616d706c6503636f6d0000010001
076578616d706c6503636f6d0000010001 7 e x a m p l e 3
c o m 0 1 1
def encode_domain_name(domain) domain.split('.') .map { |x| x.length.chr + x }
.join + "\0" end example.com 7example3com0
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
None
None
None
notice when you're confused read the specification do experiments spy
on it implement your own terrible version
None