The whole trip in one story
You type example.com into your browser and press Enter. Before the page appears, roughly this happens:
- DNS: your computer asks a DNS server, âwhat is the IP address of
example.com?â and gets an answer. - Local or not? Your computer compares that address with its own subnet (Lesson 2). It is not local, so the packet must go to the default gateway.
- ARP: to hand the packet to the gateway on the local network, your computer needs the gatewayâs MAC address. ARP finds it.
- NAT: your router swaps your private address for your homeâs public address, and remembers the swap.
- Routing: routers across the internet pass the packet along, hop by hop, toward the destination.
- The server answers on port 443 (Lesson 3), and the reply travels back the same way. Your router undoes the NAT swap and delivers it to your laptop.
The rest of this lesson takes those steps one at a time, and you will see each one on your own machine.
DNS: names to addresses
People remember names; networks use addresses. DNS (Domain Name System) is the internetâs phone book. Your computer asks a DNS resolver, usually your router or your providerâs server, and the resolver finds the answer and remembers it for a while.
DNS is gold for defenders. Almost every program, malware included, looks up a name before it connects anywhere. A list of names a laptop looked up is often the fastest way to spot it talking to somewhere it should not.
Routing: hop by hop
No single machine knows the whole internet. Each router only knows which neighbor is one step closer to the destination. Your packet is passed along a chain of routers: each pass is a hop.
Every packet carries a TTL (time to live), a number that drops by one at each hop. If it reaches zero, the packet is thrown away. That stops lost packets from circling forever, and it is also how traceroute works: it sends packets with TTL 1, 2, 3, and so on, and each router that throws one away reports back.
ARP: from IP address to MAC address
Inside your local network, data is delivered by MAC address (Lesson 1). ARP (Address Resolution Protocol) asks the whole local network: âwho has 192.168.1.1? Tell me your MAC address.â The owner answers, and your computer remembers the pair in its ARP table.
ARP trusts any answer. An attacker on the same network can reply âI am 192.168.1.1â with their own MAC address, and traffic meant for the router goes to them instead. This is called ARP spoofing. A gateway whose MAC address changes for no reason is worth a closer look.
NAT: sharing one public address
Lesson 1 showed that your home has one public address shared by every device. NAT (Network Address Translation) makes that work. When a packet leaves, the router replaces the private source address with the public one and notes which device and port it came from. When the reply arrives, the router reverses the swap.
For defenders, NAT means a websiteâs logs see the routerâs public address, not the device behind it. One public address in a log can be a whole office or a whole cafĂŠ.
Hands-on: follow your own packets
1. Ask DNS
nslookup works the same on macOS, Linux, and Windows:
nslookup example.com
The first lines name the DNS server that answered. The lines after Name: give the addresses for example.com, often both IPv4 and IPv6.
2. Count the hops
# -n shows addresses instead of looking up router names (faster)
traceroute -n example.com# tracepath is installed on most distributions; traceroute may not be
tracepath -n example.com# -d shows addresses instead of looking up router names (faster)
tracert -d example.comThe first hop is your gateway from Lesson 1. Then come your providerâs routers, then the internet. Lines of * * * or âno replyâ are routers that choose not to answer. That is normal. It can take a minute to finish; press Ctrl+C to stop early.
3. Read your ARP table
arp -aip neigharp -aFind your gatewayâs address in the list, and note its MAC address. The other entries are devices your computer talked to recently on the local network.
4. Spot the NAT
Look at your network sheet. Your private address (Lesson 1) and your public address are different, and nothing on your laptop is configured with the public one. Your router is doing NAT.
Add to your network sheet: the DNS server that answered, the addresses of example.com, how many hops it took, and your gatewayâs MAC address.
What to notice
- A single page load uses DNS, a routing decision, ARP, NAT, and many router hops before the first byte of the page arrives.
- DNS lookups reveal where a machine is trying to go, which is why defenders collect them.
- ARP trusts any answer, which makes ARP spoofing possible on a shared local network.
- Behind NAT, one public address can stand for many people. Keep that in mind before blaming âone IPâ.