Skip to content
GEEKnodes

Computing

How DNS Works: From Web Address to IP, Step by Step

What happens from typing an address until the site loads: resolver, root, TLD and authoritative servers, cache, TTL and A, AAAA, CNAME, MX and TXT records.

DNS is the system that translates names like geeknodes.com into IP addresses that computers understand. It works in the background every time you open a website or send an email. This guide explains, step by step and without unnecessary jargon, what happens during that translation and what the DNS records you’ll see in any domain dashboard are.

In short

  • DNS is like a distributed contact list: no one has the whole list, but every server knows whom to ask.
  • A query travels resolver → root → TLD → authoritative server, and the answer is stored in cache for as long as the TTL says.
  • The most common records are A (IPv4), AAAA (IPv6), CNAME (alias), MX (email) and TXT (text and verifications).

Why DNS is needed

On the internet, every server is identified by an IP address, for example 93.184.215.14 (IPv4) or 2606:2800:21f:cb07:6820:80da:af6b:8b2c (IPv6). Remembering that for every website would be impossible.

DNS (Domain Name System) lets you use easy names and also change a website’s server without you noticing anything: you just update which IP the name points to.

The parts of the system

PartWhat it doesExample
Client (your device)Asks for a nameYour browser
Recursive resolverDoes all the work of finding the answerYour ISP’s DNS, 1.1.1.1, 8.8.8.8, 9.9.9.9
Root serversKnow where the servers for each extension are13 identities, from a.root-servers.net to m.root-servers.net
TLD serversKnow which servers manage each domain in their extensionThose for .com, .es, .org
Authoritative serverHas the definitive answer for the domainYour domain provider’s DNS or Cloudflare’s

The 13 root servers are actually hundreds of machines spread around the world that share those 13 addresses.

Step by step: what happens when you type an address

Imagine you type www.ejemplo.com into the browser.

Path of a DNS query from the client to the resolver, root, TLD and authoritative server, until the IP is obtained.
The resolver queries the DNS hierarchy and returns the IP to the client.
  1. Local cache. The browser and the operating system check whether they already have the IP saved from recently. If they do, that’s it: the site starts loading.
  2. Ask the resolver. If not, your device asks the configured resolver (usually the one handed out by the router).
  3. Resolver cache. If someone at your ISP already asked for that name recently, the resolver answers instantly.
  4. Root server. If it doesn’t know, it asks a root server: “www.ejemplo.com?”. The root replies: “I don’t know, but these are the .com servers”.
  5. TLD server. The resolver asks a .com server, which replies: “The authoritative servers for ejemplo.com are ns1.proveedor.net and ns2.proveedor.net”.
  6. Authoritative server. The resolver asks ns1.proveedor.net, which gives the final answer: “www.ejemplo.com is 93.184.215.14”.
  7. Answer and cache. The resolver returns the IP to you and stores it in cache. So does your device.
  8. Connection. Now the browser connects to that IP and requests the page.

All of this usually takes milliseconds, and most of the time it’s resolved at step 1 or 3 thanks to caching.

Recursive vs. iterative queries

  • Your device makes a recursive query: “give me the final answer, you go find it”.
  • The resolver makes iterative queries: it asks each server, which refers it to the next one.

Cache and TTL

Every DNS answer includes a TTL (Time To Live): the number of seconds it can be kept in cache before asking again.

The cache keeps an old IP while the TTL runs and updates it when it expires.
The cache can serve the previous IP until the TTL expires.
TTLEqualsWhen it’s used
3005 minutesBefore a migration, so changes show up quickly
36001 hourTypical value
864001 dayRecords that almost never change

This explains the famous “DNS propagation”: when you change a record, resolvers that already had it cached keep giving the old value until their TTL expires.

Practical tip: if you’re going to change servers, lower the TTL to 300 a day before. That way, after the change, everyone will see the new IP within minutes.

DNS record types

A domain doesn’t have just one “IP”: it has a zone with several records.

Visual comparison of A, AAAA, CNAME, MX and TXT with their basic functions.
Each DNS record serves a different purpose within the zone.
TypeWhat it’s forExample value
AName → IPv4 address93.184.215.14
AAAAName → IPv6 address2606:2800:21f:cb07::1
CNAMEAlias for another namewww → ejemplo.com
MXThe domain’s mail servers, with priority10 mail.ejemplo.com
TXTFree text: SPF, DKIM, verificationsv=spf1 include:_spf.proveedor.com ~all
NSThe zone’s authoritative serversns1.proveedor.net
SOAZone data: primary server, serial number, timersCreated by the provider
CAAWhich authorities can issue SSL certificates0 issue "letsencrypt.org"

Details worth knowing

  • CNAME can’t coexist with other records for the same name. That’s why it’s not usually set on the root domain (ejemplo.com), which already has NS and SOA. Some providers offer their own alternatives such as “CNAME flattening”.
  • MX: the number is the priority; the lower the number, the higher the preference. With 10 mail1 and 20 mail2, mail goes to mail1 and uses mail2 if it fails.
  • TXT is where SPF, DKIM and DMARC live, which prevent others from sending forged email on behalf of your domain.

Look up DNS yourself

On Windows, macOS or Linux you have nslookup:

nslookup geeknodes.com
nslookup -type=MX gmail.com

On macOS and Linux, dig gives more detail, including the TTL:

dig geeknodes.com A
dig +short ejemplo.com MX
dig +trace www.ejemplo.com

dig +trace is especially educational: it shows the full path root → TLD → authoritative.

Simplified example of a response:

;; ANSWER SECTION:
ejemplo.com.   3600   IN   A   93.184.215.14

It reads like this: name, TTL in seconds, class (IN = internet), type and value.

Flush the local DNS cache

Useful if you’ve just changed a record and your device still sees the old one:

ipconfig /flushdns
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

The first is for Windows; the second, for macOS.

Common problems

SymptomLikely cause
“Server DNS address could not be found”The resolver isn’t responding or the domain doesn’t exist
A site loads on your phone over cellular but not at homeA problem with the router’s or ISP’s resolver; try another DNS
You changed the IP and still see the old siteCache and TTL. Wait or flush the local cache
Email isn’t reaching your domainMX record misconfigured or missing
Your emails go to spamSPF, DKIM or DMARC missing in TXT

Frequently asked questions

Does changing DNS speed up the internet?

It doesn’t change the download speed, only how long it takes to resolve names. A fast, reliable resolver makes opening new sites feel slightly snappier.

What is encrypted DNS?

DNS queries normally travel unencrypted. DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt them so no one on the network can see which domains you look up.

Can I block ads with DNS?

Yes: your own DNS server can refuse to resolve ad domains. That’s what Pi-hole on a Raspberry Pi does.

Accessibility preferences

Quick profiles

Text and reading

Text size
Default
Line height
Default
Letter spacing
Default
Word spacing
Default

Colour

Motion and orientation

Cursor