IP and Routing

The internet layer performs a small miracle billions of times a second: it gets a packet from any machine to any other machine on Earth, across networks owned by thousands of independent organizations, with no central controller and no guarantee it'll arrive. Understanding IP — addresses, packets, routing, and why it's deliberately unreliable — is understanding the foundation everything else is built on.

The last post placed IP at the internet layer: host-to-host delivery across networks. This post opens it up — IP addresses, how packets are routed hop by hop, the crucial fact that IP is best-effort (unreliable by design), and the address-translation (NAT) that shapes real networks. IP is the thin waist of the internet: everything above (TCP, HTTP) relies on it, and understanding its guarantees — and non-guarantees — explains a lot of higher-layer behavior.

IP addresses: naming every host

An IP address uniquely identifies a host on a network so packets can be delivered to it. Two versions coexist:

Addresses are structured, not random: an address has a network portion and a host portion, and the split is expressed with CIDR notation like 192.0.2.0/24 — the /24 means the first 24 bits are the network, leaving the rest for hosts within it. This structure is what makes routing scalable: routers make decisions based on network prefixes (whole ranges) rather than individual addresses, so they don’t need a route for every host on Earth — just for network blocks. Some ranges are special: private address ranges (like 10.0.0.0/8, 192.168.0.0/16) are reserved for internal networks and aren’t routable on the public internet, which is central to how NAT works.

Packets: the unit of delivery

IP moves data in packets — discrete chunks, each with an IP header carrying the source and destination addresses (plus other fields) followed by the payload (a TCP segment or UDP datagram from the layer above). Key properties of packet-based delivery:

Because packets are independent and can take different paths, the higher layer (TCP) is what reassembles them in order and detects losses — IP itself just hands each packet toward its destination and hopes.

Routing: how a packet crosses the world

Routing is how a packet gets from source to destination across many networks, and the striking thing is that it’s decentralized — no single system knows the whole path. It works hop by hop:

Your host → home router → ISP router → ... → backbone routers → ... → destination network → server
   each router looks at the destination IP, consults its routing table,
   and forwards the packet to the NEXT hop closer to the destination

This decentralized, hop-by-hop, dynamically-learned design is why the internet is robust (no single point of control to fail) and why network paths are variable — a packet’s journey is assembled on the fly by independent routers, not dictated centrally.

IP is best-effort (unreliable by design)

The single most important property to internalize: IP is best-effort — it does not guarantee delivery, order, or integrity. A packet may be:

And IP does nothing to fix these — it just tries its best to forward each packet and moves on. This sounds like a flaw but is a deliberate design choice: keeping IP simple and stateless (“dumb network, smart endpoints”) is what makes it scalable and robust. The intelligence — reliability, ordering, retransmission — is pushed to the endpoints, specifically to TCP at the transport layer (the next post). This is the foundational division of labor of the internet: IP provides best-effort host-to-host delivery, and TCP builds reliability on top of it at the edges. Nearly everything about TCP exists precisely because IP guarantees nothing — understanding IP’s unreliability is understanding why TCP does what it does.

NAT: the address-sharing workaround

One more piece shapes real networks: NAT (Network Address Translation). Because IPv4 addresses ran out, most devices don’t have their own public address — instead, many devices on a private network (using those private ranges) share a single public IP, with a NAT device (your router) translating between them:

Private network (many devices, private IPs)  ──NAT──▶  one public IP  ──▶  internet
  192.168.1.5 : port  ──┐
  192.168.1.6 : port  ──┼──▶  203.0.113.10 : (mapped ports)  ──▶  the internet
  192.168.1.7 : port  ──┘     (NAT tracks which internal host each connection belongs to)

NAT lets many devices share one public address by rewriting addresses and ports on outgoing packets and reversing it for the replies, tracking the mapping. It’s why your laptop and phone at home both reach the internet through one address, and it has real consequences backend engineers meet: inbound connections to a device behind NAT don’t work without special handling (port forwarding), and the client IP a server sees is often the NAT’s address, not the true origin — which matters for logging and geolocation. NAT is a pragmatic workaround for IPv4 scarcity that’s now deeply woven into how the internet actually operates.

Key takeaways

Further reading

Sources & References

IP routing and BGP