Open In App
Related Articles

Role of Subnet Mask

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The host or client address and the network or server address are the two parts of the IP address that are present on every computer device. Either a DHCP server or a human, using a static IP address, configures the IP addresses.

What is a Subnet Mask?

Setting all 0s for the host bits and all 1s for the network bits results in a 32-bit value known as a subnet mask. The IP address is divided into the host address and network address in this manner by the subnet mask. “255” is always the address assigned to the broadcast address, while “0” is always the address assigned to the network address. The subnet mask cannot be assigned to the host because it is set aside for a specific purpose.

Function of Subnet Mask

A 32-bit address that distinguishes the network address from the host address makes up the subnet mask. This indicates which part of the IP address belongs in the host section and which part belongs in the network section. The number of hosts that can be on the subnet depends on the values of the subnet mask. This comprises bits that are initialized to 1 for the network and 0 for the host. Routers and switches use it internally to send packets to the destination node along the associated local network connection.

Suppose we have a Class A network which 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 networks. Now every department will have their network. In the case of addressing without subnetting, the process of reaching an address is done by 3 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

Network Classes

The company in charge of overseeing the Internet, InterNIC, assigns IP addresses. There are classes for these IP addresses. Classes A, B, and C are the most prevalent ones among them. Although they exist, end users do not use classes D or E. The default subnet mask varies for each address class. An IP address’s first octet can be used to determine its class. The ranges of Class A, B, and C Internet addresses are listed below, along with a sample address for each:

  • Class A networks have 0-127 as their first octet and utilise 255.0.0.0 as their default subnet mask. 10.52.36.11 is classified as a class A address. 10, its initial octet, falls between 1 and 126, inclusive.
  • Class B networks have 128–191 as their first octet and 255.255.0.0 as their default subnet mask. Address 172.16.52.63 belongs to the class B address set. Its initial octet is 172, spanning from 128 to 191, inclusive.
  • Class C networks have 192-223 as their first octet and utilise 255.255.255.0 as their default subnet mask.

A packet is received which has destination address -200.1.2.20 . 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,

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

If the network id doesn’t matches with any 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.

Advantages of Subnetting

  • It does this by sending out fewer broadcasts, which lowers network load.
  • It assists in getting around restrictions in a local area network (LAN), like the maximum number of permitted hosts.
  • Without needing to access the entire network, it enables users to join to a work network from their residences.
  • It keeps one network safe from another’s infiltration. For instance, no other department within an organisation should be able to view the code created by the Developer department.
  • 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.
  • If the network is tiny, maintenance is easy.

Disadvantages of Subnetting

  • 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.
  • Companies still assign address blocks in relation to classes, therefore it cannot alleviate the inefficiency.

Conclusion

Subnetting improves performance by lowering network traffic and collisions. This gives the IT administrators complete control over data packet monitoring, router device enabling or updating, and network traffic reduction. In order for the routers to match data packets to the intended node and determine the optimal path for data transmission between the sender and recipient interface, the subnet mask addresses are required to distinguish between the host and network address.

Frequently Asked Question on Subnet Mask – FAQs

What is a Subnet Mask?

Setting all 0s for the host bits and all 1s for the network bits results in a 32-bit value known as a subnet mask.

How is a Subnet Mask represented?

The IP address’s 32-bit value is used to identify each octet. For instance, 255.255.255.0 is a typical Class C subnet mask because the last two bytes are all zeros and the first two bytes are all ones (network).

How does subnetting help in network design?

One purpose of a subnet is to reduce traffic by dividing a large network into a collection of linked, smaller networks. In this manner, traffic can move faster over networks by avoiding needless paths. The segmentation of a network address space, or subnetting, increases the effectiveness of address allocation.

Can subnet masks be variable in length?

Yes Subnet mask can be variable in length.

Why is subnetting important for security?

By quarantining infected areas of the network and making it more difficult for intruders to navigate an organization’s network, subnetting enables network managers to lessen hazards to the entire network.



Last Updated : 11 Feb, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads