IPv4 Addressing (Classes, Subnet Masks)
IPv4 addressing uses 32-bit addresses written as four decimal numbers from 0 to 255 separated by dots, such as 192.168.1.1. Addresses were historically grouped into classes A, B and C, and a subnet mask such as 255.255.255.0 marks which bits are the network portion and which identify the host.
IPv4 addresses are 32-bit numbers, written as four decimal numbers (each 0-255) separated by dots, like 192.168.1.1. Understanding how these addresses are structured, into classes historically, and into network/host portions via subnet masks, is foundational to everything else in IP networking.
The historical class system
IPv4 addresses were originally divided into classes based on their first few bits, which fixed how much of the address was network versus host:
- Class A (1.0.0.0 to 126.255.255.255): first 8 bits are the network portion, leaving 24 bits for hosts, enough for 16 million hosts per network. Meant for very large organizations.
- Class B (128.0.0.0 to 191.255.255.255): first 16 bits are network, 16 for hosts, about 65,000 hosts per network. Meant for medium organizations.
- Class C (192.0.0.0 to 223.255.255.255): first 24 bits are network, 8 for hosts, 254 usable hosts per network. Meant for small organizations.
This rigid system wasted enormous numbers of addresses (an organization needing 300 addresses had to take an entire Class B block of 65,000+), which is exactly why CIDR notation eventually replaced strict class-based allocation in practice.
Subnet masks
A subnet mask indicates which bits of an IP address are the network portion versus the host portion, written in the same dotted-decimal format as an IP address itself. A mask of 255.255.255.0 means the first 24 bits (three full octets) are the network portion, leaving the last 8 bits for host addresses, this is the same information a /24 CIDR suffix conveys, just written differently.
A worked example
The address 192.168.1.50 with subnet mask 255.255.255.0: comparing the mask, the first three octets (192.168.1) are the network portion, and the last octet (50) identifies this specific host within that network. Every device sharing 192.168.1.x with this same mask is on the same local subnet and can communicate directly; a device on a different network, like 192.168.2.x, requires a router to reach.
Reserved and special addresses
Within any subnet, some addresses are reserved and can't be assigned to a device: the network address itself (all host bits zero, like 192.168.1.0) identifies the network as a whole, and the broadcast address (all host bits set to one, like 192.168.1.255) is used to send data to every device on that subnet simultaneously. This is exactly why a /24 subnet has 256 total addresses but only 254 usable ones.
Where this matters in real systems
Modern networks configure IP addressing using CIDR notation and subnet masks directly, rather than relying on the old rigid class system, precisely because it allows right-sized address allocations instead of wasting huge blocks. Private IP ranges (like 192.168.x.x, 10.x.x.x, and 172.16.x.x to 172.31.x.x) are reserved specifically for use inside private networks and are never routed on the public internet, which is exactly why NAT is needed to translate them to a public address at the network boundary.
What interviewers actually ask about IPv4 addressing
- "What does a subnet mask actually do?" It indicates which bits of an IP address represent the network portion versus the host portion, determining which devices are on the same local network.
- "Why is the class-based addressing system considered outdated?" It forces organizations into fixed, rigid address block sizes, wasting enormous numbers of addresses for organizations that need a size in between the class boundaries.
- "Why does a /24 network have 254 usable addresses instead of 256?" The network address (all host bits zero) and the broadcast address (all host bits one) are reserved and can't be assigned to individual devices, leaving 254 out of the 256 total addresses usable.
- "Give an example of a private IP address range." 192.168.x.x, 10.x.x.x, and 172.16.x.x through 172.31.x.x are all reserved private ranges, never routed directly on the public internet.
Key takeaways
- IPv4's original class system (A, B, C) rigidly fixed the network/host split based on an address's first bits, wasting many addresses in practice.
- A subnet mask specifies which bits of an address are the network portion versus the host portion.
- Every subnet reserves a network address and a broadcast address, reducing usable host addresses by 2.
- Private IP ranges are reserved for internal network use and require NAT to communicate with the public internet.
Browse all Computer Networks topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What does a subnet mask actually do?
It indicates which bits of an IP address represent the network portion versus the host portion, determining which devices are on the same local network.
Why is the class-based addressing system considered outdated?
It forces organizations into fixed, rigid address block sizes, wasting enormous numbers of addresses for organizations that need a size in between the class boundaries.
Why does a /24 network have 254 usable addresses instead of 256?
The network address (all host bits zero) and the broadcast address (all host bits one) are reserved and can't be assigned to individual devices, leaving 254 out of the 256 total addresses usable.
Give an example of a private IP address range.
192.168.x.x, 10.x.x.x, and 172.16.x.x through 172.31.x.x are all reserved private ranges, never routed directly on the public internet.