Lesson 35: The Subnet Mask Explained
How does a computer or a router know where the Network ID ends and the Host ID begins within an IP address? It uses the Subnet Mask.
What is a Subnet Mask?
The subnet mask is a 32-bit number used in conjunction with an IP address to determine the Network ID and the Host ID. It acts as a filter or a divider.
Structure of the Subnet Mask
- Network Bits: Bits in the subnet mask set to 1 indicate the corresponding bits in the IP address belong to the Network ID.
- Host Bits: Bits in the subnet mask set to 0 indicate the corresponding bits in the IP address belong to the Host ID.
Example
Consider a standard Class C address: 192.168.10.5
Default Subnet Mask: 255.255.255.0
| Octet | IP Address (Binary) | Subnet Mask (Binary) | Result |
|---|---|---|---|
| 1 | 11000000 (192) | 11111111 (255) | Network |
| 2 | 10101000 (168) | 11111111 (255) | Network |
| 3 | 00001010 (10) | 11111111 (255) | Network |
| 4 | 00000101 (5) | 00000000 (0) | Host |
To find the Network ID, you perform a logical AND operation between the IP address and the subnet mask. In the example above, the Network ID is 192.168.10.0.
Key Concept: The subnet mask is essential because it is the boundary marker. By manipulating the mask, we can perform subnetting.