Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

IP Classes, Subnetting & CIDR
CN

IP Classes, Subnetting & CIDR

How to divide a network: From the rigid class-based system to flexible CIDR and Subnet masks.

Classful Addressing (Historical)

ClassFirst octetNetwork bitsHosts per networkDefault mask
A1-126816,777,214255.0.0.0
B128-1911665,534255.255.0.0
C192-22324254255.255.255.0
D224-239Multicast
E240-255Reserved

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

NotationMaskTotal IPsUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/30255.255.255.25242 (point-to-point link)

Formula: usable hosts = 2{(32prefix)}22^\{(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.

SubnetNetworkBroadcastUsable range
1192.168.1.0192.168.1.631-62
2192.168.1.64192.168.1.12765-126
3192.168.1.128192.168.1.191129-190
4192.168.1.192192.168.1.255193-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.

My Private Notes

Notes are auto-saved locally to this device.