Subnet Masking Methods: Classful, FLSM, VLSM, CIDR and Supernetting
A subnet mask separates the network part of an IP address from the host part.
Topic: Networking in IT Infrastructure · Explainer
Quick answer: A subnet mask separates the network part of an IP address from the host part. The main methods are classful masking (fixed /8, /16 and /24 masks by address class, now obsolete), fixed-length subnet masking (FLSM, where every subnet is the same size), variable-length subnet masking (VLSM, where each subnet is sized to its needs), and CIDR (classless prefixes such as /22 used on the internet today), which also allows supernetting or route summarisation. Related tools include wildcard masks in Cisco ACLs and special prefixes such as /31 for point-to-point links.
Key takeaways
- A mask of /24 means the first 24 bits identify the network, leaving 8 bits for hosts.
- Usable hosts in an IPv4 subnet = 2^(host bits) minus 2, except /31 and /32.
- VLSM saves addresses by sizing each subnet to its host count.
- CIDR replaced classful addressing in 1993; RFC 4632 is the current reference.
- Summarisation combines contiguous subnets into one route to shrink routing tables.
Table of Contents
- How Does a Subnet Mask Work?
- What Is Classful Masking?
- What Is FLSM?
- What Is VLSM, With an Example?
- What Are CIDR and Supernetting?
- What Are Wildcard Masks, /31 and /32?
- How Do You Check Your Calculations?
- How Does This Work in IPv6?
- References
How Does a Subnet Mask Work?
A device ANDs its IP address with the mask to find its network address, then compares that with a destination's network to decide whether to send directly or via the router.
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
The first address is the network address and the last is the broadcast address, which is why two are subtracted. For basics, see what is subnetting.
What Is Classful Masking?
Early IPv4 assigned masks by the first bits of the address: Class A (1 to 126) used /8, Class B (128 to 191) /16 and Class C (192 to 223) /24. This wasted addresses: an organisation needing 500 hosts got a Class B with 65,534. RFC 950 introduced subnetting inside these classes. Classful addressing is obsolete but still appears in exams and old documentation.
What Is FLSM?
Fixed-length subnet masking divides a network into equal subnets. Splitting 192.168.10.0/24 into four gives four /26 subnets of 62 usable hosts each. It is simple but wasteful when subnets need very different sizes.
What Is VLSM, With an Example?
Variable-length subnet masking assigns different prefix lengths within one block (RFC 1878 tabulates the sizes). Allocate the largest subnets first. Requirements from 192.168.10.0/24: Sales 100 hosts, Engineering 50, Admin 20, and two router links of 2 hosts.
| Subnet | Hosts needed | Prefix | Network | Usable range |
|---|---|---|---|---|
| Sales | 100 | /25 | 192.168.10.0 | .1 to .126 |
| Engineering | 50 | /26 | 192.168.10.128 | .129 to .190 |
| Admin | 20 | /27 | 192.168.10.192 | .193 to .222 |
| Link 1 | 2 | /30 | 192.168.10.224 | .225 to .226 |
| Link 2 | 2 | /30 | 192.168.10.228 | .229 to .230 |
The range 192.168.10.232 to .255 remains free for growth.
What Are CIDR and Supernetting?
Classless Inter-Domain Routing (RFC 4632) allows any prefix length and lets routers advertise one summary route for several contiguous networks. Four /24 networks, 10.1.0.0 to 10.1.3.0, can be summarised as 10.1.0.0/22. This "supernetting" keeps internet and enterprise routing tables smaller. Summaries must cover only addresses you actually route, or traffic may be black-holed.
What Are Wildcard Masks, /31 and /32?
- Wildcard mask: the inverse of a subnet mask, used in Cisco ACLs and OSPF. 0.0.0.255 matches any value in the last octet. Example:
access-list 10 permit 192.168.10.0 0.0.0.255. - /31: two addresses with no network or broadcast address, allowed on point-to-point links by RFC 3021.
- /32: a single host, used for loopbacks and host routes.
How Do You Check Your Calculations?
Python's standard ipaddress module confirms subnet maths:
import ipaddress
net = ipaddress.ip_network("192.168.10.0/24")
for sub in net.subnets(new_prefix=26): # FLSM: four /26
print(sub, sub.netmask, sub.num_addresses - 2, "hosts")
# VLSM check: is an address inside the Engineering subnet?
eng = ipaddress.ip_network("192.168.10.128/26")
print(ipaddress.ip_address("192.168.10.150") in eng) # True
# Summarise contiguous networks (supernetting)
nets = [ipaddress.ip_network(f"10.1.{i}.0/24") for i in range(4)]
print(list(ipaddress.collapse_addresses(nets))) # [IPv4Network('10.1.0.0/22')]
On Linux, ipcalc 192.168.10.128/26 gives the same information.
How Does This Work in IPv6?
IPv6 uses prefix lengths only, with no masks in dotted form and no broadcast addresses. A /64 is the standard size for a LAN subnet; organisations typically receive a /48 or /56 and divide it into /64s. Private IPv4 ranges for practice are listed in RFC 1918. Related: types of computer networks. WebAsha's CCNA training includes subnetting drills.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0