Part 2 · 2 chapters · ~12 min

IP and Routing

IPv4 and IPv6 addresses, subnets and CIDR, private ranges, the IP header and TTL, routing tables and longest-prefix match, ICMP and traceroute, autonomous systems, BGP and its failures, internet exchanges, anycast, and fragmentation and path MTU discovery.

4

Addresses, subnets and routes

code
CIDR in one example
10.20.0.0/16    → 10.20.0.0 - 10.20.255.255   (65,536 addresses)     a VPC
10.20.4.0/24    → 10.20.4.0 - 10.20.4.255     (256 addresses)        a subnet in it
private ranges: 10.0.0.0/8 · 172.16.0.0/12 · 192.168.0.0/16  (not routed on the internet)
IPv6: 2001:db8:abcd::/48 → enough /64 subnets for a whole company; no NAT needed

ip route            # Linux routing table     traceroute -n api.bank.example     # each hop via TTL expiry (ICMP)
mtr api.bank.example                         # traceroute + loss and latency per hop, continuously
HOW A PACKET CROSSES THE INTERNET
longest-prefix matches at every router, and BGP deciding the paths between networks
your laptop192.168.1.20home routerNATISP (AS 37148)routersinternet exchangeIXPN LagosCDN (AS 13335)edge in Lagosorigincloud region
swipe the figure sideways, or tap expand for full screen
1/5
the default route
Your laptop knows its own subnet (192.168.1.0/24) and sends everything else to the default gateway, the home router.
same subnet: direct; else: default gatewaynetstat -rn / ip route
5

Anycast and path MTU

Anycast: the same IP prefix is announced from many locations; BGP delivers each user to the nearest one. CDNs and public DNS resolvers (1.1.1.1, 8.8.8.8) use it, which is why a single address can be "close" to everyone.

Fragmentation and path MTU: if a packet is larger than a link's MTU, IPv4 can fragment it (slow, fragile) unless "don't fragment" is set, in which case routers return ICMP "fragmentation needed" and the sender lowers its packet size (path MTU discovery). Firewalls that block that ICMP cause connections that hang on large responses: the classic MTU black hole (Backend Debugging part 5).