Sie sind auf Seite 1von 9

# Lesson 30 - IPv4 Subnetting - Practice

In the previous post, I showed you three major rules used in calculating subnets. This knowledge can only be verified in practice though. Let me show you a few examples related to subnet calculations. I hope that looking at this topic from different angles is going to help you understand the concept better and feel confident when planning your IP addressing scheme. The first four questions are merely appetizers for a bigger dish: VLSM. I am going to refer to my previous post's rules while answering the questions (rule 1, rule 2 and rule 3). If you still do not remember the weights of all bits, you may consider using this little aid presented below (pic. 1) while calculating subnets, and converting binary network masks into decimal values. Pic. 1- Subnet Calculation Aid.

This tool is useful before you remember all the weights from left to right and right to left. Pic. 2 - Example of Subnet Binary-to-Decimal Conversion.

Question 1 Given the prefix 192.168.1.0/24, what should be the length of subnet mask allowing up to 9 subnets? Answer 1 The address belongs to the class C and uses its default network mask. That leaves us with 8 bits to play with (the last byte). Before we change anything, our address and network mask converted into the binary notation look like shown below (pic. 3). Pic. 3 - 192.168.1.0/24 in Binary.

In order to create 9 subnets we must extend the existing length of the network mask by 4 bits which allows up to 16 subnets (use calculation aid in pic. 1). If I tried to extend it by 3 bits only, the maximum subnets allowed would be only 8 subnets (rule 2 in lesson 29). So, I must use 4 bits and the result is: 192.168.1.0/28 (192.168.1.0 255.255.255.240). Pic. 4 - The Answer to Question 1

Since we must determine the the subnet in which the host resides (177 = 10110001), the host portion of the prefix (host bits reside in the last byte) must all be set to '0'. The byte value with the host zeroed is the address of the subnet (rule 1 pkt.1 in lesson 29). This is the result: Pic. 6 - Host Bits Zeroed = Subnet Address.

The second part of the question relates to the broadcast address of the subnet. As you remember, in order to obtain the broadcast address, you must put '1' on all host bits of the subnet/network. The subnet has already been determined (pic. 6), so let's put '1' on all bits of the host portion: .10110111 .10110000 = 176 <- subnet address ..00000111 = 7 <- host bits set to '1' In decimal it is: 176 + 7 = 183 The broadcast address is: 183. The below picture illustrates it using binary numbers. Pic. 7 - Host Bits Set to '1' = Broadcast Address.

Question 3 Given the prefix 172.16.0.0/17, how many subnets can you create? Answer3 This is a bit tricky isn't it? In order to answer this question, you don't need any calculator, paper or pen. You must trust the rule 2 in lesson 29. The address and its network mask (called prefix) converted into binary look like presented below: Pic. 8 - The Number of Subnets for 172.16.0.0/17

As you see the number of bits we have extended the class B address is: 1. So, the number of subnets we can create with it is: 2 subnets, since this subnet bit can be either 1 or 0. Pic. 9 - Questions 3 Answer

Question 4 What length of network mask would be the most optimal for router's point-to-point connection? Answer 4 The key to this question is to understand that point-to-point connection needs only 2 host addresses (two points that are connected together). Knowing this, the rest is a piece of cake. We use rule 3 inlesson 29 to determine the length of the network mask that allows 2 host addresses. Check out the picture 10. Pic. 10 - Calculating Point-to-Point Connection Host Addresses.

## Icons designed by: Andrzej Szoblik - http://www.newo.pl

As always, if you know the rules and the method, it is going to be easy thing to do. The rules have been discussed in lesson 29, so let me go about this kind of task now.

NOTICE! If your design looks similar to mine (optimizing addresses to the number of host required) you must start the calculation with the largest number of host addresses requirement and work your way down to the least number of host addresses.

This is one of the many methods available. It helps quickly calculate all subnet ranges without using calculator (pen and a piece of paper should do). Step 1 Determine the length of the network mask for each subnet in question. Keep in mind we focus in on the last byte of IP address 192.168.1.0 (8 bits). The first three bytes do not change! Subnet 1 = 46 Host Addresses In order to allocate 46 addresses we must use 6 host bits. Why? 5 bits will not be enough as 2 raised to the power of 5 is 32. Also, we must decrement two addresses for subnet and broadcast addresses. So using 5 bits would give you only 30 host addresses. Here we go with 6 bits then: Pic. 12 - Subnet 1 in Binary.

Subnet 2 = 16 Host Addresses We must repeat the same math for the remaining subnets. How many host bits to allocate for 16 hosts (subnet 2)? We must use 5 bits. In case we wanted to use only 4 host bits, the maximum number of hosts is 14 (16 - 2). Pic. 13 - Subnet 2 in Binary

Subnet 3 = 10 Host Addresses We continue using the same logic. Pic. 14 - Subnet 3 in Binary.

## Subnet 4 and 5 = 2 Host Addresses Each

On point-to-point links only 2 host addresses area needed. The most optimal network mask is / 30(30 bits). Pic. 15 - Subnet 4 and 5 in Binary.