How to Subnet IP
The primary characteristic of any OSI Layer 3 address such as an IP address is that it must be routable. To be routable the address must be able to be segmented into two different sections - the network and host portion.
This segmentation is achieved by classful network boundaries (listed below). But when the classful boundary does not supply sufficient networks a subnet is required to further divide that segment.
A subnet is a logical segmentation of a classful network. The classful networks include;
Class A - 8 bit network boundary
Class B - 16 bit network boundary
Class C - 24 bit network boundary
Class D - Not applicable
Class E - Not applicable
In other words, in order to subnet a Class A IP address a mask greater than 8 bits would be required. For class B networks the mask would need to be greater than 16 bits and class C requires more than 24 bits for the network mask.
Class A - NNNNNNNN.hhhhhhhh.hhhhhhhh.hhhhhhhh
{--> any mask greater than 8 bits is a subnet }
Class B - NNNNNNNN.NNNNNNNN.hhhhhhhh.hhhhhhhh
{--> any mask greater than 16 bits is a subnet }
Class C - NNNNNNNN.NNNNNNNN.NNNNNNNN.hhhhhhhh
{--> any mask greater than 24 bits is a subnet }
Why Create IP Network Subnets?
Classful networks were once important because early routing protocols did not propagate a subnet mask and therefore the network boundaries had to be calculated using the corresponding IP address class. This method had a major limitation in that it did not provide any flexibility for businesses with regards to their IP address scheme.
Here is an example where a classful network is inflexible;
Case study: A business has four offices around the state. Each office has less than ten computers. A single class C network is used thorughout the organization.
Under a classful routing protocol there is no flexibility for the business to use a single Class C IP range (which contains 254 usable host addresses) and segment (or subnet) that range into four smaller chunks (one for each office).
Modern routing protocols all support subnetting (classless routing) which propagates the subnet mask along with the IP address in order to give network administrators the flexibility to segment the range according to their business needs.
In this case, the business can subnet their class C network into 4 networks - each supporting 64 hosts. The network mask in this case would be 255.255.255.192
The last octet - 192 signifies that the first 2 bits of the last octet should be used to subnet the original class C which would otherwise carry a mask of 255.255.255.0
How to Subnet IP
Using the example above, we will subnet a class C ip address range into 4 segments so that our fictional business can apply one segment of its IP address range to each of its four offices.
Original IP Address Range: 192.168.10.0/24
We know that any IP address beginning with 192 is part of the Class C IP address family. Class C addresses have 24 bits masks as the classful boundary.
Class C - NNNNNNNN.NNNNNNNN.NNNNNNNN.hhhhhhhh
{--> any mask greater than 24 bits is a subnet }
Lets apply that mask to our business IP address range
IP address
- 192 . 168 .10 .0
The last octet has no network bits set in the mask and therefor the entire 8 bits are used as host addresses. This gives us 2 ^ 8 = 256 host addresses (note: there are 256 - 2 usable host addresses because address 0 is the network address and address 255 is reserved as a broadcast address).
Our business requirements stated that we had 4 offices with approximately 10 people each. Lets subnet our original network so that we can assign one subnet per office.
We want a total of 4 subnets for use in our offices so we need to reserve sufficient network bits to cater for the additional subnets. 2 ^ 2 = 4 so 2 bits will suffice to give us a total of 4 subnets.
Subnetted Class C - NNNNNNNN.NNNNNNNN.NNNNNNNN.NNhhhhhh
{--> note that we are now using 26 bits }
In order to calculate the new networks and the subnet mask we can turn to binary place values. Lets take a closer look at the binary values of the last octet.
1
1
0 0 0 0 0 0
Remember, we set an additional 2 bits on the last octet in order to subnet the original class C into 4 segments.
Calculating the new subnetted IP networks
There are four possible combinations with our newly set network bits - lets look at their values
0
0
0 0 0 0 0 0 = network 0
0
1
0 0 0 0 0 0 = network 64 (the bit with the place value of 64 is set)
1
0
0 0 0 0 0 0 = network 128 (the bit with the place value of 128 is set)
1
1
0 0 0 0 0 0 = network 192 (64 + 128)
Therefor the subetted networks for our 4 offices are:
192.168.10.0 / 26
192.168.10.64 /26
192.168.10.128 /26
192.168.10.192 /26
Why /26 you ask? If you count the number of N bits that we set in the subnet mask you will count 26
Subnetted Class C - NNNNNNNN.NNNNNNNN.NNNNNNNN.NNhhhhhh
Comparison
Lets compare our original IP network with the subnetted IP network that we used in order to cater for our business requirement of addressing four small offices.
Network Masks:
Original
NNNNNNNN.NNNNNNNN.NNNNNNNN.hhhhhhhh
Subnetted NNNNNNNN.NNNNNNNN.NNNNNNNN.NNhhhhhh
Prefix lengths:
Original
24 bit mask
Subnetted 26 bit mask
Number of networks:
Original
1 network 192.168.10.0 /24
Subnetted 4 networks 192.168.10.0/26
Number of usable hosts
Original
(2 ^ 8) - 2 = 254 usable hosts
Subnetted (2 ^ 6) - 2 = 62 usable hosts per subnet