How the Internet Works: TCP/IP and the OSI Model

Understand layers, IP addressing, subnets, routing, and the difference between TCP and UDP well enough to reason about any connection problem.

Beginner · about 10 hours · difficulty 2/5

Learn first: Linux Command Line and Packages

Networking knowledge separates engineers who guess from those who diagnose. You do not need to be a network engineer, but you must be able to follow a packet from a client to your service.

Layers as a mental model

The OSI model (7 layers) and the simpler TCP/IP model (link, internet, transport, application) are ways to locate a problem. "Can I resolve the name?" (application/DNS), "Can I reach the IP?" (internet), "Is the port open?" (transport), "Is the app answering correctly?" (application).

Addressing and routing

  • IPv4 addresses and CIDR notation: 10.0.0.0/16 holds 65,536 addresses; /24 holds 256. You will size VPCs and subnets with this.
  • Private ranges (10/8, 172.16/12, 192.168/16) and NAT to reach the internet.
  • Default gateway, route tables, and IPv6 basics.
  • ARP maps IPs to MAC addresses on a local network.

Transport

  • TCP: connection-oriented, three-way handshake, ordered and retransmitted. Most web traffic.
  • UDP: connectionless and lightweight: DNS, video, QUIC (HTTP/3).
  • Ports identify services; ephemeral ports are used by clients.

Tools

ip addr, ip route, ping, traceroute/mtr, ss -tulpn, nc -zv host port, curl -v, and tcpdump when you need to see raw packets.

Good enough to move on: you can split a /16 into subnets, explain the TCP handshake, and systematically answer "why can't service A reach service B?"

Key concepts

  • OSI and TCP/IP models
  • IPv4, CIDR and subnetting
  • Private ranges and NAT
  • Routing and gateways
  • TCP vs UDP
  • Ports and sockets
  • IPv6 basics
  • ping, mtr, ss, nc, tcpdump

Mini project

Design the address plan for a VPC with public, private and database subnets across 3 availability zones on paper, then verify your math with ipcalc and document it as a table.

Check yourself

nc -zv to a port returns 'connection refused' on one host and times out on another. What does each tell you?

Free resources