Subnetting and Subnet Mask Explained with Examples.


The computer network subnetting divides a bigger IP address space into smaller independent address spaces. The same group of connected computers can work as two or more network-independent networks using subnetting. Each group has a separate network id. A subnet mask is a value for getting a network id from the Ip address.

Subnetting Explained With Example

Subnetting creates two or more separate broadcast networks, which reduces network load and provides more security to the network users.

Subnetting example:

For example, if a LAN connects to the internet using a router. The computers on LAN are of C  class of IP addresses. The LAN can have a maximum of 254 hosts with the same Network Id if a LAN computer has an IP address 192.168.1.*. 

The network id is 192.168.1. The subnet mask is 24 bits, with a value of 192.168.1, or 192.168.1.1/24. The total number of network ids possible is 0xFFFFFF in the case of the C class IP address, which is a considerable amount. Subnetting gives an opportunity of dividing the broad range into smaller ones. 

In our example, the subnet mask is 192.168.1.1/24. This means that when the router needs to send an IP packet to any computer on the LAN, the value of the network address in the destination IP is compared against 192.168.1. If it matches, the packet is sent to the LAN else not.

We can create two (or more) LANs with different network masks with the subnetting. One LAN may have a subnet mask 192.168.1.1*/24, and the other LAN have 192.168.2.*/24

Subnetting Advantages:

Based on subnetting, we can divide the communication computers into groups. The division brings many advantages for the network and LAN users.

Logical separation: There can be multiple (one HR, the other is operations) departments in the company. Each has its servers and other things on the LAN machines. If there is no subnetting, each can access any computer over LAN. With subnetting, only the computers in a subnet address can be accessed.  Separation brings more security to department-specific data. 

Reduces Broadcast packets: After subnetting, a packet is sent to the computers, and that network id matches the subnet. For example, if there are six computers over LAN with to subnet. Each subnet has three computers with a subnet mask of 192.168.1.1/24 and 192.168.2.1/24, respectively. When an incoming packet comes into the LAN, the router broadcasts the packet to only three machines because the network packet can only belong to a subnet. If there is no subnetting, all six devices get the broadcast.

What is the subnet mask – explained?

Till now, we have explained what subnetting is. In simple terms, subnetting means dividing an IP address into the host and network ID. But how a computer knows what bits are for network ID and what are for Host Id? The answer is the subnet mask. A subnet mask is of the same length as the IP address. E.g. for IPV4, the subnet mask length is 32 bits.

How to get the network Id and Host Id from Subnet Mask?

A subnet mask is applied to an IP address. The output is the network id. Subnet apply means the IP address bits are done bitwise end with the subnet mask.

subnet mask explained

Default subnet mask for IP address classes:

Following is the default subnet mask for all types of IP address classes.

IP address class Subnet Mask (byte1.byte2.bye3.byte4)
A255.0.0.0
B255.255.0.0.
C255.255.255.0