Subnetting An IP Address

Transcription

Expert Reference Series of White PapersSubnetting an IPAddress1-800-COURSESwww.globalknowledge.com

Subnetting an IP AddressAlan Thomas, CCNA, CCSI, Global Knowledge InstructorIntroductionThe process of subnetting is both a mathematical process and a network design process. Mathematics drives howsubnets are calculated, identified, and assigned. The network design and requirements of the organization drivehow many subnets are needed and how many hosts an individual subnet needs to support. Binary basics and IPv4address structure were covered in part one of this two-part paper.This paper focuses on the process rules and helpful hints for learning to subnet an IPv4 address. It covers thefollowing topics:1.2.3.4.5.6.7.Need for subnetsProcess for subnettingFormulas for subnet calculationExamples for putting everything togetherVariable Length Subnet Mask (VLSM)Determine the subnet, usable range of host addresses, and broadcast address for a given host.Helpful tablesNote: Throughout this document, the term IP address refers to an IPv4 address. This document does not includeIPv6.IP Address Construct and RepresentationAn IP address is a thirty-two-bit binary number. The thirty-two bits are separated into four groups of eight bitscalled octets. However, an IP address is represented as a dotted decimal number (for example: 205.57.32.9).The Need for SubnetsWhat exactly is subnetting? Subnetting is taking an IP network and subdividing it into smaller IP networks calledsubnetworks, or subnets. Every IP network, or subnet, is a broadcast domain. A broadcast domain is a collectionof devices that can receive broadcast traffic from each other. Broadcast traffic is traffic that is delivered to everydevice on the network.Having a single broadcast domain, or a "flat network," presents two main problems.1. In a single large broadcast domain, there is a large amount of broadcast traffic. Broadcast traffic is veryinefficient and consumes large amounts of resources, such as bandwidth, processor cycles, and memory.In fact, enough broadcast traffic on a network can cause other applications, such as email, wordprocessors, and spreadsheets, to be negatively impacted.2. When all devices are part of the same broadcast domain, there are no protocol boundaries betweendevices, so implementing security policies is difficult. In other words, there is no easy way to protect onedevice from another device without using host-based mechanisms, such as host-based firewalls,permissions, rights, and anti-virus. These methods serve a valuable purpose, but they are not veryefficient, and they can degrade performance of the host.Copyright 2014 Global Knowledge Training LLC. All rights reserved.2

The solution to these problems is to break the single large broadcast domain into several smaller broadcastdomains. By doing this, the number of devices connected to each broadcast domain is smaller. This reduces theamount of broadcast traffic, improving the performance of all devices on the network. Additionally, a boundarybetween devices is created, which greatly improves and simplifies the implementation of security policies.As an analogy, imagine a single room, and in this room are five different groups of people; one group in eachcorner and one group in the center. Each group of people has a microphone and is discussing a different topic. Ifyou were a member of one of the groups, picture how difficult it would be to hear people in your group,concentrate on your topic, and share confidential information.Now imagine the single room being separated into five smaller rooms. Each group now has its own room with adoor and can communicate without competing with the other groups. Each person can hear and concentratebetter and more easily keep confidential information within the group.The concept of dividing a large room into smaller rooms is the same as the concept of dividing a large broadcastdomain (IP network) into smaller broadcast domains (subnets).The Subnetting ProcessIn order to create IP subnets, host bits are changed to network bits. This is often called borrowing bits. It is alsooften referred to as taking host bits and giving them to the network. By borrowing host bits, more IP subnets arecreated, but each subnet can support fewer hosts.To change a host bit to a network bit, the subnet mask must be changed. Remember, a binary 0 in the subnetmask means that bit is part of the host portion of an IP address. A binary 1 in the subnet mask means that bit ispart of the network portion of an IP address. So, to change a bit from a host bit to a network bit, the binaryvalue of the bit must be changed from 0 to 1 in the subnet mask.When calculating subnets, the following process should be used. Each step of the process will describe in detaillater in this paper.1. Determine the assigned IP address space.2. Determine the number of subnets required based on the design of the existing network, along with thestructure of the organization. It is common to assign a subnet to each department within theorganization.3. Based on the class of the IP address space and the number of required subnets, determine how manyhost bits need to be borrowed. Also determine how many hosts each subnet can support.4. Calculate the decimal value and prefix value of the new subnet mask.5. Apply the subnet mask to the assigned IP address space to calculate the network address of the newpossible subnets, the broadcast address for each possible subnet, and the range of usable IP addresses ineach possible subnet.6. Assign IP addresses to all devices, including router interfaces that are connected to that subnet.Copyright 2014 Global Knowledge Training LLC. All rights reserved.3

