Thursday, 8 November 2012

How to made easy Subnetting

Subnetting Made Easy
Hi all,

I've received an email from one of your members asking me to post up my technique for subnetting as links to external blogs are not allowed due to forum rules. I know that he benefited from it and he wishes to help out others so here goes:

First of all I need you to get rid of all of the negative thoughts surrounding subnetting. Put down all of the books that you have read about the subject and navigate away from other sites claiming to provide an easy way to subnet. This technique requires no charts, just simply the know-how to work with the powers of 2.

We need to start with the fundamentals of IP addressing. An IP address is made up of 32 bits, split into 4 octets (oct = 8, yes?). Some bits are reserved for identifying the network and the other bits are left to identify the host.

There are 3 main classes of IP address that we are concerned with.

Class A Range 0 - 127 in the first octet (0 and 127 are reserved)
Class B Range 128 - 191 in the first octet
Class C Range 192 - 223 in the first octet

Below shows you how, for each class, the address is split in terms of network (N) and host (H) portions.


At each dot I like to think that there is a boundary, therefore there are boundaries after bits 8, 16, 24, and 32. This is an important concept to remember.

We will now look at typical questions that you may see on subnetting. More often than not they ask what a host range is for a specific address or which subnet a certain address is located on. I shall run through examples of each, for each class of IP address.
IP addressing and Subnetting:
To fully understand Subnetting, it is vital to know how many network and host bits are present in Class A, Class B, and Class C networks.
  First Octet (Range) No. of Network Bits No. of Host Bits Default Mask
Class A 1 – 126 8 24
Class B 128 – 191 16 16
Class C 192 – 223 24 8

Network Address broken down into network and host bits.

Dotted decimal               17           1                             1                             1
Octet in binary 0001001 00000001             00000001             00000001
Network / Host Bits       Network Host                       Host                       Host

Subnetting is simply a process of “borrowing” host bits in order to create the subnet portion of an address. Note in the following examples that the network portion of the address never changes. The subnet field always borrows from the host bits.

Why Use Subnetting?
Subnetting is a highly effective method of conserving  IP address. Consider a point to point ISDN connection with two host addresses, one on each side of the connection. Using an entire Class C address range for this network segment would be a waste of addresses. A default Class C network mask of yields 254 usable host addresses, but only two are needed for this small network.

Subnetting allows the use of a “tighter” subnet mask that the default; that is, one that yields a smaller amount of network addresses. The benefit is that the address that would have been wasted are now still usable by other segments of the network.

Determining the number of valid subnets
To determine the number of valid subnets for a given number and mask, use this formula:
Number of subnets = (2 squared by the number of subnet bits) – 2
The number of subnet bits is determined by examining the default network mask for that class, and comparing it to the actual network mask. Taking network as an example, the default mask for the class B network is write out the default mask and the actual mask in binary:

                1st octet 2nd octet 3rd octet 4th octet
Default mask 1111111 1111111 0000000 0000000
Subnet mask 1111111 1111111 1111111 0000000
Type and number of bits all network bits all network bits all subnet bits all host bits

No. of subnet bits = network bits in (subnet mask) – network bits in (default subnet mask)
No. of hosts bits = 32 – no. of network bits in subnet mask (CIDR value)

x= no. of subnet bits    
y = no. of host bits
No. of valid subnet = 2x -2
No. of host per subnet = 2y – 2
Total no. of host = no. of valid subnet X no. of host per subnet
For example:
i)               (stated in prefix notation and /24 is called CIDR value)
x = 24 – 16 = 8                    
y= 32 – 24 = 8
No. of subnets = 28 – 2 = 254
No. of host per subnet= 28 – 2 = 254
x= 24 – 8 = 16
y= 32 – 24 = 8
No. of subnets = 28 – 2 = 254
No. of host per subnet = 28 – 2 = 254
x= 27 – 24 = 3
y= 32 – 27 = 5
No. of subnets = 23 – 2 = 6
No. of host per subnet = 25 – 2 = 30

Determining the subnet number (subnet address) of a given IP address and subnet mask
is accomplished by performing a Boolean AND operation.
First, the IP Address and its subnet mask will be converted to binary. The Boolean AND is simply a bit-by-bit comparison of the IP Address and the Subnet Mask.
1 + 1 = 1
0 + 1 = 0
0 + 0 = 0                                              
(if any value is 0 then result 0)

Consider Network Address Convert the IP address and the subnet mask into binary, remembering that /24 is equivalent to

                1st octet 2nd octet 3rd octet 4th octet
IP Address 10110010 00111000 00010101 00001001
Subnet mask 1111111 1111111 1111111 00000000
AND Result 10110010 00111000 00010101 00000000
AND Result (decimal) 172 56 21 0

So, Subnet Address of is

Example: What is the subnet address of
                1st octet 2nd octet 3rd octet 4th octet
IP Address 11001000 10011010 10010110 01011001
Subnet mask 1111111 1111111 1111111 11100000
AND Result 11001000 10011010 10010110 01000000
AND Result (decimal) 200 154 150 64

So, Subnet Address of is

Host Range in a given subnet
Y = 32 – 27 = 5

Total no of valid host in a given subnet = 2y-2 = 30

First IP Address (in the subnet)
(When all hosts bit are 0) Valid Host Range (in the subnet) Last IP Address (in the subnet)
(When all host bits are 1) to (next n/w 64+32)

Meeting Stated Design Requirements:
Your network uses Class B You need at least 150 subnets that have no more than 200 hosts apiece. What subnet mask should you use?

No. of subnet ≥ 150
2X – 2 ≥ 150                          (so x = 8)

No. of hosts per subnet ≤ to 200
2Y – 2 ≤ 200                          (so x = 7)

As is a Class B address with default mask 16 bits are being used for network and leaving another 16 bits to be divided between subnet and host bits.
As no. of Hosts per subnet should not be more than 200, and No. of subnet can be more than 150. We are not going to use more than 7 bits for the hosts, it means we have 9 bits for the subnet.
So x = 9

so the subnet mask you should use is or /25