Addresses and ports at a glance
Key idea
Every machine on a network has an IP address. Data travels in small packets, each labelled with where it's going and where it came from, and routers pass each one a step closer until it arrives.
DNS, the next module, turns a name like example.com into one of these numbers. This module is about what happens with the number.
What an address looks like
There are two versions in use side by side:
- IPv4: four numbers from 0 to 255, like
203.0.113.10. There are only about four billion of them, which isn't enough for everything online. - IPv6: eight groups of hexadecimal, like
2001:db8::10, where::stands for a run of zeros. There are enough for every device many times over.
A server often has both, and a browser uses whichever works.
Public and private addresses
Some IPv4 ranges are reserved for private networks: 10.x.x.x, 172.16.x.x to 172.31.x.x, and 192.168.x.x. Routers on the internet won't carry packets to them, so the same private address can exist in millions of homes and data centres at once.
Your laptop almost certainly has one. Your router has a single public address and shares it: it rewrites outgoing packets to carry its own address, and hands each reply back to the right device. That trick is called NAT.
Try it: find your laptop's address.
ipconfig getifaddr en0
en0 is Wi-Fi on most Macs.
ip -brief address
ipconfig
Look for IPv4 Address.
If it starts with 10., 172.16–172.31 or 192.168., it's private.
How a packet finds its way
A request is cut into packets, and your computer hands each one to your router, which passes it to your provider's router, and so on. No router knows the whole route: each only knows which neighbour is closer to the destination. A trip across the world is often 10 to 20 of these hops.
Packets can arrive out of order, or not at all. TCP, the protocol most web traffic rides on, numbers them, puts them back in order, and resends any that went missing, so your app sees one clean stream. The reply makes the same kind of trip back, to the source address on the packets.
Seeing the hops yourself
traceroute example.com on macOS and Linux, or tracert example.com on Windows, lists each router a packet passes through. Some routers don't answer and show as *; that's normal.
Check yourself