Open In App

Role of Subnet Mask

Last Updated : 31 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A subnet mask is a 32-bit number that separates an IP address into two parts: the network ID and the host ID. It tells devices which portion of the address belongs to the network and which identifies individual devices. By doing this it helps to determine which devices belong to the same local network and which devices reside on different networks. It supports efficient network organization, better control of data flow and overall improved security and management of the network.

For example:

Role-of-Subnet-Mask
Role of Subnet Mask

Subnet masks help divide a large network into smaller sub-networks (subnets), improving network efficiency, security, and performance.

Function of Subnet Mask

Why Use a Subnet Mask?

Suppose we have a Class A network which means we have 16 million hosts in a network. Managing such a large network becomes challenging due to:

  1. Maintenance of such a huge network.
  2. Security for the network – For example, we have 4 departments in a company, and all of the 4 departments need access to the whole network.

Solution: Subnetting

Subnetting solves these problems by dividing a large network into smaller, manageable sub-networks (subnets). Each department gets its own subnet, improving security and efficiency.

Without subnetting, identifying a device requires three steps:

  • Identification of the network
  • Identification of the host
  • Identification of the process

In case of addressing with subnetting, the process of reaching an address is done by 4 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

A subnet mask is a 32-bit number made of 1s and 0s. The 1s identify the network, and the 0s represent devices (hosts) in that network. For this case subnet mask is,

11111111.11111111.11111111.11000000
or
255.255.255.192

So in order to get the network which the destination address belongs to we have to bitwise & with subnet mask.

11111111.11111111.11111111.11000000
&& 11001000.00000001.00000010.00010100
-----------------------------------------------------
11001000.00000001.00000010.00000000

The address belongs to,

11001000.00000001.00000010.00000000
or
200.1.2.0

The internal router will forward the packet to the network through an interface . The interface will be identified by the routing table residing in the router.

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.

How Does Subnetting Work

Subnetting divides a large network into smaller sub-networks by modifying the subnet mask. This improves the management of IP addresses, reduces broadcast traffic, and increases network security by isolating different parts of the network. Subnetting also helps optimize the use of IP address space and improves troubleshooting and overall network performance.

For example, subnetting can organize devices into logical groups, such as separating a company's departments into different subnets. This way, traffic within one department does not unnecessarily interfere with others, improving performance and security

Network Classes

The Internet Assigned Numbers Authority (IANA), through InterNIC, oversees the allocation of IP addresses. IP addresses are divided into classes to simplify their use, with Classes A, B, and C being the most commonly used. Classes D and E exist but are not used by end users. Each class has a default subnet mask, and the first octet of the IP address determines its class. The ranges of Class A, B, and C Internet addresses are given below, along with a sample address for each:

Ranges of Classes
Range of Classes

Read more about classful IP addressing.

Advantages of Subnetting

  • Reduces network congestion: Limits broadcast traffic, improving network speed.
  • Efficient IP Usage: Allocates IPs based on need, avoiding wastage.
  • Enhances security by isolating subnets: For example, no other department within an organization should be able to view the code created by the Developer department.
  • Enables Departmental Segmentation: A higher network priority may be needed for some subnets than for others. For instance, a sales department might need to hold video conferences or webcasts.
  • Supports Scalability: Allows networks to grow while remaining organized.

Disadvantages of Subnetting

  • Limited IP Address Space: Dividing networks reduces available IPs per subnet.
  • Additional Hardware: Subnetting reduces the overall number of IP addresses in the network, yet it could necessitate purchasing extra hardware, like a router. Thus it could be very expensive.
  • Complex Setup: Requires expertise to plan and configure subnets.
  • Compatibility Issues: Older devices or systems may struggle with subnetting configurations.

Next Article
Article Tags :

Similar Reads