Role of Subnet Mask (original) (raw)

Last Updated : 2 Jan, 2026

A subnet mask is a 32-bit number used with an IP address to divide it into two parts:

In a subnet mask:

The subnet mask helps a device determine whether another device is on the same local network or on a different network, which in turn decides whether communication is direct or must go through a router.

**For example:

Role-of-Subnet-Mask

Role of Subnet Mask

Subnet masks help divide a large network into smaller logical networks called subnets, which improves network efficiency, security, and performance by reducing broadcast traffic and enabling better network management.

Function of Subnet Mask

Why Use a Subnet Mask?

Consider a Class A network, which can support approximately 16 million hosts. Managing such a large network as a single unit is impractical and introduces several challenges:

**Solution: Subnetting

Subnetting addresses these issues by dividing a large network into smaller, manageable sub-networks called subnets using a subnet mask. Each department can be assigned its own subnet, which:

In a network without subnetting, identifying a device involves three steps:

  1. Identification of the network
  2. Identification of the host
  3. Identification of the process

When subnetting is applied, address identification becomes more structured and involves four steps:

  1. Identification of the network
  2. Identification of the subnet
  3. Identification of the host
  4. Identification of the process

Suppose we have a Class C network and we want to divide it into 4 subnets. To divide we need to choose 2 bits from the host part.

Subnetting

As the first and last IP addresses are reserved for **network ID and **directed broadcast address in every subnet, we have to reserve 8 IP addresses in this case.

Subnet Mask

Representation of Subnet Masks

Class C Network: 200.1.2.0/24 i.e. divided into 4 subnets.

Subnet Matching (Bitwise AND):

IP Address: 200.1.2.20 → 11001000.00000001.00000010.00010100
Subnet Mask: 255.255.255.192 → 11111111.11111111.11111111.11000000
Result: 200.1.2.0 → 11001000.00000001.00000010.00000000

So, IP 200.1.2.20 belongs to subnet 200.1.2.0/26.

**Routing Table and Subnet Matching

If the network id doesn’t matches with any of the subnet mask then the packet will be sent to **default entry.

Default entry has network id as 0.0.0.0.

Routing Table

In some cases the network id may match with two entries in the routing table, so here the interface having the longest subnet mask (more 1’s) is selected.

Network Classes

The Internet Assigned Numbers Authority (IANA), through InterNIC, manages the allocation of IP addresses.
To simplify addressing, IP addresses are divided into five classes (A–E):

Each class has a default subnet mask, and the first octet (first 8 bits) determines the class.

classful_aaddress

Range of Classes

Read more about classful IP addressing.

**Advantages of Subnetting

**Disadvantages of Subnetting