Before two computers can exchange data, they need a way to find each other. The physical cables connecting your router to your ISP are just copper and glass: they don't know what a "webpage" is. They just move bits.
The Internet Protocol (IP) sits on top of this physical layer and provides a universal addressing scheme. An IP address is simply a number assigned to a network interface. It is the fundamental coordinate system of the Internet.
An IPv4 address (like 192.168.1.5) is a 32-bit number. That means there are exactly 232 (about 4.3 billion) possible IPv4 addresses. In the 1980s, this seemed inexhaustible. Today, we have far more devices than addresses, leading to complex workarounds like NAT (which we will cover in Lesson 3).
IPv6 solves this by using 128-bit numbers. 2128 is roughly 340 undecillion addresses: enough to assign an IP address to every single atom on the surface of the Earth.
A router's job is to look at a packet's destination IP and decide where to forward it. If core internet routers had to memorize the exact location of all 4 billion IPv4 addresses individually, they would instantly crash from memory exhaustion.
Instead, IPs are grouped into Subnets (sub-networks). An IP address is split into two logical parts: the Network Prefix (which identifies the neighborhood) and the Host ID (which identifies the specific computer in that neighborhood). Routers only need to memorize the paths to the neighborhoods, not every house inside them.
We dictate where this split happens using CIDR notation (Classless Inter-Domain Routing). A slash followed by a number (like /24) tells the network exactly how many bits from the left belong to the Network Prefix.
Slide the mask to see how a /24 differs from a /16. The red bits identify the network routing path. The green bits are available to assign to computers.
When you lease a VPC (Virtual Private Cloud) in AWS, you might define it as a 10.0.0.0/16. That gives you 65,536 addresses. You can then carve that up into smaller subnets like 10.0.1.0/24 (256 addresses) for your databases, and 10.0.2.0/24 for your web servers.
But an IP address only gets a packet to a machine. What if that machine is running a web server, a database, and a multiplayer game all at the same time? How does the OS know which program should receive the packet?