Routelearn.net
Course menu

Unit 8: Core Network ServicesLesson 8.1 (1 of 4 in this unit)54 of 84 in the Network Fundamentals course

DNS: How Names Become IP Addresses

Learn why DNS is needed, how a domain name is built, and what happens, server by server, when your computer looks up routelearn.net. The lesson covers resolvers, root, TLD and authoritative servers, caching and TTL, record types, and how to test DNS with nslookup and dig.

Beginner · 18 min read · Before this: What is an IP address?, How UDP works

DNS (Domain Name System) is the distributed, hierarchical naming system that translates domain names into IP addresses and other data stored in resource records. A recursive resolver finds an answer by querying root, top-level domain (TLD) and authoritative name servers, and caches it for the time set by the record’s TTL.

In simple terms: DNS works like a contacts list for the internet: you type a name like routelearn.net, and DNS finds the IP address your computer needs to connect.

DNS (the Domain Name System) maps human-readable domain names, like routelearn.net, to the IP addresses computers actually use to send traffic. Without it, you'd have to memorise an IP address for every website instead of typing a name. People often call it “the phonebook of the internet”, but it does more than a phonebook. Different record types hold different kinds of information, not just addresses.

The addresses in this lesson (203.0.113.10, 198.51.100.53 and so on) are documentation examples, chosen so the steps are easy to follow. Look up the real addresses yourself with the DNS Lookup tool.

Why DNS is needed

Computers find each other with numbers. A packet on the internet carries a source and destination IP address, never a name. People, on the other hand, remember names much better than numbers. DNS sits in between and solves several problems at once:

Names are easy to remember

routelearn.net is easier to type and recall than 203.0.113.10, and far easier than an IPv6 address like 2001:db8::10.

Addresses can change

A website can move to a new server or hosting company. The owner updates one DNS record, and the name keeps working.

One name, many servers

Large sites give different addresses to different users, to spread the load or send people to a nearby data centre.

More than web pages

DNS also says which servers accept email for a domain (MX) and holds text used to prove who owns a domain (TXT).

No single computer could hold every name on the internet, so DNS is a distributed database. The data is split across millions of servers, and each one is responsible for a small part of the namespace.

💡 In simple terms: a lookup is like asking a librarian (the resolver) to find a book. The librarian doesn't know every book in the world, so they check a directory (the root server). The directory points them to the right section (the TLD server), and the section points them to the exact shelf (the authoritative server) that has the book.

Where DNS sits in the network

DNS is an application-layer protocol, like HTTP. It is a helper service. Before your browser can open a TCP connection to a website, it needs the website's IP address, and DNS provides it. Your computer learns which DNS server to ask from DHCP (DHCP option 6) or from a manually entered setting.

Laptop192.168.1.20Home router192.168.1.1Recursive resolver198.51.100.53Root server.net TLDAuthoritativeroutelearn.net
  1. 1. Ask once. The laptop's stub resolver sends one query to its recursive resolver (here, through the home router).
  2. 2. Root. The resolver asks a root server, which refers it to the .net TLD servers.
  3. 3. TLD. The .net server refers it to the authoritative servers for routelearn.net.
  4. 4. Authoritative. The authoritative server gives the final answer.
  5. 5. Answer. The resolver caches the answer and sends it back to the laptop.

Notice that the laptop only talks to one server: its recursive resolver. All the other queries go between the resolver and the servers on the internet.

Domain names and their parts

A domain name is a list of labels separated by dots. Each label is one level in a tree, and a name is read from right to left. The top of the tree is the root, written as a single dot. You almost never type it, but it is always there: the full name is really www.routelearn.net. with a dot at the end.

1 · The parts of a name
www.routelearn.net.
www · Host / subdomain
A name inside the domain, chosen by its owner
routelearn · Second-level domain
The part you register and pay for
net · Top-level domain (TLD)
Run by a registry, e.g. .net, .com, .uk
. · Root
The top of the tree; usually left off when you type

Read right to left: the root, then the TLD, then the domain, then the host. Each dot moves one level down the tree.

2 · The same name in the DNS tree
  • . (root)Root servers
    • com.com TLD servers
    • net.net TLD servers
      • example.netIts own name servers
      • routelearn.netAuthoritative servers for routelearn.net
        • www.routelearn.netA record
        • mail.routelearn.netA record
    • org.org TLD servers
    • uk.uk TLD servers
