Back to course

The Subnet Mask Explained

Networking Fundamentals: The 0 to Hero Guide

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

OctetIP Address (Binary)Subnet Mask (Binary)Result
111000000 (192)11111111 (255)Network
210101000 (168)11111111 (255)Network
300001010 (10)11111111 (255)Network
400000101 (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.