IP Subnetting Made Easy

The first step in understanding how to subnet is to understand an IP address and Subnet Mask.  An IPv4 IP address is made up of 32 bits ( 4 octets of 8 bits).  There are 3 classes of IP addresses we can use for an IP network.  The left most octet defines the class.

    Class A range 1.x.x.x - 126.x.x.x  with a default subnet mask of 255.0.0.0
    Class B range 128.x.x.x - 191.x.x.x with a default subnet mask of 255.255.0.0
    Class C range 192.x.x.x - 223.x.x.x with a default subnet mask of 255.255.255.0

The default subnet mask defines how much of the IP address is dedicated to the network portion with the balance dedicated to the hosts on that network.

Let's review binary!  If there are 8 bits in an octet, and all bits have a 1 in them, the result is 255.  Remember the powers of 2 for each bit:


        __    __    __    __    __    __    __    __

        27     26     25   24     23     22    21     20

     128     64    32   16      8     4     2        1   Decimal Equivalent

 

Now lets take an IP address and break it down:
    Here's the IP address    135.105.0.0. that is registered for our company ABC, Inc.
    Step #1 - Determine what class the IP address is in                              answer: Class B
    Step #2 - Determine what the default subnet mask is                            answer: 255.255.0.0
    Setp #3 - Using the answer in step #2, determine how many bits are
 set to 1 starting from the left                                                                    answer: 16
    Step #4 - The answer from #3 will also tell you how many bits are dedicated to the network portion of the IP address.
    Step #5 - Draw a line separating the network portion of the IP address from the Host portion

This is what we have so far  135.105.|0.0.  If we used n to represent the bits for the network portion and h for the host portion of the IP address, our address would look like this:
        nnnnnnnn.nnnnnnnn.|hhhhhhhh.hhhhhhhh

With this is mind, lets determine the # of hosts we can have on the network of 135.105.0.0  To do this remember one and only one calculation  2#-2  where # will represent the number of bits.  How many bits are dedicated to the Host address?  16  Use the 16 in the equation to get 216-2= 65,534 possible Hosts.  Now you are probably asking why the minus 2 in the equation.  Some implementations of IP addressing do not allow you to use an address where the Hosts bits are all 0's or all 1's.  In fact, all 1's are used for broadcasts.  So we have to exclude them from the total possible hosts.  216 = 65,536 - 2 excluded = 65,534.

Now ABC, Inc. has grown and the company would like to break up their LAN into separate independent networks.  This process is done through subnetting.  We are still going to use the same IP address of   135.105.0.0  To define separate subnets, we need to play with the subnet mask of 255.255.0.0

To start the subnetting process, you will BORROW bits from the Host portion of the IP address and dedicate them to the subnet.  The question is, just how many bits do we borrow?  The answer starts with defining either the number of Subnets you need or the number of Hosts per subnet you need.  Either will work.  ABC, Inc. needs to break up their LAN into 5 subnets, 1 for each department - Sales, Marketing, Accounting, Payroll, and Human Resources.  So we know how many subnets we need, but still don't know how many bits to borrow.  Lets go back to the one calculation you have to remember 2#-2.  If we replace the # sign with 1 through 8 bits (remember there are 8 bits in an octet), these are the results:

    21-2 = 0 possible subnets
    22-2 = 2 possible subnets
    23-2 = 6 possible subnets
    24-2 = 14 possible subnets
    25-2 = 30 possible subnets
    26-2 = 62 possible subnets
    27-2 = 126 possible subnets
    28-2 = 254 possible subnets

Which equation is the first to support 5 subnets?  Answer:  23-2.  This will give us the 5 we need plus 1 extra.  Now, if you expect growth in the future, use an equation that supports more subnets.  OK, we have the answer.  If we borrow 3 bits, we will get 6 subnets, 5 of which we are going to use right away.  The number of bits to borrow came from the 3 in the equation above.

Hang on, here we go subnetting!!!  Let's take a look at why 23-2 only supports 6 subnets.  KEEP IN MIND, YOU CANNOT USE ALL 0's OR ALL 1's.  With that lets take 3 bits and figure the combinations by hand.  We can have:
    000
    001
    010
    011
    100
    101
    110
    111
