Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Networking & Protocols  ›  Lesson

DNS — Names to Addresses

DNS 12 minDNS maps names to records such as A, AAAA, CNAME and MX through resolvers and authoritative servers, and every answer is cached for the record's TTL.

DNS — Names to Addresses

You move notes-api to a new server and update the DNS record. Your laptop sees the new server; a colleague's still hits the old one for an hour. Nothing is broken: that is DNS caching doing exactly what it was told.

The rule

DNS turns names into records, and every answer is cached for its TTL.

The Domain Name System is a distributed database of records attached to names. The ones you will use most:

Record Maps a name to Example
A an IPv4 address notes.example.com → 203.0.113.10
AAAA an IPv6 address notes.example.com → 2001:db8::10
CNAME another name (an alias) www.example.com → example.com
MX the mail servers for a domain example.com → mail.example.com
TXT free text, often for verification and email policy
NS the name servers responsible for a domain

How a lookup works: your machine asks a recursive resolver (from your ISP, company, or a public one). If the resolver has no cached answer, it asks a root server, which points to the .com servers, which point to the domain's authoritative name servers, which give the real answer. The resolver then caches it for the record's TTL (time to live, in seconds).

dig notes.example.com +short           # just the answer
dig notes.example.com                  # full answer, including the TTL
dig @1.1.1.1 notes.example.com         # ask a specific resolver
dig example.com MX +short              # a specific record type

The shortcut

Before any DNS change, lower the TTL first and wait for the old TTL to pass. A 3600-second TTL means resolvers may keep the old answer for an hour after you change it. Drop it to 60 a day ahead, make the change, then raise it again.

Moving notes-api to a new serverStep 1 of 4
  1. Read the current record

    dig notes.example.com shows an A record for 203.0.113.10 with TTL 3600.

When DNS "has not updated", ask which resolver you are querying and what TTL it was given. dig @<resolver> against a few resolvers usually explains the mystery.

Drills

Answer fast — trust the rule.

quick drill

Which record type maps a name to an IPv6 address?

quick drill

You want www.example.com to be an alias for example.com. Which record?

quick drill

A record has a TTL of 3600. What does that allow resolvers to do?

quick drill

Which server holds the real, original records for example.com?

Remember

  • DNS turns names into records, and every answer is cached for its TTL.
  • Shortcut: lower the TTL well before a change, then switch, then raise it.
  • Trap: "DNS is broken" when a resolver is just serving a cached answer.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainMove a service without stale answers

notes.example.com has an A record with a TTL of 3600 and must move to a new server tomorrow. Explain the steps you would take so users switch over quickly, and why.