www.routelearn.net split into its labels, and the path from the root down to it.
TermMeaningExample
LabelOne piece of the name between dots (up to 63 characters)routelearn
TLDTop-level domain: the last labelnet, com, uk
DomainA name you register under a TLDroutelearn.net
Subdomain / host nameA name the owner creates inside the domainwww.routelearn.net
FQDNFully qualified domain name: the complete name, up to the rootwww.routelearn.net.
ZoneThe part of the tree that one set of authoritative servers is responsible forThe routelearn.net zone

DNS names are not case-sensitive: RouteLearn.NET and routelearn.net are the same name.

The main components

A lookup involves several types of DNS server and software. Each one has a single job:

Stub resolver

Inside your laptop or phone

A small part of the operating system. It does not search the internet itself. It asks one question (“what is the address of routelearn.net?”) and waits for a complete answer.

Recursive resolver

Your ISP, your company, or a public service

Does the real work. It asks the root, TLD and authoritative servers in turn until it has the answer, then caches it. Also called a recursive DNS server or simply a DNS resolver.

Root servers

Hundreds of sites worldwide, 13 server names

The top of the tree. They don't know where routelearn.net is, but they know who runs every top-level domain such as .net, .com and .uk.

TLD servers

Run by the registry for each TLD

They know which name servers are responsible for each domain under their TLD. For example, the .net servers know which servers answer for routelearn.net.

Authoritative servers

Run by the domain owner or their DNS host

The source of truth for a domain. They hold the records the owner created (A, MX, TXT and others) and give the final answer.

Stub resolver and recursive resolver

The stub resolver on your computer sends a recursive query, which means “please give me the final answer”. The recursive resolver accepts that job. To complete it, it sends iterative queries to other servers. Each server either answers or replies “I don't know, but ask this server next”. That reply is called a referral.

Which recursive resolver you use depends on the network. At home, it is usually your internet service provider's (ISP's) resolver, often reached through the home router, which passes queries on (it acts as a DNS forwarder). Companies usually run their own resolvers. Some people choose a public resolver such as 1.1.1.1 (Cloudflare) or 8.8.8.8 (Google).

Root servers

There are 13 root server names, from a.root-servers.net to m.root-servers.net, run by 12 different organisations. Each name is served by many copies around the world using anycast: the same address is announced from many places, so a query reaches a nearby copy. In total, there are well over a thousand root server instances. Every recursive resolver comes with a list of the root server addresses, called the root hints, so it always knows where to start.

TLD and authoritative servers

TLD servers hold a list of name servers (NS records) for every domain under their TLD. When you register routelearn.net, the registrar tells the .net registry which name servers will answer for it. Those name servers are the authoritative servers. They hold the zone, with all the records for the domain.

Caching and TTL

Asking the root, TLD and authoritative servers for every single click would be slow and would overload those servers. So every DNS answer is cached (kept in memory) for a while, in several places:

  1. The browser cache: browsers keep their own short-lived list of recent lookups.
  2. The operating system cache: the stub resolver remembers answers for every program on the computer. The local hosts file is checked at this stage too.
  3. The recursive resolver cache: shared by everyone who uses that resolver, so a popular name is almost always already there.

Every DNS record has a TTL (time to live): a number of seconds, set by the domain owner, that tells caches how long they may keep the answer before asking again. A TTL of 300 means five minutes; 86400 means one day. The resolver counts the TTL down, and when it reaches zero, the cached copy is removed.

This is a deliberate trade-off. A longer TTL means faster lookups and less load on authoritative servers, but a change to the record takes longer to reach everyone. “DNS propagation” isn't instant: it spreads gradually as each resolver's cached copy expires and is fetched again.

💡 Resolvers also cache the referrals. After one lookup, a resolver already knows the .net TLD servers, so its next lookup of any .net name skips the root. In practice, resolvers query the root servers quite rarely.

Step by step: looking up routelearn.net

Here's what happens in one complete lookup with a cold cache, meaning no cache along the way has the answer yet. Your laptop is 192.168.1.20 and its DNS server (from DHCP) is the ISP resolver at 198.51.100.53.

  1. Browser cache. You type routelearn.net. The browser checks its own cache and finds nothing.
  2. Operating system cache. The browser asks the operating system. The stub resolver checks the hosts file and its own cache, and finds nothing there either.
  3. Query to the recursive resolver. The stub resolver sends a recursive query, "A record for routelearn.net?", in a UDP datagram to 198.51.100.53 port 53.
  4. Resolver checks its cache. There is no copy, so it must find the answer itself.
  5. Ask a root server. The root doesn't know routelearn.net, but replies with a referral: "ask the .net TLD servers", with their names and addresses.
  6. Ask a .net TLD server. It replies with another referral: "routelearn.net is answered by these name servers".
  7. Ask the authoritative server. It finally answers: routelearn.net A 203.0.113.10, TTL 300 seconds. This answer is marked authoritative.
  8. Cache and reply. The resolver stores the answer (and the referrals) for their TTLs and sends the answer back to the laptop.
  9. Laptop caches it too. The operating system and the browser both store 203.0.113.10. The browser can now open a TCP connection to 203.0.113.10 port 443 (HTTPS).

Here is the same lookup as a sequence of messages. Tap any arrow to see what is inside the packet.

Step 1 of 8 · Query
Resolving routelearn.net · cold cache
Laptop
Stub resolver
Resolver
198.51.100.53
Root
a–m.root-servers
.net TLD
gtld-servers
Authoritative
routelearn.net

1. Query · Laptop → resolver · UDP 51514 → 53

The browser and OS caches have no answer. The stub resolver asks: “A record for routelearn.net? Please recurse.”

Tap this step's arrow for the details.

Now cached for up to 300 seconds
Name:
routelearn.net
Type:
A
Address:
203.0.113.10

With a warm cache, the resolver answers from memory straight after message 1, and the whole lookup takes a few milliseconds.

A complete DNS resolution of routelearn.net, from the laptop's stub resolver to the authoritative server and back.

The same chain in one line:

Step 1 of 7
  1. Browser"Where is routelearn.net?"
  2. Recursive resolverYour ISP or public DNS
  3. Root server"Ask the .net TLD servers"
  4. TLD server"Ask routelearn.net's own server"
  5. Authoritative serverReturns the actual record
  6. IP address203.0.113.10
  7. Web serverBrowser connects directly
Resolving routelearn.net to an IP address, step by step.

This whole chain usually completes in well under a second. Most of the time, steps are skipped completely because a cache already has the answer. A separate lesson follows a whole page load, from DNS to TCP to HTTPS.

Learn more: What Happens When You Open a Website?

What is inside a DNS packet

A DNS query is small, often under 100 bytes. It travels as data inside a UDP datagram, which is inside an IP packet, which is inside an Ethernet frame.

Learn more: Encapsulation and De-encapsulation

LayerFieldQuery from the laptopReply from the resolver
EthernetDestination MACThe home router (default gateway)The laptop
IPSource → destination192.168.1.20 → 198.51.100.53198.51.100.53 → 192.168.1.20
UDPSource → destination port51514 → 5353 → 51514
DNSIDA random number, e.g. 41872The same number, so it matches
DNSFlagsQuery, RD (recursion desired)Response, RD, RA, status NOERROR
DNSQuestionroutelearn.net, A, INThe question, repeated
DNSAnswerEmptyroutelearn.net 300 IN A 203.0.113.10

The resolver is on another network, so the frame is addressed to the default gateway's MAC address, found with ARP. On the way out, the home router's NAT also replaces the private source IP address with its own public address.

UDP 53 and TCP 53

DNS is registered on port 53 for both UDP and TCP:

TransportWhen it is usedWhy
UDP 53Almost every normal lookupOne small question, one small answer, no handshake, so it is fast. If a reply is lost, the client simply asks again.
TCP 53Large answers, and zone transfers between serversIf an answer is too large for UDP, the server sets the TC (truncated) flag and the client repeats the query over TCP. Zone transfers copy a whole zone and need TCP's reliability.
TCP 853 / 443Encrypted DNS (DoT / DoH)DNS over TLS and DNS over HTTPS encrypt lookups, so others on the network can't read them.

A firewall that allows only UDP 53 will break the occasional large answer, so allow TCP 53 to your resolvers as well.

Learn more: Common Ports to KnowTCP vs. UDP Compared

Common record types

A zone holds resource records. Each record has a name, a TTL, a class (almost always IN, for internet), a type and a value. The type shows what kind of information the record holds:

TypeWhat it holdsExample
AMaps a name to an IPv4 addressroutelearn.net → 203.0.113.10
AAAAMaps a name to an IPv6 addressroutelearn.net → 2001:db8::10
CNAMEAn alias pointing one name to another name (not to an address)www.routelearn.net → routelearn.net
MXThe mail servers that accept email for the domain, each with a priority (lower is preferred)10 mail.routelearn.net
NSThe authoritative name servers for the domainns1.routelearn.net
TXTFree text, commonly used for domain verification and email authentication (SPF, DKIM)v=spf1 mx -all
PTRReverse lookup: an IP address back to a name10.113.0.203.in-addr.arpa → routelearn.net
SOAAdministrative information about the zone: primary name server, admin contact, serial number, timersOne per zone

