Typorithm · medium

DNS Resolution

dns-resolutionnetworksdnsrecordsresolver
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn DNS Resolution

0%

L7 & TLS

DNS resolves names to IPs through a hierarchy — root, then TLD, then the authoritative server. Record types include A/AAAA (addresses), CNAME (alias), MX (mail), NS (nameserver), and TXT. A recursive resolver caches answers honoring each record's TTL. dig is the standard query tool.

DNS is a distributed, hierarchical directory. A lookup walks the tree: the root servers point to the TLD servers (like .com), which point to the domain's authoritative nameservers, which hold the actual records.

Records come in types. A maps a name to an IPv4 address and AAAA to IPv6; CNAME aliases one name to another; MX lists mail servers; NS names the authoritative nameservers; TXT holds arbitrary text (SPF, verification). dig and host let you ask for a specific type.

A recursive resolver does the multi-step walk on your behalf and caches each answer for the duration of its TTL, so repeat lookups are instant and the authoritative servers see far less traffic. dig is the standard, scriptable query tool; nslookup is the older alternative.

01

Resolution walks root -> TLD -> authoritative nameserver.

02

Record types: A/AAAA, CNAME, MX, NS, TXT.

03

A recursive resolver caches answers per the record's TTL.

dig example.com
dig +short A example.com
dig MX example.com
nslookup example.com
host -t NS example.com

Read the implementation

Connect each part of the code to the concept before you type.

1. Query a name

dig queries DNS for a name and prints the full answer, authority, and additional sections.

dig example.com

2. Just the A record

+short trims the output to the answer; A asks for the IPv4 address.

dig +short A example.com

3. Mail records

MX records name the mail servers that accept email for the domain.

dig MX example.com

4. Alternative lookup

nslookup is an older interactive tool that queries the configured resolver.

nslookup example.com

5. Nameservers

host -t NS asks for the authoritative nameservers of the domain.

host -t NS example.com

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

DNS Resolution: Lesson & Practice · Typorithm | ApplyDjinn