IP Addressing & Classes
Scenario
You want to mail a letter, but instead of '123 Main St, New York', you only have 'House 123'. Without the city and street, the post office has no idea where to send it. IP addresses solve this same problem for the internet.
Overview
IP addressing is the system that assigns unique numeric identifiers to devices on a network.
It is essential for devices to locate and communicate with each other across the global internet.
Where used: Networking, System Administration, Web Development
Why learn this
- Understanding IP addressing is fundamental for any backend developer or systems engineer.
- It forms the basis for more advanced networking topics like subnetting and routing.
Mental model
An IP address is a postal address for a computer, with classes acting as different sized zip codes.
Every device on a network needs a unique identifier to send and receive data. An IP address provides this identity, split into a 'network' portion (the city/zip code) and a 'host' portion (the specific house). Historically, 'Classes' determined exactly where the line between network and house was drawn, allocating big chunks of addresses to massive corporations and smaller chunks to local networks.
Explanation
An IP (Internet Protocol) address is a numerical label assigned to every device connected to a computer network. In IPv4, this address is 32 bits long, typically written as four decimal numbers separated by dots (like 192.168.1.5). This simple set of numbers is the fundamental building block of internet communication, allowing data packets to find their way from a server across the world straight to your specific smartphone.
To make routing efficient, an IP address is logically divided into two parts: a Network ID and a Host ID. The Network ID identifies the specific network (like a neighborhood), and the Host ID identifies the exact device on that network (like a house). When a router receives a packet, it first looks only at the Network ID to forward the packet to the correct general area. Only when the packet reaches the destination network does the final router use the Host ID to deliver it to the specific computer.
In the early days of the internet, this division was rigidly structured into 'Classes'. The creators realized that some organizations (like massive universities or corporations) would need millions of host addresses, while others (like a small office) would only need a few hundred. To accommodate this, they defined Class A, B, C, D, and E based on the first few bits of the IP address.
Class A networks used the first 8 bits for the network and 24 bits for the hosts, allowing for over 16 million devices per network—perfect for tech giants but highly wasteful. Class B split it evenly, 16 bits for network and 16 for hosts. Class C used 24 bits for the network and only 8 bits for hosts, allowing just 254 devices. This rigid system, known as Classful Addressing, eventually proved too inflexible and wasteful because an organization needing 300 addresses had to be given a Class B network (wasting 65,000 addresses).
While Classful Addressing has largely been replaced by more flexible systems like CIDR today, understanding it is critical. It forms the historical foundation of how routers were originally designed to read addresses, and the concepts of 'network' versus 'host' portions remain universally true. Private IP ranges (like your home's 192.168.x.x) are still directly derived from this class-based history.
Key points
- Class A (0.0.0.0 to 127.255.255.255): Reserved for massive networks. First octet is the network ID. Supports 16.7 million hosts per network.
- Class B (128.0.0.0 to 191.255.255.255): For medium-to-large networks. First two octets are the network ID. Supports 65,534 hosts per network.
- Class C (192.0.0.0 to 223.255.255.255): For small networks. First three octets are the network ID. Supports 254 hosts per network.
- Class D & E (224.0.0.0 and above): Class D is reserved for multicasting (sending data to multiple receivers at once). Class E is reserved for experimental purposes.
- Private IP Addresses: Specific ranges in Class A (10.x.x.x), Class B (172.16-31.x.x), and Class C (192.168.x.x) are reserved for local networks and cannot be routed on the public internet.
Common mistakes
- Confusing MAC addresses with IP addresses: A MAC address is a permanent physical identifier baked into hardware (like a car's VIN), whereas an IP address is a logical identifier that changes based on the network you connect to (like a license plate or postal address).
- Assuming all 256 addresses in a Class C network are usable: The first address (Host ID all 0s) is reserved as the Network Address, and the last address (Host ID all 1s) is reserved as the Broadcast Address. A /24 network has 256 IPs but only 254 usable hosts.
Glossary
- IP addressing
- The system of giving every single device on a network a unique digital 'home address' so data knows exactly where to go.
- IPv4
- The older, classic version of internet addresses that uses four numbers separated by dots (like 192.168.1.1).
- routing
- The process of finding the best and fastest path through the internet''s maze of wires to send data from its source to its destination.
Recall questions
- What is the difference between the Network ID and the Host ID in an IP address?
- Which IP class is designed to support the largest number of hosts per network?
- Why are the first and last IP addresses in a network range generally unusable for devices?
Questions & answers
Given the IP address 192.168.1.50, what class does this belong to, and is it a public or private address?
It belongs to Class C and is a private IP address.
Approach: The first octet '192' falls in the Class C range (192-223). The specific block 192.168.x.x is designated as a private IP space, meaning it is non-routable on the public internet.
An organization needs a network that can support 1,000 devices. Under strict classful addressing, which class of network must they be assigned, and how many addresses are wasted?
They must be assigned a Class B network. About 64,534 addresses are wasted.
Approach: Class C only supports 254 devices, which is too small. Class B supports 65,534 devices. Assigning a Class B network for 1,000 devices wastes exactly 65,534 - 1,000 = 64,534 addresses, highlighting the inefficiency of classful routing.
Continue learning
Next: Subnetting & CIDR
Next: IPv4 vs IPv6