Subnet Masks
 

A network mask help identifying the network and host.
Class A, B, and C networks have default masks called natural masks
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0


Subneting Guide (Private Networks)
1. Determine the number of hosts in the network
2. Determine the number of hosts per subnet 
3. Determine the address class of the network
4. Determine the appropriate default subnet mask.
5. Determine the appropriate custom subnet mask that provides a number of hosts:
6. Determine the address ranges for each subnet

When subnets are created, the Network ID borrows some bits from the Host ID to define subnets and balance bits are used for host IDs.

If you have a Class C network of 192.168.111.0 .
Its default network mask is 255.255.255.0
You can have 254 hosts in a single subnet.

subnet win

The network id of 192.168.111.1  host is 11001100.00010001.1101111
The 254 Host IDs range from 0000001 to 11111110 means (1-254)

What if you want to create two subnets in this network?
You need to have two unique network IDs to assign to each subnet.
What If we borrow 1 bit from Host ID

if we borrow 1 bit from Host ID, the number of Host IDs reduced,
But 2 subnets created. If we take two bits 4 subnets are created,
as a result, the number of host IDs is further reduced as it has only 6 bits. 

The Network ID becomes 11001100.00010001.1101111.1000000
Now only 7 bits available to Host ID from 000001 to 1111110 means (1-126)
The subnet mask become  255.255.255.128  (128 is 1000000)

Now we have two subnets with IPs ranges
 
Subnet 1 : 192.168.111.1 - 192.168.111.126
Subnet 2: 192.168.111.128 - 192.168.111.254

You can see 
192.168.111.0 and 192.168.111.127  are not used as Host IDs in segment 1.
192.168.111.127 and 192.168.111.255 are not used as Host IDs in segment 2
Because they are used as Network address and Broadcast Address f the sub network.

Network Address (Network ID) defines the subnet of a host. 

Broadcast Address:
An IP Address that allows information to be sent to all machines on a given subnet rather than a specific machine. 

For subnet 1
Network address is 192.168.111.0  
Broadcase address is 192.168.111.127  
Host addresses 92.168.111.1 - 192.168.111.126
Subnet Mask 255.255.255.128 

For subnet 2
Network address is 192.168.111.0 
Broadcast address is 192.168.111.128 
Host addresses 192.168.111.129 - 192.168.111.254
Subnet Mask 255.255.255.128 


 If we want to create 8 subnets in a Class C network. 
How many hosts per subnet can be used?

In a class C 256 addresses available for single subnet.
For 8 subnets we get 32 hosts (256/8)
As first and last addresses not used as Host ID in a subnet,
We can use only 30 Hosts per subnet. (32-2)
To define 8 subnetworks we need to borrow 3 bits form host id, 11100000 (224)
balance 5 bits are Host addresses (00001 - 111110) = 30

So we can create following 
8 sub networks each having 30 hosts with
subnet mask 255.255.255.224  

192.168.111.1 - 192.168.111.30 
192.168.111.32 - 192.168.111.62 
192.168.111.64 - 192.168.111.94 
192.168.111.96 - 192.168.111.126 
192.168.111.128 - 192.168.111.158 
192.168.111.160 - 192.168.111.190 
192.168.111.192 - 192.168.111.222 
192.168.111.224 - 192.168.111.254

Usual problems include
Determine subnet mask for n number of computers per subnet.
Given a subnet mask determine number of hosts
Determine Host ID Ranges for above 
Determine Network segment from a Host id when subnet mask given


In a class C network we can create

2 sub networks each having 126 hosts subnet mask 255.255.255.128
4 sub networks each having 62 hosts subnet mask 255.255.255.192
16 sub networks each having 14 hosts subnet mask 255.255.255.240
32 sub networks each having 6 hosts subnet mask 255.255.255.248
64 sub networks each having 2 hosts subnet mask 255.255.255.252


Advanced Learning
What if it's a Class B network ?
Identify Class - 143.111.23.25
Class B network has default mask 255.255.0.0
The network can have 256 * 256 hosts from 143.111.1.1 - 143.111.255.255
Total address space is 65536 ( Host IDs 65534)
Determine number of hosts per subnet , lets say its 20 hosts 
We can use on multiples of 2 hosts per subnet,
so closest number for 20 hosts is 2x2x2x2x2=32. 
Now divide whole address space from number of hosts per subnet.
66536/32= 2048 mean we can have 2048 subnets with 32 addresses for each.
As we know 1st and last address reserved for network address and broadcast address.
The 1st subnet will be from 143.111.0.1 -143.111.0.30
The 2nd subnet will be from 143.111.1.32-143.111.1.62
........

The last subnet will be from 143.111.254.224-143.111.254.254

The subnet mark need to borrow 11 bits from host ID to represnt 2048 sub networks
So the default Class B mask 255.255.0.0 will change to 255.255.255.224

Class A Networks use the same system. Borrow bits from Host ID to create subnets.

Method
1. Identify address class
2. Identify Network ID
3. Identify Host ID
4. How many subnets are required ?
5. Borrow left most bits from Host ID part to represent number of sub networks.
1 bit for 2, 2 for 4, 3 for 8 , 4 for 16, 5 for 32 etc... 
6. Leave the rest of the bits for host ids.
7. Set borrowed bits to 1 and rest to zero. Its your subnet mask .
8. List host ids per subnet (the first and last address not used )

Online Subnet Mask calculator

Learn Advanced Networking from Professor Messer

(c) Shilpa Sayura Foundation 2006-2017