One of the most common things you need to figure out is that after you know an IP address and subnet mask, you must answer questions about them. The question might be straightforward, such as "What is the subnet number?", or it might be more subtle, such as "Which of the following IP addresses are in the same subnet as the stated address?" In either case, if you can dissect an IP address as described in this chapter, you can answer any variation of this type of question.

In the next several sections, you will learn how to derive the subnet number and the subnet broadcast address. After deriving these two values, you easily can find the range of valid IP addresses in the subnet.

Earlier, you learned that computers perform a Boolean AND of the address and mask to find the subnet number. The following tables (Tables 12-10 through 12-14) show the Boolean AND process for the five examples used in the previous section of this chapter:

Address |
8.1.4.5 |
0000 1000 0000 0001 0000 0100 0000 0101 |

Mask |
255.255. 0.0 |
1111 1111 1111 1111 0000 0000 0000 0000 |

AND result |
8.1.0.0 |
0000 1000 0000 0001 0000 0000 0000 0000 |

Address |
130.4.102.1 |
1000 0010 0000 0100 0110 0110 0000 0001 |

Mask |
255.255.255.0 |
1111 1111 1111 1111 1111 1111 0000 0000 |

AND result |
130.4.102.0 |
1000 0010 0000 0100 0110 0110 0000 0000 |

Address |
199.1.1.100 |
1100 0111 0000 0001 0000 0001 0110 0100 |

Mask |
255.255.255.0 |
1111 1111 1111 1111 1111 1111 0000 0000 |

AND result |
199.1.1.0 |
1100 0111 0000 0001 0000 0001 0000 0000 |

Address |
130.4.102.1 |
1000 0010 0000 0100 0110 0110 0000 0001 |

Mask |
255.255.252.0 |
1111 1111 1111 1111 1111 1100 0000 0000 |

AND result |
130.4.100.0 |
1000 0010 0000 0100 0110 0100 0000 0000 |

Address |
199.1.1.100 |
1100 0111 0000 0001 0000 0001 0110 0100 |

Mask |
255.255.255.224 |
1111 1111 1111 1111 1111 1111 1110 0000 |

AND result |
199.1.1.96 |
1100 0111 0000 0001 0000 0001 0110 0000 |

Although the tables show the answers, they do not show the process. The steps taken to complete the tables are as follows:

Step 1 To begin, you start with a decimal address and mask stated in the question.

Step 2 Then you must convert the two numbers to binary, as seen in all five examples.

Step 3 Next, each bit is ANDed with the bit in the same position in the other number (in other words, a bitwise Boolean AND), giving the result of the Boolean AND.

Step 4 Finally, the Boolean AND result must be converted back to decimal.

The last step in this process, conversion of the binary number back to decimal, is the step that causes most of the problems for people new to subnetting. In some cases, the conversion is simple. For instance, in the first example, the subnet mask is 255.255.0.0. Because the mask has only 255s or 0s in decimal, the boundary between the subnet and host fields is on a byte boundary as well—between the second and third bytes, in this case. So, the conversion from binary back to decimal for the result of the Boolean AND—0000 1000 0000 0001 0000 0000 0000 0000—typically does not pose a problem.

The confusing typically arises when the boundary between the subnet and host part of the address is in the middle of a byte, which occurs when the subnet mask has some value besides

0 or 255 decimal. For example, with 130.4.102.1, mask 255.255.252.0, the first 6 bits of the third octet comprise the subnet field, and the last 2 bits of the third octet, plus the entire fourth octet, comprise the host field. The problem that some people experience is that they try to convert the 6-bit subnet part from binary to decimal, and the 10-bit host part to decimal. However, when converting binary to decimal to find the dotted decimal IP address, you always convert the entire octet—even if part of the octet is in the subnet part of the address and part is in the host part of the address.

So, in this example, the subnet number (130.4.100.0), in binary, is 1000 0010 0000 0100 0110 0100 0000 0000. The entire third octet is shown in bold, which converts to 100 in decimal. When converting, each set of 8 bits is converted to decimal, giving 130.4.100.0.

The subnet broadcast address, sometimes called the directed broadast address, can be used to send a packet to every device in a single subnet. However, few tools and protocols use the subnet broadcast address anymore. However, by calculating the subnet broadcast address, you easily can calculate the largest valid IP address in the subnet, which is an important part of answering subnetting questions.

There is a binary math operation to calculate the subnet broadcast address. However, there is a much easier process, especially if you already have the subnet number in binary:

Change all the host bit values in the subnet number to binary 1s.

You can examine this simple math behind calculating the subnet broadcast address in the five tables (Tables 12-15 through 12-19) that follow. The host parts of the addresses, masks, subnet numbers, and broadcast addresses are in bold.

Address |
8.l.4.5 |
0000 1000 0000 0001 0000 0100 0000 0101 |

Mask |
255.255.O.O |
1111 1111 1111 1111 0000 0000 0000 0000 |

AND result |
8.l.O.O |
0000 1000 0000 0001 0000 0000 0000 0000 |

Broadcast |
8.l.255.255 |
0000 1000 0000 0001 1111 1111 1111 1111 |

Address |
130.4.102.1 |
1000 0010 0000 0100 0110 0110 0000 0001 |

Mask |
255.255.255.O |
1111 1111 1111 1111 1111 1111 0000 0000 |

AND result |
l3O.4.lO2.O |
1000 0010 0000 0100 0110 0110 0000 0000 |

Broadcast |
l3O.4.lO2.255 |
1000 0010 0000 0100 0110 0110 1111 1111 |

Address |
199.1.1.100 |
1100 0111 0000 0001 0000 0001 0110 0100 |

Mask |
255.255.255.0 |
1111 1111 1111 1111 1111 1111 0000 0000 |

AND result |
199.1.1.0 |
1100 0111 0000 0001 0000 0001 0000 0000 |

Broadcast |
199.1.1.255 |
1100 0111 0000 0001 0000 0001 1111 1111 |

Address |
130.4.102.1 |
1000 0010 0000 0100 0110 0110 0000 0001 |

Mask |
255.255.252.0 |
1111 1111 1111 1111 1111 1100 0000 0000 |

AND result |
130.4.100.0 |
1000 0010 0000 0100 0110 0100 0000 0000 |

Broadcast |
130.4.103.255 |
1000 0010 0000 0100 0110 0111 1111 1111 |

Address |
199.1.1.100 |
1100 0111 0000 0001 0000 0001 0110 0100 |

Mask |
255.255.255.224 |
1111 1111 1111 1111 1111 1111 1110 0000 |

AND result |
199.1.1.96 |
1100 0111 0000 0001 0000 0001 0110 0000 |

Broadcast |
199.1.1.127 |
1100 0111 0000 0001 0000 0001 0111 1111 |

Simply by examining the subnet broadcast addresses in binary, you can see that they are identical to the subnet numbers, except that all host bits have a value of binary 1 instead of binary 0. (Look for the bold digits in the examples.)

NOTE For those of you who just want to know, to derive the broadcast address using Boolean math, first start with the subnet number and mask, in binary. Invert the mask ("invert" means change all 1s to 0s, and all 0s to 1s). Then do a bitwise Boolean OR between the two 32-bit numbers. (An OR yields a 0 when both bits are 0 and yields a 1 in any other case.) The result is the subnet broadcast address.

You also need to be able to figure out which IP addresses are in a particular subnet and which are not. You already know how to do the hard part of finding that answer. You know that in any subnet, two numbers are reserved. The two reserved numbers are the subnet number itself and the subnet broadcast address. The subnet number is the numerically smallest number in the subnet, and the broadcast address is the numerically largest number. So, the range of valid IP addresses starts with one more than the subnet number and ends with the address that is one less than the broadcast address. It's that simple!

A formal definition of the "algorithm" to find the first and last IP addresses in a subnet after the subnet number and broadcast addresses are known is as follows:

■ For the first valid IP address: Copy the subnet number, but add 1 to the fourth octet.

■ For the last valid IP address: Copy the subnet broadcast address, but subtract 1 from the fourth octet.

■ The range of valid IP addresses starts with the first number and ends with the last. Tables 12-20 through 12-24 summarize the answers for the five examples used in this section.

Octet |
1 |
2 |
3 |
4 |

Address |
130 |
4 |
102 |
1 |

Mask |
255 |
255 |
255 |
0 |

Subnet number |
130 |
4 |
102 |
0 |

First address |
130 |
4 |
102 |
1 |

Broadcast |
130 |
4 |
102 |
255 |

Last address |
130 |
4 |
102 |
254 |

Octet |
1 |
2 |
3 |
4 |

Address |
130 |
4 |
102 |
1 |

Mask |
255 |
255 |
252 |
0 |

Subnet number |
130 |
4 |
100 |
0 |

First address |
130 |
4 |
100 |
1 |

Broadcast |
130 |
4 |
103 |
255 |

Last address |
130 |
4 |
103 |
254 |

Octet |
1 |
2 |
3 |
4 |

Address |
8 |
1 |
4 |
5 |

Mask |
255 |
255 |
0 |
0 |

Subnet number |
8 |
1 |
0 |
0 |

First address |
8 |
1 |
0 |
1 |

Broadcast |
8 |
1 |
255 |
255 |

Last address |
8 |
1 |
255 |
254 |

Octet |
1 |
2 |
3 |
4 |

Address |
199 |
1 |
1 |
100 |

Mask |
255 |
255 |
255 |
0 |

Subnet number |
199 |
1 |
1 |
0 |

First address |
199 |
1 |
1 |
1 |

Broadcast |
199 |
1 |
1 |
255 |

Last address |
199 |
1 |
1 |
254 |

Octet |
1 |
2 |
3 |
4 |

Address |
199 |
1 |
1 |
100 |

Mask |
255 |
255 |
255 |
224 |

Subnet number |
199 |
1 |
1 |
96 |

First address |
199 |
1 |
1 |
97 |

Broadcast |
199 |
1 |
1 |
127 |

Last address |
199 |
1 |
1 |
126 |

Finding the Answers Without Using Binary

You actually can derive the subnet number and broadcast addresses without ever converting to and from binary, or performing Boolean math. Using the binary math required to find the subnet number and broadcast address really does help you understand subnetting to some degree. To get the correct answers faster on the exam, you might want to avoid all the conversions and binary math.

If you can find the subnet number and broadcast address, you easily can find the range of valid addresses in the subnet. So, the easy math described in this section focuses on helping you find the subnet number and broadcast address.

Of all the possible subnet masks, three masks, 255.0.0.0, 255.255.0.0, and 255.255.255.0, use only 255s and 0s. I call these masks "easy" masks because you can find the subnet number and broadcast address easily, without any real math tricks. In fact, some of you might have realized already how to find the answers when an easy mask is used—if so, go ahead and skip to the section titled "Easier Math with Difficult Masks."

In fact, of these three easy masks, 255.0.0.0 does not actually cause any subnetting. So, this section worries about only how to use the two easy masks that can be used for subnetting— 255.255.0.0 and 255.255.255.0.

The process is simple. To find the subnet number, when given an IP address and a mask of 255.255.0.0 or 255.255.255.0, do the following:

Step 1 Copy the first two (mask 255.255.0.0) or first three (mask 255.255.255.0) octets from the original IP address.

Step 2 Write down 0s in the last two octets (mask 255.255.0.0) or the last octet (mask 255.255.255.0).

Yep, it's that easy! Finding the subnet broadcast address is just as easy:

Do the same thing that you did for finding the subnet, but instead of writing down 0s in the last octet or two, write down 255s.

When you know the subnet number and broadcast address, you easily can find the first and last IP addresses in the subnet, using the same simple logic covered earlier:

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

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

When the subnet mask is not 255.255.0.0 or 255.255.255.0, I consider the mask to be a difficult mask. Why is it difficult? Most people cannot easily derive the subnet number and broadcast address without using binary math. You can use the same binary processes exactly the same way, whether the mask is easy or difficult. However, these binary processes take time to do when you cannot use a calculator. So, a quicker method for finding the same answers can help.

The following process helps you find the subnet number and broadcast address without binary math when using a difficult mask. You also can find 25 more problems with solutions on the CD chapter titled, "Subnetting Practice: 25 Subnetting Questions." The process uses something I call a subnet chart, as shown in Table 12-25.

Octet |
1 |
2 |
3 |
4 |

Address | ||||

Mask | ||||

Subnet number | ||||

First address | ||||

Broadcast | ||||

Last address |

With the type of question this shortcut is helping you to answer, the question supplies the address and subnet mask. So, you would simply record the IP address and mask in the table, putting each octet in a different column.

The unusual part of this shortcut begins when you draw a box around the "interesting" octet in the table. I call a mask octet that's not a 255 or a 0 the interesting octet because it is the octet that gives everyone heartburn when first learning subnetting. The box draws attention to the tricky part of the logic used in this shortcut.

For example, consider 130.4.102.1, with mask 255.255.252.0. Because the third octet of the mask is not a 0 or a 255, the third octet is where the interesting part of the shortcut takes place. So, you would create a subnet chart, fill in the address and mask, and draw a box around the third octet, as shown in Table 12-26.

Octet |
1 |
2 |
3 |
4 |

Address |
130 |
4 |
102 |
1 |

Mask |
255 |
255 |
252 |
0 |

Subnet number | ||||

First address | ||||

Broadcast | ||||

Last address |

Next, you should complete the chart for everything to the left of the box. To complete the chart, look at the original IP address octets to the left of the box, and copy those into the subnet, first valid address, broadcast, and last valid address fields. Note that only octets fully to the left of the box should be copied—the interesting octet, which is inside the box, should not be copied. Table 12-27 shows the same example, after this step.

Octet |
1 |
2 |
3 |
4 |

Address |
130 |
4 |
102 |
1 |

Mask |
255 |
255 |
252 |
0 |

Subnet number |
130 |
4 | ||

First address |
130 |
4 | ||

Broadcast |
130 |
4 | ||

Last address |
130 |
4 |

To find the subnet number, you have a couple of steps. The first step is easy. In the subnet number, for any octets fully to the right of the box, write down a 0. That should leave you with one octet of the subnet number missing—the interesting octet.

Next comes the tricky part of this shortcut, which gives you the value of the subnet number in the interesting octet. First, you find what I will call the magic number—which is 256 minus the mask's interesting octet. In this case, you have 256 - 252, or a magic number of 4. Then you find the multiple of the magic number that is the closest to the address's interesting octet, but less than or equal to it. In this example, 100 is a multiple of the magic number (4 * 25), and this multiple is less than or equal to 102. The next-higher multiple of the magic number, which is 104, is, of course, more than 102, so that's not the right number. The multiple of the magic number closest to but not more than the address's interesting octet is the subnet's interesting octet value. The following items summarize this important step:

Step 1 Find the magic number, which is 256 minus the value of the mask's interesting octet.

Step 2 Find the multiple of the magic number that is closest to, but not greater than, the address's interesting octet.

Step 3 Write down that multiple of the magic number as the value of the subnet number's interesting octet.

In this example, simply plug in 100 for the third octet of the subnet number in Table 12-27.

When you know the subnet number, you easily can find the first valid IP address in the subnet:

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

That's all! Table 12-28 shows the same example, but with the subnet number and first valid IP address shown

Octet |
1 |
2 |
3 |
4 |
Comments |

Address |
130 |
4 |
102 |
1 | |

Mask |
255 |
255 |
252 |
0 | |

Subnet number |
130 |
4 |
100 |
0 |
Magic = 256 - 252 = 4; 4 * 25 = 100, closest multiple < 102. |

First address |
130 |
4 |
100 |
1 |
Add 1 to subnet's last octet |

Broadcast |
130 |
4 | |||

Last address |
130 |
4 |

To review, in Table 12-28, the first two octets of the subnet number and first valid address already were filled in because they are to the left of the box around the third octet—the interesting octet, in this case. In the subnet number, the last octet is 0 because it is to the right of the box. To find the interesting octet value, compare the IP address's interesting octet to find the closest multiple of the magic number that's not larger, which is 100 in this case. To get the first valid address, just add 1 to the last octet of the subnet number, giving you 130.4.100.1.

The final step in the shortcut finds the broadcast address, from which you easily can find the last valid address in the subnet. First, in the broadcast address, write down a decimal 255 for all octets to the right of the line or the box. Do not write down a 255 in the octet inside the box. Remember, the octets to the left of the box in the subnet chart already should have been filled in, leaving a single octet with no value—the interesting octet. To fill in the interesting octet of the broadcast address, you again use the magic number. The magic number is 256 minus the mask's interesting octet. In this case, you have 256 - 252, or a magic number of 4. Then you add the magic number to the interesting octet value of the subnet number and subtract 1. The result is the broadcast address's value in the interesting octet. In this case, the value is as follows:

When you know the broadcast address, you easily can find the last valid IP address in the subnet:

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

To summarize the tricky part of this shortcut algorithm:

To find the broadcast address's interesting octet value, take the subnet number's interesting octet value, add the magic number, and subtract 1.

Octet |
1 |
2 |
3 |
4 |
Comments |

Address |
130 |
4 |
102 |
1 | |

Mask |
255 |
255 |
252 |
0 | |

Subnet number |
130 |
4 |
100 |
0 |
Magic = 256 - 252 = 100; 25 x 4 = 100, closest multiple < 102 |

First address |
130 |
4 |
100 |
1 |
Add 1 to fourth octet of subnet |

Broadcast |
130 |
4 |
103 |
255 |
Subnet-interesting-octet + magic - 1 (100 + 4 - 1) |

Last address |
130 |
4 |
103 |
254 |
Subtract 1 from fourth octet |

The entire process for dissecting IP addresses that use difficult masks is now complete. The following list summarizes the tasks in each step:

Step 1 Create and complete the easy parts of a subnet chart.

■ Create a generic subnet chart.

■ Write down the IP address and subnet mask in the first two rows of the chart.

■ Draw a box around the column of the interesting octet.

■ Copy the address octets to the left of the line or the box into the final four rows of the chart.

Step 2 Derive the subnet number and the first valid IP address.

■ Write down 0s in the subnet number for the octets to the right of the box.

■ Find the magic number, which is 256 minus the value of the mask's interesting octet.

■ Find the multiple of the magic number that is closest to but not greater than the address's interesting octet.

■ Write down that multiple of the magic number as the value of the subnet number's interesting octet.

■ 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.

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

■ To find the broadcast address's interesting octet value, take the subnet number's interesting octet value, add the magic number, and subtract 1.

■ 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 will take 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.

Was this article helpful?

## Post a comment