Skip to content

Instantly share code, notes, and snippets.

@dsample
Last active October 16, 2018 09:16
Show Gist options
  • Save dsample/1165d4145d87c43435a40ca2c103ca6c to your computer and use it in GitHub Desktop.
Save dsample/1165d4145d87c43435a40ca2c103ca6c to your computer and use it in GitHub Desktop.
How DNS works

Some example flows for a Medium post about how DNS works.

title Uncached DNS request
participant "User agent" as user
participant "ISP DNS" as edge
participant "A" as com
participant "B" as example.com
participant "C" as bar.example.com
participant "D" as foo.bar.example.com
user -> +edge: Lookup foo.bar.example.com
edge -> edge: Do I have a cache for foo.bar.example.com.? No
edge -> edge: Do I have a cache for bar.example.com.? No
edge -> edge: Do I have a cache for example.com.? No
edge -> edge: Do I have a cache for com.? Yes
note over edge,D: In reality, it will have at least 'com.'\nand in popular cases, `example.com.`
edge -> +A: Lookup example.com.
A --> -edge: Records for example.com.
edge -> edge: Follow NS record to Name Server B
edge -> +B: Lookup bar.example.com.
B --> -edge: Records for bar.example.com.
edge -> edge: Follow NS record to Name Server C
edge -> +C: Lookup foo.bar.example.com
C --> -edge: Records for foo.bar.example.com.
edge --> -user: Records for foo.bar.example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment