To download the PDF version of this article click here.

IP Subnetting

Colin Weaver, ITdojo

Note:  This document assumes that “subnet zero” is NOT used.  For a description of subnet-zero, go here (http://www.cisco.com/warp/public/105/40.html).

Subnetting IP networks is one of those things that is extremely easy for some people and painfully confusing for others.  I’ve done more than my share of subnetting so I figured I’d take a stab at trying to lay it out for anyone interested in reading it.  Anyhow, here it is:

Subnetting by Colin:

Using 172.16.0.0 255.255.0.0 as the example network (we can also write this as 172.16.0.0/16):

172.16.0.0/16 is one (1) network.  There are 65,534 possible hosts on this network.

When subnetting, the objective is to take that one network and break it into multiple smaller networks.  Two things:

1)  How many networks you divide it into is up to you (your specific needs) (e.g. how many networks you need for your situation)

2)  When you break one network up into multiple networks you end up with fewer hosts per network.

The most straight-forward way you will be asked to subnet (especially on a test) is along the lines of:

"You have been assigned the network listed above.  You need to divide this network into at least 50 subnets.  What is your new subnet mask as a result of this?  Also list the networks."

Ask yourself these questions:

Given the major network 172.16.0.0 255.255.0.0,

1)  How many bits (bb) do I have to borrow to get XX subnets (50 in this example)?

2)  If I borrow (bb) bits in order to get XX subnets, what is my new subnet mask?

3)  What are the networks for this new subnet mask?

4)  How many hosts do I have per network?

5)  What are those hosts and what is their broadcast address?

-------------------------------------------------------------------------------------

Answer:

Given the major network 172.16.0.0 255.255.0.0,

1)  How many bits (bb) do I have to borrow to get XX subnets (50 in this example)?

          Use the "magic equation":  2N-2= # of networks

          N = # of bits "borrowed"                

          (26)-2 = 62 networks*   

* (25-2 would only yield 30 networks.  We need 50 in this example.  62 is the best we can do and still meet the objectives.)

2)  If I borrow (bb) bits in order to get XX subnets, what is my new subnet mask?

·        Knowing that you borrowed six (6) bits, add the decimal values of those six bit positions together to yield the new subnet mask.        

          128    64      32      16      8        4        2        1

          ----------------------------------------------------------

          1        1        1        1        1        1        0        0        

          ----------------------------------------------------------

          128 +64 +   32 +  16 +  8 +    4 +    0 +    0 = 252        

          So, the new mask is the original mask (255.255.0.0) plus these six bit positions.        

          New mask:  255.255.252.0        

3)  What are the networks for this new subnet mask?

·        Determine the networks by examining the decimal value of the last bit position you "borrowed".  Look at question #2.  You borrowed 6 bits in order to get at least 50 subnets.  Borrowing those six bits puts you at the 4 bit-position (128+64+32+16+8+4).  That bit position marks the start of the new network range and also marks how the network numbers will grow.  So:

          A) Since this example takes us to the "4" bit-position our first network is 4.          

                   172.16.4.0        

          B) Since we are at the "4" bit position, our networks grow by 4 each time.         

                   1st network:         172.16.4.0

                   2nd network:        172.16.8.0

                   3rd network:        172.16.12.0

                   4th network:        172.16.16.0

                   5th network:        172.16.20.0

                   6th network:        172.16.24.0

                   etc...

                   Since this example will give us 62 networks we could keep counting until
                   we finally got up to:

                   62nd network:       172.16.248.0                

                   The subnet mask for every one of these networks is 255.255.252.0                 

4)  How many hosts do I have per network?

          To answer this question you have to as yourself how many "host bits" are left over from the subnetting that you did.        

          When we started we had:       

          172.   16.     0.       0

          255.   255.   0.       0        

          In Binary:        

          10101100   = 172

          00010000   = 16

          11111111   = 255        

          So:       

          172.16.0.0 =         10101100   00010000   00000000   00000000

          255.255.0.0 =       11111111   11111111   00000000   00000000        

·        The masked bits (a value of 1 in the subnet mask) are the network bits.

·        The unmasked bits (a value of 0 in the subnet mask) are the host bits.        

          Unmasked bits (host bits) = 16        

          # of hosts = (216) - 2

          # of hosts = 65534        

          For our subnetted networks (using the first subnet as an example):        

          172.   16.     4.       0

          255.   255.   252.   0        

          In Binary:        

          10101100   = 172

          00010000   = 16

          11111111   = 255

          11111100   = 252        

          So:    

          172.16.4.0 =         10101100   00010000   00000000   00000000

          255.255.252.0 =   11111111   11111111   11111100   00000000      

·        The masked bits (a value of 1 in the subnet mask) are the network bits.

·        The unmasked bits (a value of 0 in the subnet mask) are the host bits.        

          Unmasked bits (host bits) = 10 (ten)  (the last two bit positions in the 3rd octet and all 8 bit positions in the 4th octet)        

          # of hosts = (210) - 2

          # of hosts = 1,022 hosts PER network      

          So:  We started with one (1) network with 65,534 hosts.  We now have 62 networks and there are 1,022 hosts on each of those networks.

5)  What are those hosts?

          Using 172.16.4.0 255.255.252.

·        The first host is the lowest number to which you can count that is not the network number itself.  In this example, the next lowest number is:  172.16.4.1. 

·        The broadcast address for this network is the highest number to which you can count that is still LESS than the next network.  This network is 172.16.4.0.  The next network is 172.16.8.0 (see question #3)

·        The highest number that I can count to that is still LESS than 172.16.8.0 is 172.16.7.255.  1721.6.7.255 is the broadcast address for this network.

·        Another way to word this is to say that the broadcast address for a particular subnet is always 1 (one) less than the next network.

  ·        So, for 172.16.4.0:

 IP       Mask  Notes ...

172.16.4.0   255.255.252.0      Subnet Address

172.16.4.1   255.255.252.0      Host

172.16.4.2   255.255.252.0      Host

172.16.4.3   255.255.252.0      Host

172.16.4.4   255.255.252.0      Host

172.16.4.5   255.255.252.0      Host

… (a whole bunch of addresses in-between) … 

172.16.7.251        255.255.252.0      Host

172.16.7.252        255.255.252.0      Host

172.16.7.253        255.255.252.0      Host

172.16.7.254        255.255.252.0      Host

172.16.7.255        255.255.252.0      Broadcast Address

Note:  This document assumes that “subnet zero” is NOT used.