Computing Foundations › How the Internet Works › Day 16

Day 16: IP Addresses, DNS, and Routing

Day 16 of 365 — IP Addresses, DNS, and Routing

After this lesson you will be able to explain how a machine is addressed, how a name is turned into that address by DNS, and how packets are routed to it — and to diagnose the two most common "can't reach the server" failures by hand with dig, ping, and traceroute.

Course
Computing Foundations
Category
How the Internet Works
Reading time
≈ 40 min
Practical time
≈ 30 min
Lesson duration
1h 10m
Last verified
2026-07-12

Hands-on lab for this lesson

Lab files on GitHub: https://github.com/ai-roadmap-365/ai-roadmap-365.github.io/tree/main/labs/sections/computing-foundations/day-016-ip-addresses-dns-and-routing

  1. Get the hands-on files. Clone the labs repository once (you can reuse this clone for every lesson). This works on macOS, Linux, and Windows (PowerShell or WSL):
    git clone https://github.com/ai-roadmap-365/ai-roadmap-365.github.io.git
    cd ai-roadmap-365.github.io
  2. Open this lesson's lab. Move into the directory for this specific day. Every lab lives at the same predictable path — section / subsection / week / day:
    cd labs/sections/computing-foundations/day-016-ip-addresses-dns-and-routing
  3. Read the lab guide. Open `README.md` in that directory. It lists the exact commands, what each does, the expected output, and how to check your work — read it before running anything.
  4. Run it and check your work. Follow the README's "How to run" section: run the example first to see the finished result, then complete the numbered exercises in `starter/`, then run the tests. The tests pass (exit 0) only when your work is correct.
    bash tests/run_tests.sh   # or the test command named in the lab README

You can also open the lab as a local page (works offline, shows the file tree and expected output).

Learning objectives

By the end of this lesson you will be able to:

Prerequisites

Why this matters


The idea in plain language


Historical background

Diagram: a single hosts file compared with delegated DNS


What it is — and what it is not

Diagram: a recursive resolver compared with an authoritative server

DNS is:

DNS is not:


Why it was created and what problems it solves


How it works

Resolving a name

Diagram: the steps a DNS lookup passes through from cache to authoritative server

Your computer asks a recursive resolver — your ISP’s, or a public one like 1.1.1.1 — to do the legwork:

  1. Root. “Who handles .com?” The root does not know example.com, but it knows the .com servers. There are 13 named root identities, a through m, each a globally distributed fleet.

  2. TLD. “Who handles example.com?” The .com servers refer it to the authoritative name servers the domain’s owner designated.

  3. Authoritative. That server returns the actual record — an A record giving an IPv4 address, for instance.

  4. Answer and cache. The resolver returns the address and remembers it until the TTL expires.

Flowchart: a resolver walking the DNS hierarchy from root to TLD to authoritative server, with caching

RecordPurposeExample
AName to IPv4 address93.184.216.34
AAAAName to IPv6 address2606:2800:220:1:248:1893:25c8:1946
CNAMEAlias: this name is really that namewww.example.com → example.com
MXWhere email for the domain goes10 mail.example.com
TXTArbitrary text, for verification and policy"v=spf1 ..."
NSDelegates the domain to its authoritative serversa.iana-servers.net

Routing packets

Diagram: a packet hopping across routers and autonomous systems from a source computer to a destination server

Watching the hops

Diagram: how traceroute uses the hop limit to reveal each router


An everyday analogy

Diagram: how the hosts file takes precedence over DNS

The postal system.

The postThe network
A person’s name in a directoryA domain name
Their street addressAn IP address
Directory enquiriesA recursive resolver
”Ask the county office”Delegation to a TLD
The local sorting officeYour default gateway
Each office deciding the next vanRouting, hop by hop
An internal room numberA private address

Examples in practice

Diagram: how a CNAME record leads to a second lookup


Implications: security, privacy, performance, scalability, and cost

Diagram: a short DNS time-to-live compared with a long one


Subnets and CIDR, briefly

Diagram: private address ranges compared with public ones

RangeKindWhere it is used
10.0.0.0/8PrivateLarge internal networks; ~16.7 million addresses
172.16.0.0/12PrivateMedium internal networks
192.168.0.0/16PrivateHome and small office
127.0.0.0/8LoopbackThis machine itself
Everything else routablePublicGlobally reachable, assigned by registries

Alternatives: free, open source, and commercial

ToolTypeWhat it gives you
digFree, built inExactly what was returned, and by which server
nslookupFree, built inSimpler output; fine for a quick check
hostFree, built inThe shortest answer of the three
traceroute / mtrFreeThe path, and where latency appears
1.1.1.1, 8.8.8.8, 9.9.9.9FreePublic resolvers, often faster than an ISP’s
Cloudflare / Route 53 / NS1Commercial, free tiersAuthoritative hosting with low-latency global fleets

Diagram: IPv4 compared with IPv6

TermWhat it actually is
IP addressWhere a machine is, on a network
Domain nameA human-readable name that resolves to one
ResolverThe server that does the lookup work for you
Authoritative serverThe one holding the real records for a domain
TTLHow long an answer may be cached
Autonomous systemA large network under one administrative control
BGPHow autonomous systems advertise what they can reach

When to use it — and when not to

Diagram: how the CIDR prefix length determines block size


The AI connection

Diagram: four DNS failures and what each looks like


Knowledge check

quiz:
  question: "You update a domain's A record to point at a new server. Some users reach the new server immediately; others keep landing on the old one for hours. What explains the split?"
  options:
    - "Resolvers are still serving the previous answer until its TTL expires"
    - "The new server's DNS record was written with the wrong record type"
    - "BGP has not yet propagated the route to the new server's network"
    - "The authoritative name servers have not finished synchronising with each other"
  answer_index: 0
  explanation: "Every DNS answer carries a time to live, and a resolver that cached the old address serves it until that expires. Users behind a resolver with a fresh cache get the new answer; users behind one holding the old record do not, until the clock runs out."

Hands-on exercise

Resolve a name by hand, then follow a packet. Worked through fully in the Day 16 lab directory.

What you are doingCommand
The short answerdig example.com +short
The full answer with TTLdig example.com
Walk the hierarchy yourselfdig example.com +trace
Ask a specific resolverdig @1.1.1.1 example.com
Look up other record typesdig example.com MX and dig example.com NS
Follow the pathtraceroute example.com
See your own addressesipconfig getifaddr en0 or ip addr

Expected output

example.com.    3600    IN    A    93.184.216.34
.               518400  IN    NS   a.root-servers.net.
com.            172800  IN    NS   a.gtld-servers.net.
example.com.    172800  IN    NS   a.iana-servers.net.

Validate your work

Troubleshooting

Common mistakes


Practice assignment


Extension challenge


Quiz

Q1. What is an IP address, and what is it primarily used for?

  1. A human-friendly name that the network routes traffic by directly
  2. A password that authenticates a machine to the network
  3. A permanent serial number burned into a device at the factory
  4. A numeric identifier for a network interface that routers use to deliver packets
Show answer

Answer: D. A numeric identifier for a network interface that routers use to deliver packets

An IP address is a numeric location on the network that routers use to forward packets. It is not a permanent device identity — addresses are reassigned, shared behind NAT, and change when a device moves networks.

Q2. A recursive resolver has never seen a name before. Which order does it query the DNS hierarchy?

  1. Root server, then TLD server, then authoritative server
  2. TLD server, then root server, then authoritative server
  3. Authoritative server, then TLD server, then root server
  4. It asks all three at once and takes the fastest reply
Show answer

Answer: A. Root server, then TLD server, then authoritative server

The resolver asks a root server which servers handle the TLD (e.g. .com), then asks a TLD server which servers are authoritative for the domain, then asks an authoritative server for the actual record. Each step returns a referral until the last one returns the answer.

Q3. What is the key difference between an A record and a CNAME record?

  1. An A record is for IPv4 and a CNAME is for IPv6
  2. An A record maps to an IP; a CNAME points to another name
  3. A CNAME maps a name to an IP address; an A record points to another name
  4. They are identical; CNAME is just an older spelling of A
Show answer

Answer: B. An A record maps to an IP; a CNAME points to another name

An A record ends in an actual IPv4 address. A CNAME is an alias that points to a different name, so the resolver must perform a second lookup on that name to eventually reach an address. (AAAA is the record type for IPv6 addresses.)

Q4. Which of these addresses is a private address that cannot be reached from the public internet?

  1. 93.184.216.34
  2. 8.8.8.8
  3. 192.168.1.10
  4. 1.1.1.1
Show answer

Answer: C. 192.168.1.10

192.168.0.0/16 is one of the RFC 1918 private ranges (along with 10.0.0.0/8 and 172.16.0.0/12), usable only inside a local network. The other three are public, globally routable addresses.

