IPv4 Subnetting: Subnet Mask, CIDR and How to Calculate Subnets
Learn IPv4 subnetting: address classes, subnet masks, CIDR notation, and how to find the network address, broadcast address and usable hosts per subnet.
An IPv4 address has 32 bits written as four decimal numbers, for example 192.168.10.37. The subnet mask marks which bits are the network part (ones) and which are the host part (zeros). In CIDR notation the mask is written as a prefix length, so /24 means 24 network bits, the same as 255.255.255.0. Classful ranges are Class A 1 to 126 (default /8), Class B 128 to 191 (default /16) and Class C 192 to 223 (default /24).
Subnetting borrows bits from the host part to create more subnets. If you borrow s bits you get 2^s subnets, and with h host bits left each subnet has 2^h addresses, of which 2^h - 2 are usable, because the first address is the network address and the last is the broadcast address. The block size is 256 minus the interesting octet of the mask. For example the mask 255.255.255.192 (/26) has a block size of 64, so the subnets start at .0, .64, .128 and .192.
To find the network address, AND the IP address with the mask. To find the broadcast address, set all host bits to one. The usable range is everything between them. For VLSM (variable length subnet masking), allocate the largest subnet first, then the smaller ones, and give each subnet the smallest mask that fits its hosts. Private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
Key points
- Mask ones = network bits, zeros = host bits.
- Borrowing s bits gives 2^s subnets.
- Usable hosts per subnet = 2^h - 2.
- Network address = IP AND mask. Broadcast = host bits all one.
- Private ranges: 10/8, 172.16/12, 192.168/16.
Worked example
Find the subnet details for 192.168.10.37/26. The mask is 255.255.255.192 and the block size is 64. The address 37 falls in the block starting at 0. Network address 192.168.10.0, broadcast address 192.168.10.63, usable range 192.168.10.1 to 192.168.10.62. Host bits = 32 - 26 = 6, so usable hosts = 2^6 - 2 = 62.
Common questions
Why do we subtract 2 from the number of hosts?
One address is the network address and one is the broadcast address, and neither can be given to a host.
What does /26 mean?
The first 26 bits are the network part, which is the mask 255.255.255.192.
Related topics
BASMAGLY is an independent student project, not an official Delta University site. Check lectures and your instructor for the final word.