DNS and Domain Names

Learn how names resolve to addresses, the common record types and how TTLs affect deployments.

Beginner · about 3 hours · difficulty 2/5

Learn first: How the Internet Moves Data

The Domain Name System turns human names like api.example.com into IP addresses. When a client needs an address it asks a recursive resolver (from the ISP or a public one like 1.1.1.1), which walks the hierarchy: root servers, then the .com TLD servers, then the authoritative name servers for example.com. Answers are cached along the way for as long as the record's TTL allows.

Records a backend developer touches

  • A / AAAA: name to IPv4 / IPv6 address.
  • CNAME: alias one name to another (you cannot put a CNAME at the zone apex on most providers).
  • MX: mail servers for the domain.
  • TXT: free text, used for domain verification, SPF and DKIM email authentication.
  • NS: which servers are authoritative for the zone.

Why it matters

DNS is part of every deployment. Pointing a domain at a new load balancer, verifying a domain for an email provider or switching hosting all mean editing records. Because of caching, a change is not instant: if the old record had a TTL of one day, some clients may keep the old address for a day. A common practice is to lower the TTL well before a planned migration.

Pitfalls

  • Forgetting that failures can be cached too (negative caching).
  • Debugging "the site is down" without checking whether the name resolves. Use dig or nslookup first.

You are ready to move on when you can register a domain (or use a free subdomain), point it at a server and explain what dig shows you.

Key concepts

  • Resolvers and authoritative servers
  • A, AAAA and CNAME records
  • MX and TXT records
  • TTL and caching
  • dig and nslookup
  • DNSSEC

Mini project

Point a domain or free subdomain at a small server, then use dig to trace the lookup from the root servers down with dig +trace.

Check yourself

You changed an A record 10 minutes ago but some users still hit the old server. Why, and how could you have prevented it?

Free resources