Sub topic 1
Subnetting IPv4 Networks with CIDR Notation
Prerequisites.
Assume you know what an IP address and a network are, and can convert between binary and decimal values from 0 through 255.
What an IPv4 Address Is
An IPv4 address is a 32-bit identifier assigned to a network interface. It is normally written as four decimal octets separated by periods. Each octet contains 8 bits and ranges from 0 to 255.
For example, 192.168.10.25 contains four octets:
1921681025
The address identifies both a network and a host on that network. The position where those parts divide depends on the subnet mask or CIDR prefix.
Reading Addresses in Binary
Each octet represents the bit weights 128, 64, 32, 16, 8, 4, 2, and 1.
For example, decimal 10 is binary 00001010:
8 + 2 = 10- The other bit positions are zero
Therefore, 192.168.10.25 becomes:
11000000.10101000.00001010.00011001
A common error is treating an octet as an unrestricted decimal number. IPv4 octets are exactly 8 bits, so values above 255 are invalid.
Network Bits and Host Bits
The 32 bits divide into network bits and host bits. Network bits identify the subnet. Host bits identify an interface within that subnet. A mask marks the network-bit positions with 1 and the host-bit positions with 0.
For example, a /24 prefix uses 24 network bits and 8 host bits. In 192.168.10.25/24, the network is 192.168.10.0; the final octet identifies the host.
Why Classful Addressing Was Replaced
Older classful addressing used fixed boundaries:
- Class A:
/8 - Class B:
/16 - Class C:
/24
These choices often allocated far more addresses than an organization needed. Classless Inter-Domain Routing (CIDR) replaced those fixed classes with flexible prefix lengths. This reduced wasted addresses and made route aggregation possible.
CIDR Notation and Prefix Length
CIDR writes an address followed by /N, where N is the number of network bits. Thus, /24 means a mask of 255.255.255.0, while /20 means 255.255.240.0.
The remaining 32 - N bits are host bits. A longer prefix creates a smaller subnet. Always interpret an address together with its prefix; 192.168.10.25/24 and 192.168.10.25/16 belong to different networks.
Exercise
How many network bits and host bits does 10.4.8.0/20 have?
Show answer
It has 20 network bits and 12 host bits.