Throw out the combination's with all 0's and all 1's, count the remaining combinations and you have your 6 possible subnets.  Now lets break down the subnet mask to include the 3 bits we borrowed from the Host portion to define our 6 subnets - s.
    Before we started we had:  nnnnnnnn.nnnnnnnn.hhhhhhhh.hhhhhhhh

   
Now we have:                    nnnnnnnn.nnnnnnnn.ssshhhhh.hhhhhhhh

Just for kicks, we now have 13 h's for our Hosts.  How many Hosts can we have on each of the 6 Subnets?  Using 213-2, we get 8190 Hosts.

Let's keep things rolling.  See those 3 s, figure their decimal equivalent:

  s        s        s   __    __    __    __    __

  27     26     25   24     23     22    21     20

128     64    32   16      8     4     2        1   Decimal Equivalent

The answer is 128+64+32=224.  You've just figured out the number to use for the 3rd octet, 224.  Now our subnet mask is 255.255.224.0.  With this subnet mask, we borrowed 3 bits from the Host portion and used them to define our Subnet.  Great!!  But wait, were not done yet.

You now have to figure the address you can use for each Subnet in the 3rd octet.  Remember, YOU CANNOT USE ALL 0's OR ALL 1's.  Here is how we do it, 2 different ways.
    A.)  Take the right most s, and get its decimal value     answer: 32      OR
    B.)  Take 256 and subtract your subnet mask of 224   answer: 32     
 Either will work just fine.  Pick a method to use consistently.

The 32 represents the range increment (R.I.).  Take the 3 bits, put all 0's in their spots, get the decimal equivalent,   answer: 0.  Take the result and add the R.I. to get 32.  Take that result and add the R.I. to get 64 and so on.  Here are the ranges:
    Decimal        Binary   
         0             000    CAN'T USE
        32            001    1st useable Subnet
        64            010    2nd useable Subnet
        96            011    3rd useable Subnet
        128          100    4th useable Subnet
        160          101    5th useable Subnet
        192          110    6th useable Subnet
        224          111    CAN'T USE

Now we have 6 subnets defined, all using the Subnet Mask of 255.255.224.0.  The subnets are:

        135.105.32.0
        135.105.64.0
        135.105.96.0
        135.105.128.0
        135.105.160.0
        135.105.192.0

Almost Done!!  Last thing we need to do is determine what addresses to assign to the Hosts.  Lets take the 135.105.32.0 subnet and break it down to n, s, and h's.

nnnnnnnn.nnnnnnnn.ssshhhhh.hhhhhhhh

We are going to work with the s and h's from this point on.  If we use 32 (our first available Subnet) for the s part we get 001 in binary.  If we use all 0's for the h's we get 00000.00000000 in binary.  Put the 2 together to make up the last 2 octets, we get:
        00100000.00000000 (in decimal this is 32.0)
            32        .        0

Now lets put all 1's in the h's, keeping the s part the same.  We now get:
        00111111.11111111 (in decimal this is 63.255)
            63        .      255

What have we been saying all along?  YOU CAN'T USE ALL 0's OR ALL 1's.  So we add 1 to the starting number and subtract 1 from the ending number in the range and get:  32.1 and 63.254.  This is the Range of addresses we can assign to Hosts on the 32 Subnet.  Here are the Ranges for all 6 Subnets:
      Subnet        Range   
        32        32.1 - 63.254
        64        64.1 - 95.254
        96        96.1 - 127.254
       128     128.1 - 159.254
       160     160.1 -
191.254
       192     192.1 - 223.254

 

Last but not least, take the original IP address and tack it onto the front of these Subnets and your work is done.
    Original IP address and Subnet mask: 
           135.105.0.0
            255.255.0.0

Divided into 6 Subnets:
           Subnet                    Subnet mask:                Range of adresses
        135.105.32.0            255.255.224.0            135.105.32.1  -  135.105.63.254
        135.105.64.0            255.255.224.0            135.105.64.1  -  135.105.95.254
        135.105.96.0            255.255.224.0            135.105.96.1  -  135.105.127.254
        135.105.128.0          255.255.224.0            135.105.128.1 - 135.105.159.254
        135.105.160.0          255.255.224.0            135.105.160.1 - 135.105.191.254
        135.105.192.0          255.255.224.0            135.105.192.1 - 135.105.223.254

Question:  The host with the IP address of 135.105.145.16 using the Subnet mask of 255.255.224.0 resides on which subnet?   Answer:  The host resides on the 135.105.128.0 subnet.