Formulas for Subnet CalculationThere are several formulas and rules used to calculate subnets. The formulas and rules are discussed below.Possible Number of SubnetsTo calculate the number of possible subnets, use the formula 2n, where n equals the number of host bitsborrowed. For example, if three host bits are borrowed, then n 3. 23 8, so eight subnets are possible if threehost bits are borrowed. The table below lists the powers of 2.Bits 11PossibleSubnets2481632641282565121,0242,048Bits 524,194,304To complete the third step of the subnetting process, determine how many host bits need to be borrowed andrewrite the formula as 2n (number of required subnets). For example, if the number of required subnets is 18,then write the formula as 2n 18. Solve for n by getting as close to the number of required subnets as possiblewithout going under. In this example, n 5 (25 32). This means that to create at least 18 subnets, 5 host bitsmust be borrowed.Possible Number of Hosts per SubnetTo calculate the number of possible hosts per subnet, use the formula 2h - 2, where h equals the number of hostbits. The reason two addresses must be subtracted is because of the network address and the broadcast address.There are two ways to determine the number of host bits.1. Determine the number of remaining host bits based on the class of address and the number of host bitsborrowed.a.b.c.d.Determine the assigned IP address space.Determine number of host bits available.Determine number of host bits borrowed.Determine the number of remaining host bits by subtracting the number of host bits borrowedfrom the default number of host bits. The difference is h in the formula.e. Determine the number of possible hosts by using the formula 2h - 2. Use the table above todetermine the number of hosts available after a specific number of bits have been borrowedfrom the host portion of the address.f. Calculate the new subnet mask and prefixCopyright 2014 Global Knowledge Training LLC. All rights reserved.4

Examples for each class of IP address space are shown in the table below.Given IPAddress SpaceNumber of Host BitsAvailableNumber of HostBits BorrowedNumber of Host BitsRemaining (h)Number ofPossible HostsABC24168147424 - 14 1016 - 7 98-4 4210 1,0241024 - 2 1,02227 128128 - 2 12624 1616 - 2 14New Subnet Mask255.255.252.0255.255.254.0255.255.255.240New Prefix/22/23/282. Determine how many host bits need to be saved based on the number of hosts the subnet needs tosupport. This scenario is coming from a design perspective and is very common.a.b.c.d.Determine the assigned IP space.Determine the number of host bits available.Determine how many hosts the subnet needs to support.Rewrite the formula as 2h - 2 (number of required hosts), where h equals the number of hostbits that must be saved.e. Solve for h, by finding the exponent of 2 whose value is as close to the number of requiredhosts as possible without going under. That exponent is the value of h.f. All other bits not saved for host bits become network bits. Use the following formula todetermine how many host bits are given to the network portion: (Number of Host BitsAvailable) - hg. Calculate the new subnet mask and prefix.Understanding the concept of saving host bits is critical. Remember, host bits are always the bits to the far rightof the IP address. So when saving host bits, start with the far right bit (the last bit of the last octet) and count tothe left. Remaining host bits are given to the network portion.For example, suppose that six host bits need to be saved. This means the last six bits of the last octet are saved ashost bits, while the first two bits of the last octet, along with any host bits from the second and third octet, aregiven to the network portion. The table below shows this concept.ExponentBasePlace ValueBinary ValueMeaningLast Octet of Subnet Mask22625241286432161100Network Network HostHostBitBitBitBit7Copyright 2014 Global Knowledge Training LLC. All rights Bit5

Examples for each class of IP address space are shown in the table below.Given IPAddress SpaceNumber of Host Bits AvailableNumber of Required Hosts PerSubnetABC2416850020025Number of Host Bits Given tothe Network Portion2h - 2 50029 512512 - 2 510h 924 - h24 - 9 152h - 2 20028 256256 - 2 254h 816 - h16 - 8 82h - 2 2525 3232 - 2 30h 58-h8-5 3New Subnet Mask255.255.254.0255.255.255.0255.255.255.224New Prefix/23/24/27Number of Host Bits to Save (h)Calculate New Subnet MaskTo complete the fourth step of the subnetting process—calculating the decimal and prefix values of the newsubnet mask—perform the following steps.1.2.3.4.Determine the class of IP network.Determine the default subnet mask or prefix for the class of address.Determine how many host bits were borrowed or given to the network.Calculate the new subnet mask and prefix. To calculate the new subnet mask, start with the first binary 0in the default subnet mask and change it to a binary 1. Continue doing this, moving left to right, for thenumber of bits borrowed.For example, if the default subnet mask is 255.255.0.0, and if the number of bits borrowed is four, then the firstfour bits of the third octet must be changed from binary 0s to binary 1s. In this example, the new subnet mask is255.255.240.0.The table below provides an example of these steps.Assigned IP Address SpaceClass of Assigned IP Address SpaceDefault Subnet Mask (DottedDecimal Format)Default Subnet Mask in BinaryDefault Subnet Mask (Prefix Format)Number of Host Bits BorrowedNew Subnet Mask (Dotted DecimalFormat)New Subnet Mask in BinaryNew Subnet Mask (Prefix Format)Copyright 2014 Global Knowledge Training LLC. All rights .11110000.00000000/206

Calculate the New SubnetsCalculating the new subnets is part of the fifth step of the subnetting process. In the subnet mask, the last bitborrowed is called the Least Significant Bit (LSB). The figure below shows an example.In the subnet mask 255.255.240.0, the LSB is the fourth bit of the third octet. This bit has a value of 16. This isimportant to note, because the value of the LSB determines the multiples of the new IP subnets. In other words,the network numbers of the new possible subnets go in increments of 16 in the third octet. The table belowshows the new possible 3.96.0159.43.224.0159.43.112.0159.43.240.0Use the value of the LSB to determine the new possible subnets works for every class of IP network with anysubnet mask.Calculate the Broadcast Address and Usable Range of theNew SubnetsOnce the network address of the new possible subnets is known, the broadcast address and the usable range forthe new subnets can be quickly calculated.Copyright 2014 Global Knowledge Training LLC. All rights reserved.7

To calculate the broadcast address and each of the subnets, identify the next subnet, and then go back oneaddress. The table below shows the new subnets and their broadcast addresses.Subnet 192.0159.43.208.0159.43.224.0159.43.240.0Broadcast .43.239.255159.43.255.255To calculate the usable range of IP addresses—meaning, the range of IP addresses that can be assigned to devicesconnected to the subnet—do the following:1. Add one address to the subnet address to find the first usable IP address.2. Subtract one address from the broadcast address to find the last usable IP address.The following table shows all of the new possible subnets; the usable range of IP addresses for each subnet; andthe broadcast address for each subnet.Subnet 192.0159.43.208.0159.43.224.0159.43.240.0Usable Range of Host IP Addresses159.43.0.1 through 159.43.15.254159.43.16.1 through 159.43.32.254159.43.32.1 through 159.43.47.254159.43.48.1 through 159.43.63.254159.43.64.1 through 159.43.79.254159.43.80.1 through 159.43.95.254159.43.96.1 through 159.43.111.254159.43.112.1 through 159.43.127.254159.43.128.1 through 159.43.143.254159.43.144.1 through 159.43.159.254159.43.160.1 through 159.43.175.254159.43.176.1 through 159.43.190.254159.43.192.1 through 159.43.207 254159.43.208.1 through 159.43.223.254159.43.224.1 through 159.43.239.254159.43.240.1 through 159.43.255.254Copyright 2014 Global Knowledge Training LLC. All rights reserved.Broadcast .43.239.255159.43.255.2558

Putting It All TogetherHere is a class C example demonstrating everything. The given IP address space is 209.44.33.0 /24. The requirednumber of subnets is 6. The table below shows the six-step subnetting process.Step 1--Given IP Address SpaceStep 2--Number of RequiredSubnetsStep 3A--Determine Number ofBits to BorrowStep 3B--Determine Number ofHosts per SubnetStep 4--Calculate new subnetmask and prefixStep 5--Apply the Subnet Mask tothe IP SpaceStep 6--Assign IP Addresses toDevices as Appropriate209.44.33.0 (Class C)Default Subnet Mask 255.255.255.0Default Number of Host Bits 863(2n 6, where n the number of host bits to borrow. n 3(23 8))30(Number of host bits available) - n h8-3 5h 52h - 2 (Number of hosts per subnet)25 32 - 2 30Default Class C Subnet Mask 255.255.255.0Default Class C Prefix /24New Subnet Mask 255.255.255.224New Prefix /27SubnetUsable RangeBroadcast209.44.33.0209.44.33.1 - 30209.44.33.31209.44.33.32209.44.33.33 - 62209.44.33.63209.44.33.64209.44.33.65 - 94209.44.33.95209.44.33.96209.44.33.97 - 126209.44.33.127209.44.33.128209.44.33.129 - 158209.44.33.159209.44.33.160209.44.33.161 - 190209.44.33.191209.44.33.192209.44.33.193 - 222209.44.33.223209.44.33.224209.44.33.225 - 254209.44.33.255The router interface usually receives the first IP address of the subnet, butthis is not required.Copyright 2014 Global Knowledge Training LLC. All rights reserved.9

Here is a class B example demonstrating everything. The given IP address space is 147.38.0.0 /16. The requirednumber of subnets is 400. The table below shows the six-step subnetting process.Step 1--Given IP Address SpaceStep 2--Number of RequiredSubnetsStep 3--Determine Number of Bitsto BorrowStep 4--Calculate new subnetmask and prefixStep 5--Apply the Subnet Mask tothe IP Space (Only the first 10 areshown.)Step 6--Assign IP Addresses toDevices as Appropriate147.38.0.0 (Class B)4009(2n 400, where n the number of host bits to borrow. n 9(29 512))Default Class B Subnet Mask 255.255.0.0Default Class C Prefix /16New Subnet Mask 255.255.255.128New Prefix /25SubnetUsable RangeBroadcast147.38.0.0147.38.0.1 - 147.38.0.126147.38.0.127147.38.0.128147.38.0.129 - 147.38.0.254147.38.0.255147.38.1.0147.38.1.1 - 147.38.1.126147.38.1.127147.38.1.128147.38.1.129 - 147.38.1.254147.38.1.255147.38.2.0147.38.2.1 - 147.38.2.126147.38.2.127147.38.2.128147.38.2.129 - 147.38.2.254147.38.2.255147.38.3.0147.38.3.1 - 147.38.3.126147.38.3.127147.38.3.128147.38.3.129 - 147.38.3.254147.38.3.255147.38.4.0147.38.4.1 - 147.38.4.126147.38.4.127147.38.4.128147.38.4.129 - 147.38.4.254147.38.4.255The router interface usually receives the first IP address of the subnet, butthis is not required.Variable Length Subnet MaskingWhen the subnet mask is fixed throughout the IP network, meaning the subnet mask is the same for everysubnet, it is called Static Length Subnet Masking (SLSM). SLSM often leads to wasted IP addresses.Copyright 2014 Global Knowledge Training LLC. All rights reserved.10

The IP network 172.16.0.0 /16 has been assigned to an organization. The organization has subnetted this IPnetwork into multiple /24 (255.255.255.0) subnets. A /24 subnet means there are eight host bits, which meanseach subnet can support up to 254 hosts.The figure above shows a region of the organization. For the LANs connected to the HQ router, 254 hosts persubnet is appropriate. However, for the LANs connected to the branch routers, where only 50 hosts reside, 254possible hosts is too many. In fact, there are 204 wasted IP addresses per branch. For the WAN links between therouters, where only two hosts reside, 254 possible hosts is extreme overkill. In fact, there are 252 IP addresseswasted on each WAN link. That means there is a total of 1,824 wasted IP addresses in this design.In order to make more efficient use of the assigned IP address space, a Variable Length Subnet Mask (VLSM) canbe used. In VLSM, the number of network and host bits assigned to a subnet can vary based on the number ofhosts the subnet is required to support.Additionally, implementing VLSM provides more levels of hierarchy within the IP address space because a subnetcan be further subnetted. More levels of hierarchy provide opportunities for route aggregation, also called routesummarization. When routes are summarized, a single entry in the routing table of a router represents multiplesmaller networks. Route summarization improves the efficiency of routing protocols and the overall routingprocess.The figure above shows the IP addressing scheme for the same region utilizing VLSM. The organization is stillassigned the 172.16.0.0 /16 network, but now the region is assigned the 172.16.8.0 /21 subnet. This subnet has atotal of eleven host bits available.Copyright 2014 Global Knowledge Training LLC. All rights reserved.11

Within the region, the 172.16.8.0 /21 subnet is further subnetted as follows:1. The networks connected to the HQ router are assigned the 172.16.8.0 /24 and 172.16.9.0 /24 subnets. A24-bit prefix is chosen based on the number of hosts the subnet needs to support. Each of these subnetsneeds to support 200 hosts. In order to support 200 hosts, eight host bits must be saved. If eight hostbits are saved, 24 bits can be given to the network portion. (For example: 11 total host bits - 8 savedhost bits 3 additional bits given to the network. 21 existing network bits 3 additional network bits 24 total network bits.) While this creates 254 possible host IP addresses, this overage is acceptable fortwo reasons:a. 254 possible host IP addresses is as close to 200 without going under as possible. If only sevenhost bits were saved, there would only be 126 possible host IP addresses.b. 54 additional host IP addresses leaves room for growth within the subnet. As a general rule,add 20 percent to the actual number of hosts to allow for growth. For example, the networksattached to the HQ router need to support 200 hosts, so planning for 240 hosts allows a bufferfor growth within the subnet.2. The next available subnet after the 172.16.9.0 /24 subnet is the 172.16.10.0 /24. This subnet is furthersubnetted into subnets using 26 network bits (a 26-bit prefix) for the LANs at the branch offices. Again,the prefix is chosen for these subnets based on the need for each of the branch subnets to support 50hosts. In order to support 50 hosts, six host bits must be saved. If six host bits are saved, 26 bits can begiven to the network portion. While this creates 62 possible hosts per subnet, this overage is acceptable.3. The next available subnet after the 172.16.10.192 /26 subnet is the 172.16.11.0 /26. This subnet isfurther subnetted into subnets using 30 network bits (a 30-bit prefix) for the WAN links between therouters. Again, the prefix is chosen based on the need for each of the WAN links to support two hosts.In order to support two hosts, two host bits must be saved. If two host bits are saved, 30 bits can begiven to the network portion. In this instance, having exactly two host IP addresses is acceptable becausethese are serial WAN links. Serial WAN links are point-to-point, meaning they have only two devices.Since no more than two devices can connect to a point-to-point link, there is no need to account forpossible growth on those networks.The figure also demonstrates route aggregation or summarization. In other words, all ten of the subnets withinthe region can be represented by the subnet 172.16.8.0 /21. This means that routers for other regions within theorganization have only one entry in their routing tables instead of ten. Having a smaller routing table enables arouter to forward packets faster. Additionally, by having a summarized route, if there is a topology changewithin the region, the routers at other regions do not need to rerun the routing protocol. This makes forwardingof packets much faster.Determine the Subnet, Usable Range of Addresses, andBroadcast Address for Given HostOften it is necessary to determine the subnet, the usable range of host IP addresses, and the broadcast addressfor a given host. This process is described below.1. Identify the IP address and subnet mask of the host.2. Identify the LSB to determine the interval of the subnets.Copyright 2014 Global Knowledge Training LLC. All rights reserved.12

