Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Cisco Press CCNA ICND 2004 - Cisco Press.pdf
Скачиваний:
120
Добавлен:
24.05.2014
Размер:
13.19 Mб
Скачать

Analyzing and Interpreting IP Addresses and Subnets 127

(c)Find the multiple of the magic number that is closest to but not greater than the address’s interesting octet.

(d)Write down that multiple of the magic number as the value of the subnet number’s interesting octet.

(e)To find the first valid IP address in the subnet, copy the subnet number, but add 1 to the fourth octet.

Step 3 Derive the broadcast address and the last valid IP address:

(a)Write down 255s in the broadcast address octets to the right of the line or the box.

(b)To find the broadcast address’s interesting octet value, take the subnet number’s interesting octet value, add the magic number, and subtract 1.

(c)To find the last valid IP address in the subnet, copy the broadcast address, but subtract 1 from the fourth octet.

Becoming proficient at this shortcut takes some practice. To make sure you have the process down, review the examples in the CD chapter “Subnetting Practice: 25 Subnetting Questions,” which has 25 different examples, including the Boolean AND and shortcut methods of finding the subnet number.

Which Subnet Masks Meet the Stated Design Requirements?

This chapter has explained how to answer questions that provide the subnet number. However, some questions do not supply the subnet number, but instead ask you to choose the correct subnet mask given a set of requirements. The most common of these questions reads something like this:

“You are using Class B network X, and you need 200 subnets, with at most 200 hosts per subnet. Which of the following subnet masks can you use?” This is followed by some subnet masks from which you choose the answer.

To find the correct answers to these types of questions, you first need to decide how many subnet bits and host bits you need to meet the requirements. Basically, the number of hosts per subnet is 2x – 2, where x is the number of host bits in the address. Likewise, the number of subnets in a network, assuming that the same subnet mask is used all over the network, is also 2x – 2, but with x being the number of subnet bits. As soon as you know how many subnet bits and host bits are required, you can figure out what mask or masks meet the stated design goals in the question.

128 Chapter 4: IP Addressing and Subnetting

Examples certainly help. The first sample question reads like this:

“Your network can use Class B network 130.1.0.0. What subnet masks meet the requirement that you plan to allow at most 200 subnets, with at most 200 hosts per subnet?”

First you need to figure out how many subnet bits allow for 200 subnets. You can use the formula 2x – 2 and plug in values for x until one of the numbers is at least 200. In this case, x turns out to be 8. In other words, you need at least 8 subnet bits to allow for 200 subnets.

If you do not want to keep plugging values into the 2x – 2 formula, you can instead memorize Table 4-30.

Table 4-30 Maximum Number of Subnets/Hosts

Number of Bits in the Host

Maximum Number of Hosts or Subnets (2x – 2)

or Subnet Field

1

0

 

 

2

2

 

 

3

6

 

 

4

14

 

 

5

30

 

 

6

62

 

 

7

126

 

 

8

254

 

 

9

510

 

 

10

1022

 

 

11

2046

 

 

12

4094

 

 

13

8190

 

 

14

16,382

 

 

As you can see, if you already have the powers of 2 memorized, you really do not need to memorize the table—just remember the formula.

As for the first sample question, 7 subnet bits is not enough, because that allows for only 126 subnets. You need 8 subnet bits. Similarly, because you need up to 200 hosts per subnet, you need 8 host bits.

Analyzing and Interpreting IP Addresses and Subnets 129

Finally, you need to decide what mask(s) to use, knowing that you have a Class B network and that you must have at least 8 subnet bits and 8 host bits. Using the letter N to represent network bits, the letter S to represent subnet bits, and the letter H to represent host bits, the following shows the sizes of the various fields:

NNNNNNNN NNNNNNNN SSSSSSSS HHHHHHHH

All that is left is to derive the actual subnet mask. Because you need 8 bits for the subnet field and 8 for the host field, and the network field takes up 16 bits, you have already allocated all 32 bits of the address structure. Therefore, only one possible subnet mask works. To figure out the mask, you need to write down the 32-bit subnet mask, applying the following fact and subnet masks:

The network and subnet bits in a subnet mask are, by definition, all binary 1s.

Similarly, the host bits in a subnet mask are, by definition, all binary 0s.

So, the only valid subnet mask, in binary, is

11111111 11111111 11111111 00000000

When converted to decimal, this is 255.255.255.0.

A second example shows how the requirements stated in the question allow for multiple possible subnet masks:

“Your network can use Class B network 130.1.0.0. What subnet masks meet the requirement that you plan to allow at most 50 subnets, with at most 200 hosts per subnet?”

For this design, you still need at least 8 host bits, but now you only need at least 6 subnet bits. 6 subnet bits allows for 26 – 2, or 62, subnets. Following the same convention as before, but now using an X for bits that can be either subnet or host bits, the format of the address structure is as follows:

NNNNNNNN NNNNNNNN SSSSSSXX HHHHHHHH

In other words, the addresses have 16 network bits, at least 6 subnet bits, and at least 8 host bits. This example actually allows for three valid subnet masks, whose structure is as follows:

NNNNNNNN NNNNNNNN SSSSSSSS HHHHHHHH – 8 subnet, 8 host NNNNNNNN NNNNNNNN SSSSSSSH HHHHHHHH – 7 subnet, 9 host NNNNNNNN NNNNNNNN SSSSSSHH HHHHHHHH – 6 subnet, 10 host

130 Chapter 4: IP Addressing and Subnetting

So, based on the requirements in the question, three different valid subnet masks meet the requirements:

11111111 11111111 11111111 00000000 255.255.255.0

11111111 11111111 11111110 00000000 255.255.254.0

11111111 11111111 11111100 00000000 255.255.252.0

The 2 bits that could be subnet bits or host bits, based on the requirements, are shown in bold.

What Are the Other Subnet Numbers?

The final general type of IP addressing and subnetting question covered in this chapter asks you to list all the subnets of a particular network. You could use a long process that requires you to count in binary and convert many numbers from binary to decimal. However, because most people either learn the shortcut or use a subnet calculator in their jobs, I decided to just show you the shortcut method for this particular type of question.

First, the question needs a better definition—or at least a more-complete one. The question might be better stated like this:

“If the same subnet mask is used for all subnets of this Class A, B, or C network, what are the valid subnets?”

IP design conventions do not require the engineer to use the same mask for every subnet. Unless specifically stated, the question “What are all the subnets?” probably assumes that the same mask is used for all subnets, unless the question specifically states that different masks can be used on different subnets.

The following easy decimal process lists all the valid subnets given the network number and the only mask used on that network. This three-step process assumes that the size of the subnet part of the address is, at most, 8 bits in length. The same general process can be expanded to work when the size of the subnet part of the address is more than 8 bits, but that expanded process is not described here.

The three-step process uses a chart that I call the subnet list chart. I made up the name just for this book. Table 4-31 presents a generic version of the subnet list chart.

Table 4-31 Three-Step Process Generic Subnet List Chart

Octet

1

2

3

4

 

 

 

 

 

Network Number

 

 

 

 

 

 

 

 

 

Mask

 

 

 

 

 

 

 

 

 

Subnet Zero

 

 

 

 

 

 

 

 

 

Analyzing and Interpreting IP Addresses and Subnets 131

Table 4-31 Three-Step Process Generic Subnet List Chart (Continued)

Octet

1

2

3

4

 

 

 

 

 

First Subnet

 

 

 

 

 

 

 

 

 

Next Subnet

 

 

 

 

 

 

 

 

 

Last Subnet

 

 

 

 

 

 

 

 

 

Broadcast Subnet

 

 

 

 

 

 

 

 

 

You list the known network number and subnet mask as the first step in the process. If the question gives you an IP address and mask instead of the network number and mask, just write down the network number of which that IP address is a member. (Remember, this three-step process assumes that the subnet part of the addresses is 8 bits or less.)

For the second of the three steps, copy the network number into the Subnet Zero row. Subnet zero, or the zero subnet, is numerically the first subnet, and it is one of the two reserved subnet numbers in a network. (You can use the zero subnet on a Cisco router if you configure the global configuration command ip zero-subnet.) Interestingly, a network's zero subnet has the exact same numeric value as the network itself—which is one of the reasons that it should not be used. For the purposes of answering questions on the exam about the number of valid subnets in a network, consider the zero subnet unusable, unless the question tells you that using it is ok. In real life, do not use the zero subnet if you do not have to.

The third step in the process is covered after Tables 4-32 and 4-33, which list two familiar examples, with the first two steps completed.

Table 4-32 Subnet List Chart: 130.4.0.0/24

Octet

1

2

3

4

 

 

 

 

 

Network Number

130

4

0

0

 

 

 

 

 

Mask

255

255

255

0

 

 

 

 

 

Subnet Zero

130

4

0

0

 

 

 

 

 

Table 4-33 Subnet List Chart: 130.4.0.0/22

Octet

1

2

3

4

 

 

 

 

 

Network Number

130

4

0

0

 

 

 

 

 

Mask

255

255

252

0

 

 

 

 

 

Subnet Zero

130

4

0

0

 

 

 

 

 

132 Chapter 4: IP Addressing and Subnetting

The last step in this process, Step 3, is repeated many times. This last step uses the magic number, which is 256 minus the mask octet value in the interesting octet. With this process of finding all the subnet numbers, the interesting octet is the octet that contains all of the subnet part of the addresses. (Remember, the process assumes 8 or fewer subnet bits!) In both Tables 4-32 and 4-33, the interesting octet is the third octet.

The third and final step in the process to find all the subnet numbers goes like this: Starting with the last completed row in the table, do the following:

a.Because this process assumes 1 byte or less in the subnet part of the addresses, on the next row of the table, copy down the three octets that are not part of the subnet field. Call the octet that is not copied down the “subnet octet” or the “interesting octet.”

b.Add the magic number to the previous subnet octet, and write that down as the value of the subnet octet.

c.Repeat the preceding two tasks until the next number you would write down in the subnet octet is 256. (But don’t write it down—it’s invalid.)

The idea behind the process of finding all the subnets becomes apparent when you review the same two examples used earlier. Table 4-34 lists the example with the easy mask. Note that the magic number is 256 – 255 = 1 in this case, and that the third octet is the interesting subnet octet.

Table 4-34 Subnet List Chart: 130.4.0.0/255.255.255.0 Completed

Octet

1

2

3

4

 

 

 

 

 

Network Number

130

4

0

0

 

 

 

 

 

Mask

255

255

255

0

 

 

 

 

 

Subnet Zero

130

4

0

0

 

 

 

 

 

First Subnet

130

4

1

0

 

 

 

 

 

Next Subnet

130

4

2

0

 

 

 

 

 

Next Subnet

130

4

3

0

 

 

 

 

 

Next Subnet

130

4

4

0

 

 

 

 

 

(Skipping Many Subnets)

130

4

X

0

 

 

 

 

 

Last Subnet

130

4

254

0

 

 

 

 

 

Broadcast Subnet

130

4

255

0

 

 

 

 

 

You might better understand the logic behind how this process works by looking at the first few entries and then the last few entries. The zero subnet is easily found because it’s the same

Analyzing and Interpreting IP Addresses and Subnets 133

number as the network number. The magic number is 256 – 255 = 1 in this case. Essentially, you increment the third octet (in this case) by the magic number for each successive subnet number.

One row of the table is labeled “Skipping Many Subnets.” Rather than make this book even bigger, I left out several entries but included enough that you could see that the subnet number’s third octet just gets bigger by 1, in this case, for each successive subnet number.

Looking at the end of the table, the last entry lists 255 in the third octet. 256 decimal is never a valid value in any IP address, and the directions said not to write down a subnet with 256 in it, so the last number in the table is 130.4.255.0. The last subnet is the broadcast subnet, which is the other reserved subnet number. The subnet before the broadcast subnet is the highest, or last, valid subnet number.

With a simple subnet mask, the process of answering this type of question is very simple. In fact, many people might even refer to these subnets using just the third octet. If all subnets of a particular organization were in network 130.4.0.0, with mask 255.255.255.0, you might simply say “subnet 5” when referring to subnet 130.4.5.0.

The process works the same with difficult subnet masks, even though the answers are not as intuitive. Table 4-35 lists the answers for the second example, using a mask of 255.255.252.0. The third octet is again the interesting subnet octet, but this time the magic number is 256 – 252 = 4.

Table 4-35 Subnet List Chart: 130.4.0.0/255.255.252.0

Octet

1

2

3

4

 

 

 

 

 

Network Number

130

4

0

0

 

 

 

 

 

Mask

255

255

252

0

 

 

 

 

 

Subnet Zero

130

4

0

0

 

 

 

 

 

First Subnet

130

4

4

0

 

 

 

 

 

Next Valid Subnet

130

4

8

0

 

 

 

 

 

(Skipping Many Subnets)

130

4

X

0

 

 

 

 

 

Last Subnet

130

4

248

0

 

 

 

 

 

Broadcast Subnet

130

4

252

0

 

 

 

 

 

The first subnet number numerically, the zero subnet, starts the list. By adding the magic number in the interesting octet, you find the rest of the subnet numbers. Like the previous example, to save space in the book, many subnet numbers were skipped.

134 Chapter 4: IP Addressing and Subnetting

You probably wouldn’t guess that 130.4.252.0 is the broadcast subnet for this latest example. However, adding the magic number 4 to 252 gives you 256 as the next subnet number, which is invalid, so 130.4.252.0 is indeed the broadcast subnet.

The three-step process to find all the subnet numbers of a network is as follows:

Step 1 Write down the network number and subnet mask in the first two rows of the subnet list chart.

Step 2 Write down the network number in the third row. This is the zero subnet, which is one of the two reserved subnets.

Step 3 Do the following two tasks, stopping when the next number you would write down in the interesting column is 256. (But don’t write it down— it’s invalid.)

(a)Copy all three uninteresting octets from the previous line.

(b)Add the magic number to the previous interesting octet, and write it down as the value of the interesting octet.