Q5. What does the TTL on a DNS record control?

  1. How many routers a packet may cross before being discarded
  2. How many times the record may be queried per second
  3. The maximum size in bytes of the DNS response
  4. How long a resolver may serve the answer from cache
Show answer

Answer: D. How long a resolver may serve the answer from cache

A DNS record's TTL (time to live) is how many seconds a resolver may cache and reuse the answer before it must re-query. This is why the second lookup of a name is fast, and why a record change can take time to take effect everywhere.

Q6. Why was IPv6 created?

  1. IPv4's 32-bit address space was running out
  2. IPv4 could not represent domain names, only numbers
  3. IPv6 replaced DNS with a simpler naming scheme
  4. IPv4 was too slow to route packets quickly enough
Show answer

Answer: A. IPv4's 32-bit address space was running out

IPv4 has 32-bit addresses — about 4.3 billion — which the growth of the internet exhausted (the central pool ran out in 2011). IPv6 uses 128-bit addresses, an effectively unlimited space, and now runs alongside IPv4.

Q7. How does a router decide where to send a packet?

  1. It knows the complete path to every machine on the internet in advance
  2. It reads the destination, picks the best next hop, and forwards
  3. It asks a central internet switchboard for directions
  4. It sends the packet to every neighbor and lets them sort it out
Show answer

Answer: B. It reads the destination, picks the best next hop, and forwards

Each router makes one local decision: it reads the destination IP, looks up the best next hop in its routing table, and forwards the packet one step closer. No router holds a map of the whole internet — a workable path emerges from many local decisions.

Q8. A service "can't be reached." You run `dig +short A the-host` and get a correct, expected IP address. What does this tell you?

  1. The problem is definitely inside the application code
  2. The DNS record is wrong and must be fixed first
  3. DNS works, so suspect routing, a firewall, or the service itself
  4. Nothing useful; the command cannot help diagnose connection issues
Show answer

Answer: C. DNS works, so suspect routing, a firewall, or the service itself

A correct resolution rules out DNS as the cause. The next step is to test reachability with ping and traceroute to see whether packets get to the destination and where they stop. Separating "wrong address" from "can't reach the address" is the core networking-debugging habit.

Glossary

IP address
A numeric identifier for a network interface that routers use to deliver packets; a machine's location on the network, not a permanent name for a device.
IPv4
The original internet addressing scheme using 32-bit addresses (about 4.3 billion), written as four numbers 0–255 separated by dots, such as 93.184.216.34.
IPv6
The newer addressing scheme using 128-bit addresses, written as eight groups of hexadecimal digits, created because the IPv4 space was exhausted.
subnet
A contiguous block of addresses that share a leading prefix and are treated as one local network.
CIDR
Classless Inter-Domain Routing notation, which writes an address block as an address plus a slash and a number of fixed leading bits, such as 192.168.1.0/24 (256 addresses).
private IP
An address in a reserved range (10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16) that works only inside a local network and is never routed on the public internet.
loopback
The special address 127.0.0.1, which always means "this very machine"; part of the 127.0.0.0/8 range.
DNS
The Domain Name System, a distributed, hierarchical directory that maps human-friendly names to records such as IP addresses.
resolver
A recursive resolver is a server that performs the full DNS lookup on your behalf — walking root, TLD, and authoritative servers — and returns and caches the final answer.
A record
A DNS record that maps a name to an IPv4 address; the AAAA record is its IPv6 equivalent.
CNAME
A DNS record that aliases one name to another name, which the resolver must then look up in turn, rather than pointing directly to an address.
MX record
A DNS mail-exchange record specifying which server receives email for a domain, with a priority number.
TTL
Time to live: on a DNS record, how many seconds a resolver may cache the answer; on an IP packet, the hop limit that traceroute exploits.
router
A machine that forwards packets between networks, reading each packet's destination address and sending it to the best next hop from its routing table.
BGP
The Border Gateway Protocol, by which autonomous systems advertise to their neighbors which address blocks they can reach, stitching independent networks into one internet.
autonomous system
A large network under a single administrative control (an ISP, university, or cloud provider), identified by an AS number and exchanging routes with others via BGP.
traceroute
A tool that reveals the routers along the path to a host by sending packets with increasing hop limits so each router in turn reports back.

Sources and further reading


Kept in this browser, no account needed. Your progress page turns the whole record into one link you can bookmark or open on another device.