Learning goals
Explain how a hostname becomes an IP address, distinguish recursive from authoritative DNS servers, interpret common record types (A, AAAA, CNAME), understand TTL and caching behavior, and read basic dig output without memorizing every flag.
The problem DNS solves
Humans remember names (api.example.com). Networks route to IP addresses (203.0.113.10 or 2001:db8::1). The Domain Name System (DNS) is the distributed phone book that translates one into the other.
Plain English: before your browser opens a TCP connection, it almost always asks DNS, “What IP goes with this name?” If that lookup fails or returns a stale address, nothing else in the HTTPS story can start.
Resolution steps (stub resolver → answer)
Typical path on a laptop or phone:
- Application asks the OS resolver: “IP for
learning.jdfive.com?” - OS cache — if a recent answer exists and TTL has not expired, return it.
- Configured recursive resolver — often your ISP,
8.8.8.8, or1.1.1.1(company laptops may use an internal resolver). - Recursive resolver walks the tree — starting at root, then TLD (
.com), then authoritative servers forjdfive.com, following delegations until it gets an answer. - Answer returned to the app with A/AAAA records (and cached at each layer per TTL).
Your app → OS cache → recursive resolver → root → .com → jdfive.com authoritative → answer
Authoritative servers hold the truth for a zone (the records your DNS provider lets you edit). Recursive resolvers do the legwork on behalf of clients and cache results.
Record types you will see daily
| Type | Meaning | Example use |
|---|---|---|
| A | IPv4 address | learning.jdfive.com → 203.0.113.10 |
| AAAA | IPv6 address | Same name, IPv6 path |
| CNAME | Alias to another name | www.example.com → example.com |
| NS | Nameserver delegation | Who is authoritative for the zone |
| MX | Mail server | Email routing (not HTTP, but same system) |
| TXT | Arbitrary text | SPF, domain verification, ACME challenges |
CNAME chain: A CNAME points to another hostname, not directly to an IP. The resolver follows CNAMEs until it hits A/AAAA. You cannot put a CNAME at the zone apex (example.com bare) in classic DNS—providers use ALIAS/ANAME tricks at the edge instead.
Plain English: A/AAAA are the final numeric destination. CNAME says “ask again under this other name.”
TTL: time to live
Every DNS answer carries a TTL (seconds). Caches—recursive resolvers, OS, sometimes the browser—may reuse the answer until TTL expires.
- Low TTL (60–300 s): faster failover when you change IPs; more DNS queries.
- High TTL (hours): less load; slow propagation when you misconfigure a record.
Operational pain: you fix a wrong A record but users still hit the old IP until caches expire. Lower TTL before a planned migration if your provider allows it.
Recursive vs authoritative (precise)
- Recursive resolver (client-facing): accepts queries from stubs, performs full lookup, returns a final answer or NXDOMAIN. Configured via DHCP or
/etc/resolv.conf/ system settings. - Authoritative server: answers only for zones it owns; responds with AA (authoritative) bit set for those names.
Your app’s server is neither—it is a stub resolver that delegates to the recursive resolver.
dig intuition
dig (domain information groper) queries DNS from your machine—useful to see what the world gets vs what you think you configured.
dig learning.jdfive.com A +short
dig learning.jdfive.com AAAA +short
dig www.example.com CNAME +trace # verbose delegation path
Read the ANSWER SECTION for records and TTL. AUTHORITY SECTION shows which nameservers serve the zone. Compare:
dig @8.8.8.8 learning.jdfive.com A # query Google recursive directly
dig @ns1.yourprovider.com learning.jdfive.com A # query authoritative
If authoritative is correct but recursive is wrong, wait for TTL or check stale cache. If authoritative is wrong, fix the DNS panel first.
DNS and HTTPS together
TLS certificates are issued for names, validated against what the client requested. DNS must resolve to the server that holds the matching private key. Certificate mismatch (cert for example.com, user typed www.example.com) is a common misconfiguration—fix DNS/CNAME and cert SANs together.
CDNs often ask you to CNAME www to their edge; they terminate TLS at the edge. The DNS story and the TLS story stay linked.
Common mistakes (beginners)
- Editing DNS and expecting instant global change. TTL and resolver caches delay propagation.
- CNAME at apex. Classic DNS forbids CNAME on bare
example.com; use provider-specific apex records or redirect. - Confusing registrar with DNS host. Buying a domain vs hosting its zone files are separate; nameserver (NS) records must point to where records live.
- Ignoring AAAA. IPv6-only or dual-stack clients may prefer AAAA; missing record can mean slow fallback or failure.
- Using
pinghostname as proof DNS is “fine.”pinguses its own resolver path; usedigfor the exact record type you need.
Practice checkpoint
-
What is the difference between authoritative and recursive DNS?
- Answer: Authoritative servers hold official zone data; recursive resolvers fetch answers on behalf of clients and cache them.
-
A record vs CNAME—when do you stop resolving?
- Answer: Stop at A/AAAA (IP). CNAME requires further lookup of the target name until A/AAAA.
-
TTL is 3600 and you change an A record. Why might some users still hit the old IP for up to an hour?
- Answer: Resolvers and OS caches may keep the previous answer until the original TTL expires.
-
What does
dig +short learning.jdfive.com Ashow?- Answer: Just the IPv4 address(es) returned for that name, without verbose sections.
Interview angles
- “What happens in DNS when you hit a URL?” — Stub asks recursive; recursive cache or iterative query from root → TLD → authoritative; A/AAAA returned; cached per TTL.
- “CNAME vs A record?” — A maps name to IP; CNAME maps name to another name (alias). Apex CNAME limitations.
- “How would you debug DNS for a production outage?” — Compare authoritative vs public recursive (
dig @8.8.8.8), check TTL, trace delegations, verify NS glue, check recent panel changes.