In this subnetting tutorial we will learn about Subnet Calculation.

After this subnetting tutorial you will have clear idea on How to allocate IPs for each subnet or How to do subnetting or How to design internal network of orgnization?

If you are designing network from scratch, first you will need to find out how will you divide the network. Generally you can divide the network in logical subnet, consider that you are designing network for organization, you can divide network based on departments, i.e.Sales, IT, Marketing, Customer care, Human resources, Accounting, etc. or let's say for college or school we can divide network based on branch or lab wise. for example in engineering college, you can divide branch wise, i.e. Computer Engineering, Information Technology, Electronics & Communication and so on.

Also prepare table with total number of hosts required in each subnet. Any machine connected with network needs at least one unique IP address to communicate within network. you also need to consider that many devices can have multiple ways to connect to network, Laptop can be connected using LAN or through your Wireless network, which means you need to allocate IP per connection.

Once you gather required information, you can start with subnetting or allocation IP address range to subnet.
We will consider a scenario where we need to design network for organization. Required information is mentioned below.

DepartmentHosts
IT275
Accounting127
Sales265
Marketing400
Customer Care38

In this subnetting tutorial we have used VLSM algorithm to calculate subnet.

VLSM algorithm

### Step #2 Find subnet mask for each subnet.

Max Hosts < 2 ^ HB
NB = 32 - HB
SM = NB (times 1) + HB (times 0)
i.e for NB = 23 and HB = 9, SM = 11111111111111111111111000000000 (23 times '1' + 9 times '0')

NW = IP AND SM
BC = IP OR ~SM
For next subnet:
IP = BC + 1

### Step #4 Allocate IP for each subnet.

RANGE = NW + 1 to BC - 1
REPEAT #3 for all subnet.

Detailed Explanation:

Step #1 : Sort subnet based on number of hosts.

Sort subnet in descending order based on number of hosts. We will allocate IP ranges for larger subnet first, then second largest subnet and so on. So that network overlapping can be avoided.

DepartmentHosts
Marketing400
IT275
Sales265
Accounting127
Customer Care38

Step #2 : Find subnet mask for each subnet.

To find subnet mask we will first find network bits (NB) and host bits (HB) required for each subnet.
Subnet mask can be represented as NB and HB. Once we have NB and HB, We will be able to find subnet mask.

Let's find NB and HB :

For hosts bits we have to find closest power of 2, that is larger than required number of hosts.

Host Bits (HB):
For subnet with 400,
2^8 = 256 and 2^9 = 512.
here 256 < 400 < 512.
So HB is 9 for subnet Marketing.
Hence, HB = 9
Network Bits (NB):
We know that subnet mask is 32 bit binary number. as mentioned above NB and HB makes up this 32 bits.
SM = 32
NB + HB = 32
NB = 32 - HB = 23
Hence, NB = 23

Once we have NB and HB it's very easy to get subnet mask.

Write consecutive '1' NB times. here NB is 23
NB = 11111111111111111111111

Now append consecutive '0' HB times with NB. here HB = 9.
SM = 11111111111111111111111000000000

Divide in 4 octets
SM = 11111111.11111111.11111110.00000000

Convert octets to decimal
SM = 255.255.254.0
Hence for Marketing (400 hosts subnet) subnet mask is 255.255.254.0

Repeat the step #2 for each departments.

After Step #2 we will have following details.

Marketing400255.255.254.0
IT275255.255.254.0
Sales265255.255.254.0
Accounting127255.255.255.0
Customer Care38255.255.255.192

If you are designing internal network for organization, you have to use any available private IP range.

Available private IP range
Class A 10.0.0.0 - 10.255.255.255
Class B 172.16.0.0 - 172.31.255.255
Class C 192.168.0.0 - 192.168.255.255
We will be using Class C range. Starting IP Address 192.168.0.0
IP address subnet mask 11000000101010000000000000000000 192.168.0.0 11111111111111111111111000000000 255.255.254.0 BITWISE AND 11000000101010000000000000000000 192.168.0.0
Hence, Network Address for Marketing subnet is 192.168.0.0

Repeat the step #3 for each departments.
While doing further calculation, Starting IP address for Next (IT) subnet is next IP to Broadcast Address of Previous (Marketing) subnet.

After Step #3, We will have following details.

Marketing400255.255.254.0192.168.0.0192.168.1.255
IT275255.255.254.0192.168.2.0192.168.3.255
Sales265255.255.254.0192.168.4.0192.168.5.255
Accounting127255.255.255.0192.168.6.0192.168.6.255
Customer Care38255.255.255.192192.168.7.0192.168.7.63

Step #4 : Allocate IP address for subnet.

IP Allocation: