Classful Addressing (Historical)
| Class | First octet | Network bits | Hosts per network | Default mask |
|---|---|---|---|---|
| A | 1-126 | 8 | 16,777,214 | 255.0.0.0 |
| B | 128-191 | 16 | 65,534 | 255.255.0.0 |
| C | 192-223 | 24 | 254 | 255.255.255.0 |
| D | 224-239 | Multicast | — | — |
| E | 240-255 | Reserved | — | — |
The classful system was wasteful. A company needing 300 IPs would get a Class B (65,534 IPs) wasting thousands of addresses. This led to CIDR.
CIDR (Classless Inter-Domain Routing)
CIDR notation: IP/prefix_length — e.g., 192.168.1.0/24
| Notation | Mask | Total IPs | Usable hosts |
|---|---|---|---|
/24 | 255.255.255.0 | 256 | 254 |
/25 | 255.255.255.128 | 128 | 126 |
/26 | 255.255.255.192 | 64 | 62 |
/30 | 255.255.255.252 | 4 | 2 (point-to-point link) |
Formula: usable hosts = 2{(32−prefix)}−2 (subtract network and broadcast addresses).
Subnetting
Subnetting splits a network into smaller subnets:
- Reduces broadcast traffic — each subnet is its own broadcast domain
- Improves security — isolates network segments
- Efficient allocation — match subnet size to actual need
Example
You have 192.168.1.0/24. You want 4 subnets. Borrow 2 bits from host portion → /26 → 4 subnets, 62 usable hosts each.
| Subnet | Network | Broadcast | Usable range |
|---|---|---|---|
| 1 | 192.168.1.0 | 192.168.1.63 | 1-62 |
| 2 | 192.168.1.64 | 192.168.1.127 | 65-126 |
| 3 | 192.168.1.128 | 192.168.1.191 | 129-190 |
| 4 | 192.168.1.192 | 192.168.1.255 | 193-254 |
Q: Why is CIDR better than the classful system?
A: The classful system was wasteful — Class B gave 65,534 addresses even if 500 were needed. CIDR allows variable-length prefixes (e.g., /23 for 510 hosts), allocating exactly what’s needed.
Q: What is 127.0.0.1 used for?
A: The loopback address — tests the local TCP/IP stack without sending data on the physical network. Any traffic to 127.x.x.x stays on the local machine.
Q: In a /24 network, how many usable hosts are there?
A: 256 total addresses, minus the network address (all host bits 0) and broadcast address (all host bits 1) = 254 usable hosts.
Q: What is VLSM (Variable Length Subnet Mask)?
A: Using different subnet masks within the same network. Instead of all subnets being /26, you can have a mix of /26, /27, /30 depending on need. This minimizes wasted addresses.
Premium Content
Unlock IP Classes, Subnetting & CIDR and all premium lessons with a subscription.
From ₹199.99/year — See plans