Subnetting allows for creating multiple logical networks from a single address block. Since we use a router to connect these networks together, each interface on a router must have a unique network ID. Every node on that link is on the same network.
We create the subnets by using one or more of the host bits as network bits. This is done by extending the mask to borrow some of the bits from the host portion of the address to create additional network bits. The more host bits used, the more subnets that can be defined. For each bit borrowed, we double the number of subnetworks available. For example, if we borrow 1 bit, we can define 2 subnets. If we borrow 2 bits, we can have 4 subnets. However, with each bit we borrow, fewer host addresses are available per subnet.
RouterA in the figure has two interfaces to interconnect two networks. Given an address block of 192.168.1.0 /24, we will create two subnets. We borrow one bit from the host portion by using a subnet mask of 255.255.255.128, instead of the original 255.255.255.0 mask. The most significant bit in the last octet is used to distinguish between the two subnets. For one of the subnets, this bit is a “0” and for the other subnet this bit is a “1”.
Formula for calculating subnets
Use this formula to calculate the number of subnets:
2^n where n = the number of bits borrowed
In this example, the calculation looks like this:
2^1 = 2 subnets
The number of hosts
To calculate the number of hosts per network, we use the formula of 2^n – 2 where n = the number of bits left for hosts.
Applying this formula, (2^7 – 2 = 126) shows that each of these subnets can have 126 hosts.
For each subnet, examine the last octet in binary. The values in these octets for the two networks are:
Subnet 1: 00000000 = 0
Subnet 2: 10000000 = 128
See the figure for the addressing scheme for these networks.
If you want you can check this video: