Wednesday, May 6, 2009

Subnetting Tips

The questions you will be asked on the CCNA exam will probably be one or all of the following:

  1. If you are going to use the subnet mask, x.x.x.x, how many subnets does this subnet mask produce? (You'll know this answer automatically if you memorize the subnet mask tables in our memorization lists).
  2. How many valid hosts are available for the following subnet? (You'll know this answer automatically if you memorize the subnet mask tables in our memorization lists).
  3. What are the valid subnets that you can obtain from the given subnet mask?
  4. What is the broadcast address of each subnet?
  5. What are the valid hosts in each of the subnets?
  6. What subnet mask should you use if you need x subnets and y hosts?

The following is the easiest way to figure out the answers to each of these questions. It is the method used by Todd Lammle. If you have his CCNA book, he covers this method in the book.
  
First, memorize your "powers of two":

  2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
2^6 = 64
2^7 = 128
2^8 = 256
2^9 = 512
2^10 = 1024

Let's go over each of the above questions:

1. How many subnets:

Let's say you are going to use the subnet mask 255.255.255.224 with a class C address and you need to know how many subnets are available. Think of the subnet mask in binary as 11111111.11111111.11111111.11100000. Looking at the last octet (because you use this octet for subnetting on a class C address), you've got three "on" bits, or 1's. So, the formula to figure out how many subnets that this mask will produce is 2^n-2, where n is the number of "on" bits. 2^3-2 = 6 subnets. If you have memorized your subnet mask tables from our memorization lists, you'll know this is true and won't have to go through this procedure.

Let's try another one. Let's say you are going to use the subnet mask 255.255.255.224 with a class B address. Think of the subnet mask in binary as 11111111.11111111.11111111.11100000. Looking at the last two octets (because you use these two octets for subnetting on a class B address), you've got eleven "on" bits, or 1's. So, the formula to figure out how many subnets that this mask will produce is 2^n-2, where n is the number of "on" bits. 2^11-2 = 2046 subnets. If you have memorized your subnet mask tables in our memorization lists, you'll know this is true and won't have to go through this procedure.

2. How many hosts per subnet:

Let's say you are using the subnet mask 255.255.255.224 with a class C address and you want to figure out how many hosts are available for each subnet. Instead of looking at the "on" bits when trying to find the number of subnets, you will be looking at the "off" bits or 0's. So, once again think of your subnet mask as 11111111.11111111.11111111.11100000. You'll see that there are five "off" bits. So, the formula to figure out how many hosts per subnet that this mask will produce is 2^y-2, where y is the number of "off" bits. 2^5-2 = 30 hosts per subnet. If you have memorized your subnet mask tables from our memorization lists, you'll know this is true and won't have to go through this procedure.

Let's try another one: Let's say you are using the subnet mask 255.255.255.0 with a class B address and you want to figure out how many hosts are available for each subnet. Instead of looking at the "on" bits when trying to find the number of subnets, you will be looking at the "off" bits or 0's. So, think of your subnet mask as 11111111.11111111.11111111.00000000. You'll see that there are eight "off" bits. So, the formula to figure out how many hosts per subnet that this mask will produce is 2^y-2, where y is the number of "off" bits. 2^8-2 = 254 hosts per subnet. If you have memorized your subnet mask tables from our memorization lists, you'll know this is true and won't have to go through this procedure.

3., 4. and 5. Valid subnets, broadcast address, valid hosts

We can answer all of these at the same time using the following procedure. What are the valid subnets that you can obtain from the given subnet mask, what is the broadcast address of each subnet, and what are the valid hosts in each of the subnets.

Let's say that you need to subnet the network address 199.42.78.0 using the subnet mask 255.255.255.224.

First, to figure out the valid subnets, use the formula: 

256 – subnet mask = base number.

So, your base number is 256 – 224 = 32. Now just keep adding 32 to itself to get the valid subnets. 32, 32+32=64, 64+32=96, 96+32=128, 128+32=160, 160+32=192. You can't use 192+32=224 because 224 is your subnet mask. So, your valid subnets are 32, 64, 96, 128, 160, and 192. Let's start making a table to easily see what is happening:

Subnet 1 Subnet 2 Subnet 3 Subnet 4 Subnet 5 Subnet 6
Subnet Address 32 64 96 128 160 192
First Valid Host            
Last Valid Host            
Broadcast Address            

Next, to figure out what the broadcast addresses are for each subnet, just use the number before the next subnet. So, for the subnet address 32, the number before the next subnet 64 is 63. This is the broadcast address for subnet 32. For the subnet address 64, the number before the next subnet 96 is 95. This is the broadcast address for subnet 64. Do this for each subnet. Remember, just use the number before the next subnet. Let's fill in our table to see what we have so far:

  Subnet 1 Subnet 2 Subnet 3 Subnet 4 Subnet 5 Subnet 6
Subnet Address 32 64 96 128 160 192
First Valid Host            
Last Valid Host            
Broadcast Address 63 95 127 159 191 223

Finally, figuring out the valid hosts is easy. Just fill in the numbers between the subnet address and the broadcast address. Let's fill in the rest of the table:

  Subnet 1 Subnet 2 Subnet 3 Subnet 4 Subnet 5 Subnet 6
Subnet Address 32 64 96 128 160 192
First Valid Host 33 65 97 129 161 193
Last Valid Host 62 94 126 158 190 222
Broadcast Address 63 95 127 159 191 223

Now that you know how to create the whole table to find all the subnets, the broadcast addresses, and the valid hosts, let's find out how to quickly figure out answers to what you need without doing the whole table. Let's say you receive the following question on the exam:

Using the subnet mask 255.255.255.224, what is the subnet that the host 199.42.78.133 belongs to and the broadcast for this address?

All you have to do is use your formula 256 – subnet mask = base number.
256-224=32, which is your first subnet. Now just add the 32 to itself until you reach the subnet that contains the host 133. 32+32=64, 64+32=96, 96+32=128, 128+32=160. We can stop here because 133 is between 128 and 160. So, we know that the address 199.42.78.133 belongs within the 199.42.78.128 subnet and the broadcast is one less than the next subnet of 160, which is 159. So, the broadcast address is 199.42.78.159.

Let's try another one:
Given the network address 172.16.68.17 and the subnet mask 255.255.192.0, find the subnet it belongs to and its broadcast.

First, use the formula 256 – subnet mask = base number. 256-192=64. 64+64=128, 128+64=192. We can't use 192 because it is your subnet mask. So, our valid subnets are 64.0 and 128.0 (notice that the subnetting is on the third octet of the mask 255.255.192.0, that's why the subnets are 64.0 and 128.0, not just 64 and 128 - Remember this!!!).

Let's use a chart for this one to make it easier to see:

Subnet 1 Subnet 2
Subnet address 64.0 128.0
First valid host 64.1 128.1
Last valid host 127.254 191.254
Broadcast address 127.255 191.255

We can tell from the chart that the host 172.16.68.17 is in the 172.16.64.0 subnet and its broadcast is 172.16.127.255.

The more examples that you do on subnetting, the easier it becomes. Here is a summary of what you need to know:

  • Number of subnets = 2^n-2 where n is the number of "on" bits or 1's
  • Number of hosts = 2^y-2 where y is the number of "off" bits or 0's
  • 256 – subnet mask = base number or first subnet (add this number to itself to find remaining subnets)
  • Broadcast address = the number before the next subnet
  • Valid hosts = the numbers between the subnets, not including the broadcast address

6. This is the final question that you saw at the beginning of this document. If you are given a particular network and you need x subnets and y hosts, which subnet mask should you use?

The easiest way to do these types of questions is to memorize the subnet mask tables in our memorization lists. The other way is to use the formulas:

Number of subnets = 2^n-2 where n is the number of "on" bits or 1's 
Number of hosts = 2^y-2 where y is the number of "off" bits or 0's

Let's say you receive the following question on the exam:
You are given the network 130.175.0.0. You want at least 70 subnets and 500 hosts per subnet. What subnet mask should you use?

If you memorized our subnet mask tables, you could easily see that you would have to use subnet mask 255.255.254.0 to satisfy these conditions. If you don't memorize the lists, here is one way you could do it:

This is a class B address, so you have 16 bits that can be used for subnetting (the 0.0 in the subnet mask can be written 00000000.00000000, which is 16 bits).

Using your formulas above, you will want to come as close as you can to 70 subnets and 500 hosts. If we start by trying to find the amount of subnets (using "on" bits or 1's), we know that 2^6-2=62 (11111100.00000000) isn't enough subnets so let's use 2^7-2= 126 (11111110.00000000). This is enough but let's make sure it will give us enough hosts. Since we used 2^7-2=126 (11111110.00000000) for the subnets, we would use the "off" bits to find the hosts. Since we have 7 "on" bits, this means we have 9 "off" bits. So, 2^9-2=510, which just gives us enough hosts. This means that 11111110.00000000 would work for the subnet mask. Knowing what we do about binary, let's add up the "on" bits or 1's: 128+64+32+16+8+4+2=254. So, the subnet mask would be 255.255.254.0. You could also figure out this problem finding the hosts first instead of the subnets first.

No comments:

Post a Comment