This post provides information concerning the following topics:

In the previous post, we looked at how IPv4 addressing works, and the idea that it is possible to break a single large networks into multiple smaller networks for more flexibility in your network design. This article shows you how to perform this task. This is known as *subnetting*.

Some students (and working IT professionals) are intimidated by subnetting because it deals with math; more specifically, binary math. While some people pick this up quickly, some take more time than others. And this is OK. Just keep practicing. The ability to subnet IPv4 addresses is a key skill that is required to pass the CCNA 200-301 exam. This makes some people nervous during an exam. Just remember that this is math, and therefore there has to be an absolute correct answer. If you follow the steps, you will come up with the correct answer. I always tell my students that subnetting and working with binary should be the easiest questions you have on an exam, because you know that if you follow the steps you will arrive at the correct answer. Keep calm, remember the rules, and you will be fine. After all, it’s just math, and math is easy.

Remember from the previous article that there are network bits (N bits) and host bits (H bits) in an IPv4 address and they follow a specific pattern:

Octet # | 1 | 2 | 3 | 4 |

Class A Address | N | H | H | H |

Class B Address | N | N | H | H |

Class C Address | N | N | N | H |

All 0s in host portion = network or subnetwork address

All 1s in host portion = broadcast address

Combination of 1s and 0s in host portion = valid host address

To subnet a network address space, we will use the following formulae:

2^{N} (where N is equal to the number of network bits borrowed) | Number of total subnets created |

2^{H} (where H is equal to the number of host bits) | Number of total hosts per subnet |

2^{H} – 2 | Number of valid hosts per subnet |

## Subnetting a Class C Network Using Binary

You have an address of 192.168.100.0 /24. You need nine subnets. What is the IP plan of network numbers, broadcast numbers, and valid host numbers? What is the subnet mask needed for this plan?

You cannot use N bits, only H bits. Therefore, ignore 192.168.100. These numbers cannot change. You only work with host bits. You need to borrow some host bits and turn them into network bits (or in this case, subnetwork bits; I use the variable N to refer to both network and subnetwork bits).

**Step 1.** Determine how many H bits you need to borrow to create nine valid subnets.

2^{N} ≥ 9

N = 4, so you need to borrow 4 H bits and turn them into N bits.

Start with 8 H bits | HHHHHHHH |

Borrow 4 bits | NNNNHHHH |

**Step 2.** Determine the first subnet in binary.

0000HHHH | |

00000000 | All 0s in host portion = subnetwork number |

00000001 | First valid host number |

00000010 | Second valid host number |

00000011 | Third valid host number |

… | |

00001110 | Last valid host number |

00001111 | All 1s in host portion = broadcast number |

**Step 3.** Convert binary to decimal.

00000000 = 0 | Subnetwork number |

00000001 = 1 | First valid host number |

00000010 = 2 | Second valid host number |

00000011 = 3 | Third valid host number |

. … | |

00001110 = 14 | Last valid host number |

00001111 = 15 | All 1s in host portion = broadcast number |

**Step 4.** Determine the second subnet in binary.

0001HHHH | |

00010000 | All 0s in host portion = subnetwork number |

00010001 | First valid host number |

00010010 | Second valid host number |

… | |

00011110 | Last valid host number |

00011111 | All 1s in host portion = broadcast number |

**Step 5.** Convert binary to decimal.

00010000 = 16 | Subnetwork number |

00010001 = 17 | First valid host number |

… | |

00011110 = 30 | Last valid host number |

00011111 = 31 | All 1s in host portion = broadcast number |

**Step 6.** Create an IP plan table.

Subnet | Network Number | Range of Valid Hosts | Broadcast Number |

1 | 0 | 1–14 | 15 |

2 | 16 | 17–30 | 31 |

3 | 32 | 33–46 | 47 |

Notice a pattern? Counting by 16.

**Step 7.** Verify the pattern in binary. (The third subnet in binary is used here.)

0010HHHH | Third subnet |

00100000 = 32 | Subnetwork number |

00100001 = 33 | First valid host number |

00100010 = 34 | Second valid host number |

… | |

00101110 = 46 | Last valid host number |

00101111 = 47 | Broadcast number |

**Step 8.** Finish the IP plan table.

Subnet | Network Address (0000) | Range of Valid Hosts (0001–1110) | Broadcast Address (1111) |

1 (0000) | 192.168.100.0 | 192.168.100.1–192.168.100.14 | 192.168.100.15 |

2 (0001) | 192.168.100.16 | 192.168.100.17–192.168.100.30 | 192.168.100.31 |

3 (0010) | 192.168.100.32 | 192.168.100.33–192.168.100.46 | 192.168.100.47 |

4 (0011) | 192.168.100.48 | 192.168.100.49–192.168.100.62 | 192.168.100.63 |

5 (0100) | 192.168.100.64 | 192.168.100.65–192.168.100.78 | 192.168.100.79 |

6 (0101) | 192.168.100.80 | 192.168.100.81–192.168.100.94 | 192.168.100.95 |

7 (0110) | 192.168.100.96 | 192.168.100.97–192.168.100.110 | 192.168.100.111 |

8 (0111) | 192.168.100.112 | 192.168.100.113–192.168.100.126 | 192.168.100.127 |

9 (1000) | 192.168.100.128 | 192.168.100.129–192.168.100.142 | 192.168.100.143 |

10 (1001) | 192.168.100.144 | 192.168.100.145–192.168.100.158 | 192.168.100.159 |

11 (1010) | 192.168.100.160 | 192.168.100.161–192.168.100.174 | 192.168.100.175 |

12 (1011) | 192.168.100.176 | 192.168.100.177–192.168.100.190 | 192.168.100.191 |

13 (1100) | 192.168.100.192 | 192.168.100.193–192.168.100.206 | 192.168.100.207 |

14 (1101) | 192.168.100.208 | 192.168.100.209–192.168.100.222 | 192.168.100.223 |

15 (1110) | 192.168.100.224 | 192.168.100.225–192.168.100.238 | 192.168.100.239 |

16 (1111) | 192.168.100.240 | 192.168.100.241–192.168.100.254 | 192.168.100.255 |

Quick Check | Always an even number |
| Always an odd number |

Use any nine subnets—the rest are for future growth.

**Step 9.** Calculate the subnet mask. The default subnet mask for a Class C network is as follows:

Decimal | Binary |

255.255.255.0 | 11111111.11111111.11111111.00000000 |

1 = Network or subnetwork bit

0 = Host bit

You borrowed 4 bits; therefore, the new subnet mask is the following:

11111111.11111111.11111111.11110000 | 255.255.255.240 |

You subnet a Class B network or a Class A network using exactly the same steps as for a Class C network; the only difference is that you start with more H bits.

## Subnetting a Class B Network Using Binary

You have an address of 172.16.0.0 /16. You need nine subnets. What is the IP plan of network numbers, broadcast numbers, and valid host numbers? What is the subnet mask needed for this plan?

You cannot use N bits, only H bits. Therefore, ignore 172.16. These numbers cannot change.

**Step 1.** Determine how many H bits you need to borrow to create nine valid subnets.

2^{N} ≥ 9

N = 4, so you need to borrow 4 H bits and turn them into N bits.

Start with 16 H bits | HHHHHHHHHHHHHHHH (Remove the decimal point for now) |

Borrow 4 bits | NNNNHHHHHHHHHHHH |

**Step 2.** Determine the first valid subnet in binary (without using decimal points).

0000HHHHHHHHHHHH | |

0000000000000000 | Subnet number |

0000000000000001 | First valid host |

… | |

0000111111111110 | Last valid host |

0000111111111111 | Broadcast number |

**Step 3.** Convert binary to decimal (replacing the decimal point in the binary numbers).

00000000.00000000 = 0.0 | Subnetwork number |

00000000.00000001 = 0.1 | First valid host number |

… | |

00001111.11111110 = 15.254 | Last valid host number |

00001111.11111111 = 15.255 | Broadcast number |

**Step 4.** Determine the second subnet in binary (without using decimal points).

0001HHHHHHHHHHHH | |

0001000000000000 | Subnet number |

0001000000000001 | First valid host |

… | |

0001111111111110 | Last valid host |

0001111111111111 | Broadcast number |

**Step 5.** Convert binary to decimal (returning the decimal point in the binary numbers).

00010000.00000000 = 16.0 | Subnetwork number |

00010000.00000001 = 16.1 | First valid host number |

… | |

00011111.11111110 = 31.254 | Last valid host number |

00011111.11111111 = 31.255 | Broadcast number |

**Step 6.** Create an IP plan table.

Subnet | Network Number | Range of Valid Hosts | Broadcast Number |

1 | 0.0 | 0.1–15.254 | 15.255 |

2 | 16.0 | 16.1–31.254 | 31.255 |

3 | 32.0 | 32.1–47.254 | 47.255 |

Notice a pattern? Counting by 16.

**Step 7.** Verify the pattern in binary. (The third subnet in binary is used here.)

0010HHHHHHHHHHHH | Third valid subnet |

00100000.00000000 = 32.0 | Subnetwork number |

00100000.00000001 = 32.1 | First valid host number |

… | |

00101111.11111110 = 47.254 | Last valid host number |

00101111.11111111 = 47.255 | Broadcast number |

**Step 8.** Finish the IP plan table.

Subnet | Network Address (0000) | Range of Valid Hosts (0001–1110) | Broadcast Address (1111) |

1 (0000) | 172.16.0.0 | 172.16.0.1–172.16.15.254 | 172.16.15.255 |

2 (0001) | 172.16.16.0 | 172.16.16.1–172.16.31.254 | 172.16.31.255 |

3 (0010) | 172.16.32.0 | 172.16.32.1–172.16.47.254 | 172.16.47.255 |

4 (0011) | 172.16.48.0 | 172.16.48.1–172.16.63.254 | 172.16.63.255 |

5 (0100) | 172.16.64.0 | 172.16.64.1–172.16.79.254 | 172.16.79.255 |

6 (0101) | 172.16.80.0 | 172.16.80.1–172.16.95.254 | 172.16.95.255 |

7 (0110) | 172.16.96.0 | 172.16.96.1–172.16.111.254 | 172.16.111.255 |

8 (0111) | 172.16.112.0 | 172.16.112.1–172.16.127.254 | 172.16.127.255 |

9 (1000) | 172.16.128.0 | 172.16.128.1–172.16.143.254 | 172.16.143.255 |

10 (1001) | 172.16.144.0 | 172.16.144.1–172.16.159.254 | 172.16.159.255 |

11 (1010) | 172.16.160.0 | 172.16.160.1–172.16.175.254 | 172.16.175.255 |

12 (1011) | 172.16.176.0 | 172.16.176.1–172.16.191.254 | 172.16.191.255 |

13 (1100) | 172.16.192.0 | 172.16.192.1–172.16.207.254 | 172.16.207.255 |

14 (1101) | 172.16.208.0 | 172.16.208.1–172.16.223.254 | 172.16.223.255 |

15 (1110) | 172.16.224.0 | 172.16.224.1–172.16.239.254 | 172.16.239.255 |

16 (1111) | 172.16.240.0 | 172.16.240.1–172.16.255.254 | 172.16.255.255 |

Quick Check | Always in form even #.0 |
| Always odd #.255 |

Use any nine subnets—the rest are for future growth.

**Step 9.** Calculate the subnet mask. The default subnet mask for a Class B network is as follows:

Decimal | Binary |

255.255.0.0 | 11111111.11111111.00000000.00000000 |

1 = Network or subnetwork bit

0 = Host bit

You borrowed 4 bits; therefore, the new subnet mask is the following:

11111111.11111111.11110000.00000000 | 255.255.240.0 |

## Binary ANDing

Binary ANDing is the process of performing multiplication to two binary numbers. In the decimal numbering system, ANDing is addition: 2 and 3 equals 5. In decimal, there are an infinite number of answers when ANDing two numbers together. However, in the binary numbering system, the AND function yields only two possible outcomes, based on four different combinations. These outcomes, or answers, can be displayed in what is known as a truth table:

0 and 0 = 0

1 and 0 = 0

0 and 1 = 0

1 and 1 = 1

You use ANDing most often when comparing an IP address to its subnet mask. The end result of ANDing these two numbers together is to yield the network number of that address.

Question 1

What is the network number of the IP address 192.168.100.115 if it has a subnet mask of 255.255.255.240?

Answer

**Step 1.** Convert both the IP address and the subnet mask to binary:

192.168.100.115 = 11000000.10101000.01100100.01110011 255.255.255.240 = 11111111.11111111.11111111.11110000

**Step 2.** Perform the AND operation to each pair of bits—1 bit from the address ANDed to the corresponding bit in the subnet mask. Refer to the truth table for the possible outcomes.

192.168.100.115 = 11000000.10101000.01100100.01110011 255.255.255.240 = 11111111.11111111.11111111.11110000 ANDed result = 11000000.10101000.01100100.01110000

**Step 3.** Convert the answer back into decimal:

11000000.10101000.01100100.01110000 = 192.168.100.112 The IP address 192.168.100.115 belongs to the 192.168.100.112 network when a mask of 255.255.255.240 is used.

Question 2

What is the network number of the IP address 192.168.100.115 if it has a subnet mask of 255.255.255.192?

(Notice that the IP address is the same as in Question 1, but the subnet mask is different. What answer do you think you will get? The same one? Let’s find out!)

Answer

**Step 1.** Convert both the IP address and the subnet mask to binary:

192.168.100.115 = 11000000.10101000.01100100.01110011 255.255.255.192 = 11111111.11111111.11111111.11000000

**Step 2.** Perform the AND operation to each pair of bits—1 bit from the address ANDed to the corresponding bit in the subnet mask. Refer to the truth table for the possible outcomes.

192.168.100.115 = 11000000.10101000.01100100.01110011 255.255.255.192 = 11111111.11111111.11111111.11000000 ANDed result = 11000000.10101000.01100100.01000000

**Step 3.** Convert the answer back into decimal:

11000000.10101000.01100100.01110000 = 192.168.100.64 The IP address 192.168.100.115 belongs to the 192.168.100.64 network when a mask of 255.255.255.192 is used.

### So Why AND?

Good question. The best answer is to save you time when working with IP addressing and subnetting. If you are given an IP address and its subnet, you can quickly find out what subnetwork the address belongs to. From here, you can determine what other addresses belong to the same subnet. Remember that if two addresses are in the same network or subnetwork, they are considered to be *local* to each other and can therefore communicate directly with each other. Addresses that are not in the same network or subnetwork are considered to be *remote* to each other and must therefore have a Layer 3 device (like a router or Layer 3 switch) between them to communicate.

Question 3

What is the broadcast address of the IP address 192.168.100.164 if it has a subnet mask of 255.255.255.248?

Answer

**Step 1.** Convert both the IP address and the subnet mask to binary:

192.168.100.164 = 11000000.10101000.01100100.10100100 255.255.255.248 = 11111111.11111111.11111111.11111000

**Step 2.** Perform the AND operation to each pair of bits—1 bit from the address ANDed to the corresponding bit in the subnet mask. Refer to the truth table for the possible outcomes:

192.168.100.164 = 11000000.10101000.01100100.10100100 255.255.255.248 = 11111111.11111111.11111111.11111000 ANDed result = 11000000.10101000.01100100.10100000 = 192.168.100.160 (Subnetwork #)

**Step 3.** Separate the network bits from the host bits:

255.255.255.248 = /29. The first 29 bits are network/ subnetwork bits; therefore,000. The last 3 bits are host bits.11000000.10101000.01100100.10100

**Step 4.** Change all host bits to 1. Remember that all 1s in the host portion are the broadcast number for that subnetwork.

11111000000.10101000.01100100.10100

**Step 5.** Convert this number to decimal to reveal your answer:

11000000.10101000.01100100.10100111 = 192.168.100.167 The broadcast address of 192.168.100.164 is 192.168.100.167 when the subnet mask is 255.255.255.248.

### Shortcuts in Binary ANDing

Remember that I said ANDing is supposed to save you time when working with IP addressing and subnetting? Well, there are shortcuts when you AND two numbers together:

An octet of all 1s in the subnet mask results in the answer being the same octet as in the IP address.

An octet of all 0s in the subnet mask results in the answer being all 0s in that octet.

Question 4

To what network does 172.16.100.45 belong, if its subnet mask is 255.255.255.0?

Answer

172.16.100.0

Proof

**Step 1.** Convert both the IP address and the subnet mask to binary:

172.16.100.45 = 10101100.00010000.01100100.00101101 255.255.255.0 = 11111111.11111111.11111111.00000000

**Step 2.** Perform the AND operation to each pair of bits—1 bit from the address ANDed to the corresponding bit in the subnet mask. Refer to the truth table for the possible outcomes.

172.16.100.45 = 10101100.00010000.01100100.00101101 255.255.255.0 = 11111111.11111111.11111111.00000000 10101100.00010000.01100100.00000000 = 172.16.100.0

Notice that the first three octets have the same pattern both before and after they were ANDed. Therefore, any octet ANDed to a subnet mask pattern of 255 is itself! Notice that the last octet is all 0s after ANDing. But according to the truth table, anything ANDed to a 0 is a 0. Therefore, any octet ANDed to a subnet mask pattern of 0 is 0! You should only have to convert those parts of an IP address and subnet mask to binary if the mask is not 255 or 0.

Question 5

To what network does 68.43.100.18 belong if its subnet mask is 255.255.255.0?

Answer

68.43.100.0 (There is no need to convert here. The mask is either 255s or 0s.)

Question 6

To what network does 131.186.227.43 belong if its subnet mask is 255.255.240.0?

Answer

Based on the two shortcut rules, the answer should be

131.186.???.0

So now you only need to convert one octet to binary for the ANDing process:

227 = 11100011

240 = 11110000

11100000 = 224

Therefore, the answer is 131.186.224.0.