Open In App
Related Articles

Role of Subnet Mask

Improve Article
Save Article
Like Article

Suppose we have a Class A network that means we have 16 million hosts in a network. The task we have to do is:

  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 not access the whole network.

For this we need subnetting i.e., dividing a huge network into smaller network. Now every department will have their own network .

In case of addressing without subnetting, the process of reaching an address is done by 3 steps –

  1. Identification of the network
  2. Identification of the host
  3. 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.

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.

A packet is received which has destination address - . Then how the router will identify that which subnet it belongs to . It’ll be done using Subnet Mask.

A subnet mask is a 32-bit number which is used to identify the subnet of an IP address. The subnet mask is combination of 1’s and 0’s. 1’s represents network and subnet ID while 0’s represents the host ID. For this case, subnet mask is,


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

&&  11001000.00000001.00000010.00010100

The address belongs to,


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 :
If the network id doesn’t matches with any then the packet will be sent to default entry. Default entry has network id as

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.

Level Up Your GATE Prep!
Embark on a transformative journey towards GATE success by choosing Data Science & AI as your second paper choice with our specialized course. If you find yourself lost in the vast landscape of the GATE syllabus, our program is the compass you need.

Last Updated : 26 May, 2020
Like Article
Save Article
Similar Reads