Skip to content

Grokem · https://www.grokem.com/cloud/cloud-networking/dns/how-dns-works

What you will learn

  • Follow a DNS lookup from the browser to the answer
  • Explain what a TTL does and why changes take time to spread
  • Choose the right record type for A, AAAA, CNAME, MX and TXT use cases
  • Check a record from the command line

Computers find each other by numbers (IP addresses), but people remember names. The Domain Name System (DNS) is the global directory that turns www.example.com into an address, and it is involved in almost everything you do online.

A lookup, step by step

When your browser needs the address for www.example.com, this is roughly what happens.

  1. The browser and operating system check their own caches. If either remembers a recent answer, it is used and nothing else happens.
  2. The request goes to a recursive resolver. That is a server (usually your internet provider's, or a public one you chose) whose job is to find the answer and remember it.
  3. The resolver checks its cache. Many popular names are answered here.
  4. If not, it asks a root server where to find .com. The root does not know the address; it points to the servers responsible for .com.
  5. It asks a .com (top-level domain) server about example.com. That server replies with the name servers responsible for the domain.
  6. It asks the domain's authoritative server for www.example.com, and receives the real answer: an address and a TTL.
  7. The resolver caches the answer for the TTL and returns it to your computer, which connects.

Each level only knows who to ask next. No single server holds the whole directory, which is why the system scales to the whole internet.

Caching and TTL

Every answer carries a TTL, the number of seconds anyone may reuse it. Caches at every level obey it. This speeds things up enormously, and it explains a classic frustration: when you change a record, nothing is pushed out. Resolvers worldwide keep serving the old answer until their copies expire, so the change appears gradually, up to the old TTL.

Practical consequence: before a planned move (a new server, a new mail provider), lower the TTL a day or two ahead, make the change, then raise it again. A short TTL means faster changes but more lookups.

The record types you will use

Type Holds Example use
A An IPv4 address www points to 203.0.113.10
AAAA An IPv6 address The same, for IPv6
CNAME An alias to another name blog is an alias for sites.example.net
MX Where e-mail for the domain is delivered, with a priority Mail goes to your mail provider
TXT Free text, widely used for verification and e-mail policy SPF, DKIM and DMARC records, domain ownership checks
NS The authoritative name servers for the zone Set at your registrar
SOA Administrative data for the zone Created for you

The address 203.0.113.10 above comes from a range reserved for documentation. Never use a real address in an example.

Checking records yourself

bash
dig +short www.example.com A
dig +short example.com MX
dig +short example.com TXT
nslookup -type=MX example.com

dig is common on Linux and macOS, and nslookup is available on Windows as well. Asking a specific resolver (dig @8.8.8.8 example.com) shows what that resolver sees, which helps when a change appears for some people and not others.

Common mistakes

  • A CNAME at the root of the domain. It is not allowed alongside the records the root must have. Use an A or AAAA record, or your provider's alias feature.
  • Forgetting the dot. In some zone files, a name without a trailing dot is treated as relative and gets the zone name appended, giving example.com.example.com.
  • Changing records at the wrong place. The records live at whoever your name servers say they do. Editing a zone at one provider while the registrar still points at another changes nothing.
  • Leaving old records behind. A record pointing at a decommissioned service can be taken over by someone else. Remove what you no longer use.
  • Expecting an instant change. Allow for the TTL.
  • Mail records missing. E-mail delivery depends on correct MX and TXT records. When mail misbehaves after a DNS change, check these first.

Beyond lookup

Plain DNS is not encrypted or authenticated by default. DNSSEC adds signatures so answers can be checked, and DNS over HTTPS or TLS encrypts the question between you and your resolver. Both are worth knowing when you work on security.

Glossary

Resolver
The server (often run by your ISP or a public provider) that looks up names on your behalf and caches answers.
Authoritative server
The server that holds the real records for a domain and gives the final answer.
Record
One entry in a domain's zone: a name, a type, a value and a TTL.
TTL
Time to live: how many seconds a cached answer may be reused.
Zone
The set of records a particular authoritative server is responsible for.
Registrar
The company through which a domain name is registered and its name servers are set.

Frequently asked questions

Why do DNS changes take time to 'propagate'?

Nothing is pushed anywhere. Resolvers around the world simply keep the old answer until its TTL runs out, so a change becomes visible gradually as caches expire.

Why can't I put a CNAME on my root domain?

A CNAME means 'this name is an alias for another', and it cannot coexist with the other records the root (apex) of a zone must have, such as NS and SOA. Many providers offer an alias or flattened record that works around this.

Next steps

  • Look up the records for your own domain with dig or nslookup
  • Lower a TTL before a planned change, and raise it again afterwards

References

From Grokem: https://www.grokem.com/cloud/cloud-networking/dns/how-dns-works

Lesson 2 of 7 in Infrastructure basics for data work

How did this strike you?

Be the first to react – it is anonymous.

Community

Questions about this?

Ask in Questions and help and get help from other readers.

Ask a questionBrowse Questions and help

Comments (2)

  • Samir P.

    What does TTL mean on a DNS record?

    • Grokem Editorial

      Time to live: the number of seconds a resolver may keep the answer before asking again. A long TTL means fewer lookups but a slow spread of any change; lower it a day before a planned move, then raise it again afterwards.

Choose what we may use. You can change this at any time with “Privacy choices” at the foot of every page. Details are in the Cookie policy and the Privacy policy.

Strictly necessary

Remembers your theme, the lessons you marked as done and this choice. It stays on your device, tracks nothing and cannot be switched off.

Always on
What exactly is collected, and why

Grokem’s own counts

Collects
The pages you open and how long you stay, how far you scroll, where you came from, your device type, browser, screen size, language and time zone. Your IP address is turned into a code that changes every day; it is never stored as it is.
Why
To see how long lessons are read and where readers leave. Not shared with anyone.
Stored
A random visitor ID, a visit ID and the time of your last page view in your browser’s storage (gr_vid, gr_sid, gr_last). No name or email is attached.