## Subnetting tutorial

Here is something I put together for my brother who was studying for his CCNA at the time. Subnetting seems to kick peoples arse constantly, so I spent some time with one of our network engineers. This was the outcome of it.

How-To Subnet an IP Range
By Mark Birchfield
Birchfield4@yahoo.com

To understand how subnetting works, you must first have a good basic understanding of IP Addresses. An Ip address is set of binary octets broken into quads. That probably made absolutly no sense to you, so we will try it another way. An Ip address follows what is called dotted octet notation. There are 4 sets of numbers in an ip address with dots separating them. (ie., 192.168.0.1) Now lets go a bit further into the binary octet part. Binary numbers are broken down by what is known as positional notation. This works from right to left in increasing place values. Here is an example:

192.168.0.1 in binary octet form would be 11000000.10101000.00000000.00000001

1 1 0 0 0 0 0 0. = binary form of 192 (Hint: Add up the ones with the numbers below
128 64 32 16 8 4 2 1 them. First one equals 128 plus second which is 64. Added together this equals…192.

1 0 1 0 1 0 0 0. = binary form of 168 (Again, each 1 holds value of number below it.)
128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 0. = 0 , Duh..
128 64 32 16 8 4 2 1

0 0 0 0 0 0 0 1 = 1
128 64 32 16 8 4 2 1

Great! Now the basics are out of the way. Let’s move on to the important stuff. How we subnet an ip range depends first on how large your assigned ip range is to begin with. If you are running a private network going through One static Ip address then your range is: 192.168.xxx.xxx . So there is really no reason to subnet UNLESS you want to cut down on traffic and segment your lan by whatever reason you feel is good enough to undertake this task. Lets assume an ip address of 128.16.8.0 as a base. This is obviously a simplified example, but enough so to get the point of the exercise. Broken down into dotted octet notation 128.16.8.0 is:
10000000.00010000.00001000.00000000
Now, the first step in subnetting, is planning. How many hosts do you want per mask? Is there a chance that you may be expanding any or all of these subnets in the future? These are all things that HAVE to be taken into consideration BEFORE you get everything setup. The reason is this, the amount of hosts you decide upon directly affects all the following steps. Say you want to have 20 hosts available per subnet. This means that you will need a minimum of 22 hosts (Remember, network address and broadcast have to be taken into account also.) Lets zoom in on the last octet of our ip address.

0 0 0 0 0 0 0 0 Remember this from above?
128 64 32 16 8 4 2 1

So, if we want at least 22 hosts on each of our subnets then we are going to need the last 5 bits in our octet quad. This will give us a total available of 16+8+4+2+1 or 31 possible hosts or 29 if you don’t count the network address and broadcast address. This leaves the first three bits of the octet for Network addressing (again, refer to the top on how ips work.) This makes our Subnet Mask for our ENTIRE network 255.255.255.224. How did I come up with this? The positional notation values for the first three bits of our final octet, when added together, equal 224.

{Network bits}{ Host bits}

{128 64 32 }{ 16 8 4 2 1}

0 0 0 0 0 0 0 0 Network address for this subnet
0 0 0 0 1 IP Range of 128.16.8.0-31
0 0 0 1 0
0 0 0 1 1
…….

0 0 1 0 0 0 0 0 Network address for this subnet
0 0 0 0 1 IP Range of 128.16.8.32-63
0 0 0 1 0
0 0 0 1 1
…….

0 1 0 0 0 0 0 0 Network address for this subnet
0 0 0 0 1 IP Range of 128.16.8.64-95
0 0 0 1 0
0 0 0 1 1
…….

………….
………….

1 1 1 0 0 0 0 0 Network address for this subnet
0 0 0 0 1 IP Range of 128.16.8.224-255
0 0 0 1 0
0 0 0 1 1
…….

Get the picture so far? So lets see where we stand now. We have our ip address of 128.16.8.0. Now lets look at the subnet mask as we figured out above. For our first subnet, we use our subnet mask of 255.255.255.224. This gives us hosts from 128.16.8.1 to 30 with 128.16.8.0 for network address and 128.16.8.31 as broadcast. Our next subnet would be 128.16.8.32 with the same 31 hosts counting broadcast and network. The subnet following that would have anip range of 128.16.8.64-95. The next would be 128.16.8.96-127, then 128-159, then 160-191, 192-223, and finally 224-255.
This is a very simplified example without a lot of why this happens. Here is an attempt on my part to explain how this works. Your Ip address and your subnet mask is bitwise “AND”ed together (read boolean algebrea). “0”s hide the number, while “1”s let it show through. The resulting binary number is your network address that falls out of the addition. Example:

11000000.10101000.00000000.000 Network address (192.168.0.0 in this case)

This means anything to the right of the 4th bit in the final octet is a host address. This also means that the first three bits in the final octets are network address’. So, as above, our first subnet would be 192.168.0.0-31. After that we would have to set the third bit from the left in the final octet, which changes the network address and results in our second subnet. Example: