What is a subnet mask, and how is it used in networking?

A subnet mask is a 32-bit address that is used in computer networks to divide an IP address into network and host portions. It plays a crucial role in the implementation of IP subnetting, which is a technique used to partition an IP address space into smaller, more manageable subnetworks. Subnetting allows for efficient utilization of IP addresses and facilitates better organization and management of network resources.

Structure of an IP Address and Subnet Mask:

  • IP Address:
    • An IP address is a 32-bit numerical label assigned to each device participating in a computer network that uses the Internet Protocol for communication.
    • It is typically represented in dotted-decimal format (e.g.,, where each decimal represents 8 bits of the 32-bit IP address.
  • Subnet Mask:
    • The subnet mask is also a 32-bit value, represented in the same dotted-decimal format.
    • It consists of two parts: the network portion (composed of consecutive '1' bits) and the host portion (composed of consecutive '0' bits).

Purpose of Subnetting:

  1. Efficient Address Allocation:
    • Subnetting allows organizations to divide their IP address space into smaller subnetworks, preventing the wastage of addresses.
    • This is especially important when dealing with limited IPv4 addresses.
  2. Improved Network Management:
    • Dividing a network into subnets makes it easier to manage and troubleshoot network issues.
    • Network administrators can apply different policies, configurations, and security measures to each subnet independently.
  3. Reduced Broadcast Domain Size:
    • Subnetting helps in limiting the broadcast domain size. Broadcasts are limited to devices within the same subnet, reducing network congestion.

Subnet Mask and Binary Representation:

  • Binary Representation:
    • In binary form, a subnet mask's '1' bits represent the network portion, and '0' bits represent the host portion.
    • For example, the subnet mask in binary is 11111111.11111111.11111111.00000000.

Calculating Network and Host Addresses:

  • Logical AND Operation:
    • To determine the network address, the logical AND operation is applied to the IP address and the subnet mask.
    • For example:yamlCopy codeIP Address:
      Subnet Mask:

  • Host Address Range:
    • The remaining bits in the IP address represent the host portion, allowing for the calculation of the range of host addresses within that subnet.


  • IP Address:
    • (in binary: 11000000.10101000.00000001.01100100)
  • Subnet Mask:
    • (in binary: 11111111.11111111.11111111.00000000)
  • Network Address (Logical AND Operation):
  • Host Address Range:
    • From to