It is normal for a domain to have only a few of these. Many domains have little more than A, NS and MX records, plus the SOA record that every zone has. A missing record type usually just means that feature isn't used, not that anything is broken.

Real-world scenario: moving a website to a new host

A company moves its website to a new hosting provider and updates its A record to point to the new server's IP address. Visitors whose resolvers cached the old record, for example with a 24-hour TTL, keep reaching the old server until that cached copy expires, even though the record itself changed instantly. That is why teams usually lower the TTL before a migration, so the switch-over is quick when it happens.

  1. A few days before: lower the TTL from 86400 (one day) to 300 (five minutes). Wait at least one old TTL so every cache picks up the short one.
  2. Moving day: change the A record to the new address. Within about five minutes, resolvers start using it.
  3. Keep the old server running for a while, in case a cache somewhere ignored the TTL.
  4. Afterwards: raise the TTL again to reduce the number of lookups.

What happens when DNS fails

When DNS breaks, the network itself usually still works. Packets to IP addresses still flow; only names stop working. That is why “the internet is down” so often really means “DNS is down”.

What you seeWhat it meansTypical cause
Timeout (“DNS request timed out”)No DNS server answeredResolver down or unreachable, wrong DNS server address, firewall blocking port 53
NXDOMAIN (“Non-existent domain”)The authoritative server says the name does not existA typo, an expired domain, a name that was never created
SERVFAILThe resolver tried but could not get a valid answerAuthoritative servers broken or unreachable, DNSSEC validation failure
An answer, but the wrong addressDNS works but holds old or wrong dataStale cache after a change, a hosts file entry, a wrong record
Browser error “DNS_PROBE_FINISHED_NXDOMAIN”The browser could not resolve the nameAny of the causes above: test with nslookup

Troubleshooting DNS: useful commands

The first test is always the same: can you reach the site by IP address but not by name? If ping 203.0.113.10 works but ping routelearn.net says it could not find the host, the network is fine and DNS is the problem. Then use the tools below. A later lesson walks through a full fault-finding example.

Learn more: DNS Problems

nslookup (Windows, Linux and macOS)

Example output from a Windows PC, written for this lesson
C:\> nslookup routelearn.net
Server:  router.home
Address:  192.168.1.1

Non-authoritative answer:
Name:    routelearn.net
Address:  203.0.113.10
What to look for: Server and Address show which DNS server answered. Here it is the home router at 192.168.1.1, which forwards queries to the ISP's resolver. Under Non-authoritative answer, the Address line is the result: 203.0.113.10. “Non-authoritative” is normal; it means the answer came through a resolver, not directly from routelearn.net's own server.
Example output from a Windows PC, written for this lesson
C:\> nslookup routelearn.net 1.1.1.1
Server:  one.one.one.one
Address:  1.1.1.1

Non-authoritative answer:
Name:    routelearn.net
Address:  203.0.113.10
Adding a server address at the end sends the query to that server instead of your usual one. What to look for: the Server line now shows 1.1.1.1. If this works but the plain command fails, your own resolver is the problem.
Example output from a Windows PC, written for this lesson
C:\> nslookup routlearn.net
Server:  router.home
Address:  192.168.1.1

*** router.home can't find routlearn.net: Non-existent domain
What to look for: Non-existent domain is NXDOMAIN. A typo (a missing “e”) caused it. DNS is working correctly; the name simply does not exist.

dig (Linux and macOS)

Example output from a Linux computer, written for this lesson
$ dig routelearn.net
; <<>> DiG 9.18.28 <<>> routelearn.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41872
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;routelearn.net.                IN      A

;; ANSWER SECTION:
routelearn.net.         300     IN      A       203.0.113.10

;; Query time: 24 msec
;; SERVER: 192.168.1.1#53(192.168.1.1) (UDP)
;; WHEN: Mon Oct 05 10:15:02 UTC 2026
;; MSG SIZE  rcvd: 59
What to look for: status: NOERROR means success. The ANSWER SECTION line shows the name, the remaining TTL (300 seconds), the class, the type and the address. SERVER shows which resolver answered, over UDP port 53. Run the command again and the TTL will be lower and the query time close to 0 ms, because the answer now comes from a cache.
CommandWhat it does
dig routelearn.net MXAsks for a specific record type (MX, AAAA, TXT, NS and so on)
dig +short routelearn.netPrints only the answer, e.g. 203.0.113.10
dig @1.1.1.1 routelearn.netAsks a specific DNS server
dig +trace routelearn.netFollows the root → TLD → authoritative chain itself and prints every referral
dig -x 203.0.113.10Reverse lookup (PTR record)