3. Identify the subnet to which the host belongs. To do this, find the subnet ID that is closest to the host IPaddress without going over. (Think of the TV game show The Price Is Right—get as close to the pricewithout going over.)4. Identify the broadcast address for the subnet. To do this, find the next subnet ID and subtract oneaddress.5. Identify the usable range of host IP addresses. To do this, add one address to the subnet ID, andsubtract one address from the broadcast address.The tables below show an example for each class of address.Given Host IP Address andPrefix207.59.22.34 /2816Identify the LSBIdentify the Subnet toWhich the Host BelongsIdentify the BroadcastAddress for the SubnetIdentify the Usable Rangeof Host IP AddressesGiven Host IP Address andPrefixThe 28th bit is the 4th bit of the 4th e the LSB is 16, the interval of the new subnets is 16. 32 is the multiple of 16closest to 34 without going over.207.59.22.47The broadcast address is one less than the next subnet ID. The next subnet ID after207.59.22.32 is 207.59.22.48.207.59.22.33 - 207.59.22.46The first usable IP address is one more than the subnet ID. The last usable IPaddress is one less than the broadcast address.175.38.54.188 /232Identify the LSBIdentify the Subnet toWhich the Host BelongsIdentify the BroadcastAddress for the SubnetIdentify the Usable Rangeof Host IP AddressesThe 23rd bit is the 7th bit of the 3rd octet.1281641321161814121LSB10175.38.54.0Because the LSB is 2, the interval of the new subnets is 2. 54 is the multiple of 2closest to 54 without going over.172.38.55.255The broadcast address is one less than the next subnet ID. The next subnet ID after172.38.54.0 is 172.38.56.0.172.38.54.1 - 172.38.55.254The first usable IP address is one more than the subnet ID. The last usable IPaddress is one less than the broadcast address.Copyright 2014 Global Knowledge Training LLC. All rights reserved.13

Given Host IP Address andPrefix98.165.33.250 /1132The 23rd bit is the 7th bit of the 3rd octet.Identify the LSB1281Identify the Subnet toWhich the Host BelongsIdentify the BroadcastAddress for the SubnetIdentify the Usable Rangeof Host IP Addresses641321LSB1608040201098.160.0.0Because the LSB is 32, the interval of the new subnets is 32. 160 is the multiple of32 closest to 165 without going over.98.191.255.255The broadcast address is one less than the next subnet ID. The next subnet ID after98.160.0.0 is 98.192.0.0.98.160.0.1 - 98.191.255.254The first usable IP address is one more than the subnet ID. The last usable IPaddress is one less than the broadcast address.Helpful TablesPrefix Notation to Dotted Decimal Notation ConversionThe table below shows the prefix notation and its equivalent dotted decimal 0.0255.248.0.0255.252.0.0255.254.0.0PrefixDotted DecimalPrefixDotted 55.255.252255.255.255.254Copyright 2014 Global Knowledge Training LLC. All rights reserved.14

List of MultiplesThe table below lists the multiples, or intervals, for the bit values. These are used to calculate the list of newsubnets created based on the 12216220224228232236240244248252ConclusionThe ability to interpret and understand IP addresses and subnet masks is critical for an IT professional. This skill isthe foundation for troubleshooting numerous problems, from the assignment of an IP address to a host torouting problems to access-control list problems. It is also necessary for designing and configuring efficient IPnetworks.Learn MoreLearn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edgethrough training.ICND1 v2.0 - Interconnecting Cisco Networking Devices, Part 1ICND2 v2.0 - Interconnecting Cisco Networking Devices, Part 2ROUTE - Implementing Cisco IP Routing v2.0TSHOOT - Troubleshooting and Maintaining Cisco IP Networks v2.0Visit www.globalknowledge.com or call 1-800-COURSES (1-800-268-7737) to speak with a Global Knowledgetraining advisor.About the AuthorAlan Thomas holds a Bachelor of Science degree in technical management and has been a network professionalin several capacities for over 20 years. Alan is a Global Knowledge Instructor and has received the QualityInstructor Award.Copyright 2014 Global Knowledge Training LLC. All rights reserved.15

the process of subnetting is both a mathematical process and a network design process. mathematics drives how subnets are calculated, identified, and assigned. the network design and requirements of the organization drive how many subnets are needed and how many hosts an individual subnet needs to support. binary basics and ipv4 address structure