Files
Shaz 42b8971744
Build and deploy Docusaurus / build-and-deploy (push) Successful in 1m1s
Add network & containerisation
2026-03-10 20:31:37 +01:00

3.8 KiB
Raw Permalink Blame History

DNS Basics

How domain names are resolved to IP addresses, and how local DNS differs from public DNS.

For generic networking concepts, see:

For my concrete home server DNS setup, see:


Scope

  • What DNS does and why it exists.
  • How a query is resolved step by step.
  • Common record types.
  • Public DNS vs internal / split DNS.
  • TTL.

1. What DNS Does

DNS (Domain Name System) translates human-readable names like google.com into IP addresses like 142.250.74.46. Without DNS, every user would need to memorise the IP of every service they use.

DNS is a globally distributed, hierarchical database. No single server knows all names — responsibility is delegated across thousands of authoritative name servers worldwide.


2. How a Query Is Resolved

When your browser wants to reach www.example.com:

  1. Local cache — the OS checks if it already has a recent cached answer.
  2. Stub resolver — the OS sends the query to its configured DNS server (usually the router or a public resolver).
  3. Recursive resolver — if not cached, this server performs the full lookup:
    • Asks a root server: "Who handles .com?"
    • Asks the .com TLD server: "Who handles example.com?"
    • Asks the authoritative name server for example.com: "What is www.example.com?"
  4. The answer (an IP address) travels back and is cached at each level.
  5. The OS delivers the IP to the browser, which opens a TCP connection.

This whole process typically takes a few milliseconds.


3. Common Record Types

Type Purpose Example
A Maps a name to an IPv4 address example.com → 93.184.216.34
AAAA Maps a name to an IPv6 address example.com → 2606:2800:…
CNAME Alias: maps one name to another name www.example.com → example.com
MX Mail server for a domain @ → mail.example.com
TXT Arbitrary text; used for SPF, DKIM, domain ownership "v=spf1 include:…"
PTR Reverse lookup: IP → name 34.216.184.93.in-addr.arpa → example.com
NS Authoritative name server(s) for a zone example.com → ns1.example.com

In practice, A, CNAME, and TXT are the records encountered most often.


4. Public DNS vs Internal DNS

4.1 Public DNS

Public resolvers answer queries for any registered domain on the internet. Common examples:

  • 8.8.8.8 / 8.8.4.4 — Google DNS
  • 1.1.1.1 / 1.0.0.1 — Cloudflare DNS
  • 9.9.9.9 — Quad9

Your OS or router is configured to use one of these by default.

4.2 Internal / Local DNS

For names that only exist inside a private network (like .lan domains on a home server), you need an internal DNS server. It answers queries for private names and forwards everything else to a public resolver.

This is called split DNS: different names are resolved by different servers depending on which network you are on.


5. TTL (Time To Live)

Every DNS record has a TTL — a duration in seconds telling resolvers how long they may cache the answer.

  • Short TTL (60300 s): changes propagate quickly, but more queries are made.
  • Long TTL (360086400 s): reduces query load, but changes are slow to propagate everywhere.

When changing a record (for example updating an IP), it is common to lower the TTL beforehand to speed up propagation.