Looking at and clearing the local cache

ipconfig /displaydns

Windows: list the names in the operating system's DNS cache, with their remaining TTL.

ipconfig /flushdns

Windows: empty the DNS cache, so the next lookup asks the resolver again.

resolvectl status

Linux (systemd-resolved): show which DNS servers each interface uses.

sudo resolvectl flush-caches

Linux (systemd-resolved): empty the local DNS cache.

ipconfig /all on Windows, or cat /etc/resolv.conf on Linux, shows which DNS server the computer is using. If that address is wrong, check your DHCP settings.

Common mistakes

  • Blaming the network for a DNS problem, or the other way round. Test with an IP address first; it tells you which half of the problem to look at.
  • Expecting DNS changes to appear instantly. Old answers stay in caches until their TTL runs out. Lower the TTL before a planned change.
  • Forgetting the local caches. After a fix, the browser and operating system may still hold the old answer. Flush the OS cache and restart the browser.
  • Forgetting an old entry in the hosts file. It overrides DNS on that computer, so nslookup (which asks the DNS server directly) and the browser can give different answers.
  • Allowing only UDP 53 through a firewall. Large answers fall back to TCP 53, so those lookups fail.
  • Pointing a CNAME at an IP address. A CNAME must point to another name. Use an A or AAAA record for an address.
  • Thinking “Non-authoritative answer” is an error. It is normal; it only means the answer came through a resolver.
✅ Key takeaways
  • DNS translates names into IP addresses (and more) using a distributed, tree-shaped database.
  • Names are read right to left: root, TLD, domain, host.
  • Your computer's stub resolver asks one recursive resolver, which queries the root, TLD and authoritative servers for it.
  • Answers are cached in the browser, the OS and the resolver for the record's TTL.
  • DNS uses UDP 53 for normal lookups and TCP 53 for large answers and zone transfers.
  • If an IP address works but a name doesn't, suspect DNS and test with nslookup or dig.

Check yourself

Predict · scenario 1

Your laptop needs the address of routelearn.net and nothing is cached anywhere. Which server does the laptop itself send its query to?

Predict · scenario 2

A record has a TTL of 3600 seconds. A resolver cached it just before you changed the address. When will that resolver start giving out the new address?

Predict · scenario 3

ping 203.0.113.10 works, but ping routelearn.net says it could not find the host. What is the most likely problem?

Predict · scenario 4

A DNS answer is too large to fit in a UDP reply from the server. What happens next?

Predict · scenario 5

A resolver with an empty cache asks a root server for the address of routelearn.net. What does the root server reply?

Related lessons

DNS builds on several earlier lessons. Names are looked up over UDP on a well-known port, and your DNS server address is usually provided by DHCP. To see DNS as one step in the bigger picture, read What happens when you open a website? When names stop working, go to DNS problems.

FAQ

Why does a DNS change take time to show up everywhere?
Because of caching. Every record has a TTL that tells resolvers how long they may cache the answer before asking again. A resolver only sees a change after its cached copy expires. That is why "DNS propagation" happens gradually rather than everywhere at once: nothing is pushed out, and old copies simply expire.
What's the difference between a recursive resolver and an authoritative server?
A recursive resolver does the work for you: it follows the chain from the root to the TLD to the authoritative server. An authoritative server is the source of truth for a specific domain's records. It only answers questions about the zones it is responsible for.
Does DNS use UDP or TCP?
Both, on port 53. Normal lookups use UDP 53 because a question and its answer each fit in one small datagram. DNS switches to TCP 53 when an answer is too large for UDP, and servers use TCP for zone transfers. Encrypted DNS also exists: DNS over TLS (DoT) uses TCP 853 and DNS over HTTPS (DoH) uses port 443.
Is DNS the same thing as a firewall or ad blocker?
No. Some ad blockers work through DNS: they refuse to resolve known ad or tracker domains, so your device never connects to those servers. But DNS itself is only a lookup system for names. Blocking is a feature built on top of it, and a firewall filters the traffic itself, not the names.