Subnetting /24 and larger network Cisco Forum FAQSubnetting /24 and larger network (#15260) | ||
| Suggested prerequisite reading »Cisco Forum FAQ »I do not understand subnetting? Note: It is highly suggested to read the above prerequisite link before reading this topic due to some terminologies and understanding of the link content. Basically this is the 2nd chapter of the prerequisite link content. Even when you feel you understand Class C network subnetting already and are ready to move up to the next level, it is always a good idea to refresh the concepts and some definitions. The Basic Concept Similar to Class C subnet calculation (/24 or smaller subnet), basic concept applies to Class B (/16 or smaller subnet up to /23) and Class A (/8 or smaller subnet up to /15) subnet calculations. When the first 3 octets in Class C subnet calculation are always constant and only last octet changes (as shown above), the first 2 and last octets in Class B subnet calculation are always constant where only the third octet changes. Similarly, the first and last two octets in Class A subnet calculation are always constant where only the second octet changes. Quick Review Let's review a 192.168.0.0/23 network. As you can see, this is a broadcast network. You can then determine the following 192.168.0.0/23
Understanding /23 Network In 255.255.255.254 (/31), you can see this as a network that consists of two 255.255.255.255 (/32) networks. You can apply the same understanding on looking /23 network. By considering the last octet, you should be able to see 255.255.254.0 (/23) as a network consisting of two 255.255.255.0 (/24) networks. Determine Subnet Mask Format You may wonder how to state the subnet mask format as 255.255.254.0. Determine such basically follows the same understanding as determine 255.255.255.254 (the /31). As you may notice, the 255 represents one of 255 and the 254 represents two of 255. In /31 (255.255.255.254), there are two 255 (two 255.255.255.255). By applying the same understanding, there are two 255 (two 255.255.255.0) in /23 (255.255.254.0). Determine IP Address Number In /24 or smaller networks (within Class C network),
Within Class B network, you have the following
Note that the concept of size doubling still applies in Class B network as in Class C network as mentioned. As illustrations, there are 2 of /24 within /23; 2 of /23 within /22; and 2 of /18 within /17 networks. Implementing /23 Network Let's say an organization decide to use 192.168.0.0/23 as a single subnet without subnetting it to smaller subnets. Let's say the gateway IP address would be 192.168.0.1. Some hosts within the subnet will have the following network info 192.168.0.34/23
192.168.1.0/23
Octet and Subnet Calculation As with /24 and smaller subnets, we keep referring to octets when working with /23 or larger subnets. As illustration, let's say you have 192.168.65.27/22 network. You need to determine the following * the network range * the IP address order number You need to see the /22 network as larger /16 network (the whole 192.168.0.0 Class B network). /22 equals to 255.255.252.0. The 252 means that there are four /24 networks. On the 1st /22 network, the 3rd octet range would be .0 to .3. Here is the breakdown on the 1st network
The remaining networks would be the following
As you can see, the 192.168.65.27/22 within the 192.168.64.0/22 network with order number of 283. Some Tips and Tricks 1. Convert CIDR Subnet Mask Format To Dotted 4-Tuple Format Note that when deals with /24 network or longer prefix, you only focus on the last octet. With Class B network, it is similar concept with focusing on the 3rd octet. Class B network is between /16 and /23 CIDR. As mentioned, you only focus on the 3rd octet where the 1st two and last octets are constant. In other word, only the 3rd octet is changing as follows. /24: 255.255.255.0 /23: 255.255.254.0 /22: 255.255.252.0 /21: 255.255.248.0 /20: 255.255.240.0 /19: 255.255.224.0 /18: 255.255.192.0 /17: 255.255.128.0 /16: 255.255.0.0 With Class B, there is a similar formula to convert CIDR format into dotted 4-tuple format by holding on these * The "longest" Class B network (the /24) always has 255 as the 3rd octet * The /24 always has a single Class C network * The next larger Class B network is always double size of the current Class B network. In other word, the next larger Class B network has double quantities of Class C network than the current Class B network * The 1st two octet are always 255 and the last octet is always 0 where the 3rd octet is changing For illustration, you like to convert /18 CIDR into dotted 4-tuple format. The 3rd octet on the Class B network:
Since the 1st two octet are always 255 and the last octet is always 0, then the /18 CIDR is equal to 255.255.192.0 subnet mask. 2. Find Out IP Address Quantity Within Specific Subnet There is also similar formula like the one with the Class C network subnetting (256 - The 3rd Octet) x 256 = IP Address Quantity Within Specific Subnet Illustration
3. Reverse Bit Correlation Between Subnet Mask and Number of IP Address Let's visit the binary format of Class B network
There is similar correlation between subnet mask and IP address quantity within the subnet on Class B network as on the Class C network. You can apply this correlation to find out smaller subnet quantity when subnetting Class B network into smaller Class C network. Here is the process. * Find out the number of CIDR form of the smaller subnet, i.e. /n * Take n as the power of two as 2^n * Calculate 2^n * The 2^n represents the number of /n subnet will be when subnetting a Class B network into /n subnet Let's have an illustration. Say you have a full Class B network and you subnet it into smaller /28 network. You like to know how many /28 subnets will be, assuming you can use Subnet Zero. Recall the /24 subnetting process where you only focus on the last octet. With Class B subnetting process, you only focus on the last two octets; the 3rd and the 4th. The /28 network in binary format has the 1st 28 bits set to one where the remaining 4 bits are set to zero. Let's remove the 1st two octets and just focus on the last two octets. When only focusing on the last two octets, there are the 1st 12 bits set to one where the remaining 4 bits are set to zero. Take the 1st bits that are set to one, which is 12; as the power of two as 2^12. The 2^12 equals to 4096. This 4096 represents the number of /28 subnet will be when subnetting a Class B network into /28 subnet. Let's calculate how many /28 subnet will be within full Class B network using different method. As you may recall, there are 16 of /28 subnets within Class C network. Using the concept of size doubling, then you have the following table.
As to find out quickly the number of IP address within the a Class B network, you are using the same concept as dealing with the Class C network; which is based on the number of bits that are set to zero. Following is an illustration. When you have let's say /19 network; there are the 1st 19 bits set to one and the remaining 13 bits set to zero. Take this number 13 as the power of two as 2^13. The 2^13 = 8192. This 8192 represents the number of IP addresses within the /19 network. As you may notice, the illustration assumes you can use Subnet Zero. 4. Determine Smaller Subnet Range Problem 1: Let's say you have a full Class B network, which is 172.16.0.0/16 network. You subnet it into smaller /28 network. You like to find out how the 897th of /28 subnet looks like. Here are the process * Find out how many subnets will be if the bigger subnet is /24 * Take the number of the subnets and assigns it into m * Take a number n as of n-th of the smaller subnet * Calculate (n - 1) / m * When the calculation result is a round number, such number represents the 3rd octet of the n-th subnet. In addition, the 4th octet equals to 0 * The 1st and 2nd octets are always constants * The IP address represented as such 1st, 2nd, 3rd, and 4th octets is the Network ID * The Network Broadcast last octet = m - 1 Using the illustration, you need to find out how many /28 subnets within /24 network. As you may recall, there are 16 of /28 subnets within /24 network. You are finding out the 897th of the /28 subnet range is. Therefore n = 897, m = 16 When you calculate (n - 1) / m, you have (n - 1) / m = (897 - 1) / 16 = 56 Since 56 is a round number, then the following two occur * The 56 represents as the 3rd octet * The 4th octet equals to 0 The 1st and 2nd octets are always constant. As a result, the IP address you have is 172.16.56.0; which is also the Network ID IP address. As to the Network Broadcast, Network Broadcast IP address last octet = m - 1 = 16 - 1 = 15 The 897th /28 subnet itself look like the following 172.16.56.0/28 = 172.16.56.0 - 172.16.56.15 where
Problem 2: Let's say you have a full Class B network, which is 172.16.0.0/16 network. You subnet it into smaller /28 network. You like to find out how the 3117th of /28 subnet looks like. There is a similar process as previous problem, with some additional steps to deal with non-round number. * Find out how many subnets will be if the bigger subnet is /24 * Take the number of the subnets and assigns it into m * Take a number n as of n-th of the smaller subnet * Calculate (n - 1) / m * When the calculation result is not a round number, you only consider the round number part and remove the fraction * The round part represents the 3rd octet * Multiple the round number part (the 3rd octet) by m * Add the result by 1 * Assign p as the final result, where p = (the 3rd octet x m) + 1 * The result of (n - p) x m represents the Network ID IP address last octet * The result of (Network ID IP address last octet + (m - 1)) represents the Network Broadcast IP address last octet * The 1st and 2nd octets are always constants * The IP address represented as such 1st, 2nd, 3rd, and 4th (last) octets is the n-th of how the smaller subnet look like Using the illustration, you need to find out how many /28 subnets within /24 network. As you may recall, there are 16 of /28 subnets within /24 network. You are finding out the 3117th of the /28 subnet range is. Therefore n = 3117, m = 16 (n - 1) / m = (3117 - 1) / 16 = 3116/16 = 194.75 The 194.75 is not a round number, so we only consider the round part and remove the fraction. In other word, we take the 194 only. This 194 round number represents the 3rd octet. p = (the 3rd octet x m) + 1 = (194 x 16) + 1 = 3104 + 1 = 3105 (n - p) x m = (3117 - 3105) x 16 = 192 This 192 represents the last octet of the Network ID IP address. In other word, 3117th subnet Network ID IP address: 172.16.194.192/28 Network ID last octet + (m - 1) = 192 + (16 - 1) = 192 + 15 = 207 This 207 represents the last octet of the Network Broadcast IP address. In other word, 3117th subnet Network Broadcast IP address: 172.16.194.207/28 Since you now have both Network ID and Network Broadcast IP addresses, then the 3117th /28 subnet off the 172.16.0.0/16 looks like the following. 3117th subnet: 172.16.194.192/28 = 172.16.194.192 - 172.16.194.207 where
Note 1. These two problems assume that you can use Subnet Zero. If you cannot use Subnet Zero, you need to modify the formula although the concept is the same. 2. The p = 3105 represents the 3105-th subnet. In other words, p = n = 3105 in case you like to find out how the 3105th /28 subnet range is. 3. From previous note, you can then apply the formula or process within Problem 2 into Problem 1 with the same result. In other words, Problem 2 formula or process is in general form compared to the Problem 1. 5. Convert Dotted 4-Tuple Subnet Mask Format Into CIDR Format Let's say you have 255.255.192.0 subnet mask. You like to know how the subnet mask looks in CIDR format. You are using the similar process as in the Class C network with the difference of working on the 3rd octet only where the 1st, 2nd, and 4th octets are constant. Following are the steps when deals with Class B subnetting: * Focus only on the 3rd octet * Set the octet as the last octet of a /24 network subnet mask where 1st, 2nd, and 3rd octets are 255 * Determine IP address quantity within the new /24 network subnet * Find out n where 2^n = IP address quantity within the subnet * Subtract 8 by n * Take the subtraction result as additional set-to-one bits to the 1st 16 bits set to one of the full Class B subnet mask * Add the total number of bits set to one * This total number represents the CIDR format Let's use an illustration to convert the 255.255.192.0 into CIDR format. Focus only on the 3rd octet, which is the 192. Set the 192 as the last octet of a /24 network subnet mask as 255.255.255.192 When you build up your own table (or memorize it), you know there are 64 IP addresses within 255.255.255.192 subnet mask. Find out n where 2^n = 64 By simple calculation (and probably some trial and error), you find that n = 6 Recall the previous discussion that in binary format, all the bits within 1st and 2nd octet of Class B network are set to one. Similarly all bits within the last octet are set to zero. Only bits within the 3rd octet are changing. Let's focus on the bits within this 3rd octet. As you know, there are 8 bits within the 3rd octet. In /16 network (the full Class B network), all of those 8 bits within the 3rd octet are set to zero. With the value of n = 6, this means that there are 6 last bits set to zero within the 3rd octet itself. Subtract 8 by 6 to have 2. This 2 represents the remaining 2 bits set to one; which are also the 1st 2 bits within those 8 bits. Take these 2 bits as additional set-to-one bits into the 1st 16 bits of the full Class B subnet mask. The full Class B subnet mask has the 1st 16 bits set to one. With additional 2 bits set to one, there are total of the 1st 18 bits set to one. Therefore 255.255.192.0 network has the 1st 18 bits set to one (16 + additional 2) where the remaining 14 bits are set to zero. Since CIDR format bases on the 1st set-to-one bits, the 255.255.192.0 subnet mask is equal to /18 CIDR. by aryoba | ||