Advanced Topics: IP Subnetting A WHITE PAPER PREPARED FOR ASPE TECHNOLOGY www.aspetech.com toll-free: 877-800-5221
Advanced Topics IP Subnetting It is almost impossible to lay out an IP network without the use of subnetting. This paper will explain the principles of subnetting and link the subnetting topic to the principles of LAN operation. Basic IP Addressing Rules The basic rules of IP network addressing are: 1. Every host must have a unique 32-bit IP address. 2. Some portion of the complete 32-bit IP address is the network address. 3. Hosts on the same network must have the same network address. 4. All networks must have a unique network address (no duplicates). 5. The number of leftmost bits that are the network address is defined by the class of the address. 6. For class A networks (decimal equivalent of left-hand byte is in the range 0-126), the network value is the first 8 bits. 7. For class B networks (decimal equivalent of left-hand byte is in the range 128-191), the network value is the first 16 bits. 8. For class C networks (decimal equivalent of left-hand byte is in the range 192-223), the network value is the first 24 bits. These rules tell you that if you want to lay out IP addresses on a group of networks, you assign a unique IP address to each host interface, and you must also ensure that every host interface on a single network has the same IP network (left portion) address. The size of the network address (8, 16, or 24 bits) is determined by the class of the address. The Router s Role But why would you want to worry about a group of networks, rather that just one network? Please note that the acronym IP stands for internetworking protocol. An internetwork is defined to be a group of interconnected networks. So the IP protocol is specifically designed to work well with an internetwork with a group of networks. The reason for this is most modern networking situations are going to require more than one network. True, small businesses have only a single LAN within the office, but it is almost guaranteed that the business will be connected to the internet. The connection to the internet is, technically, a second network, because the WAN technology used to connect the office network (the office network is a LAN) to the ISP office (which is also a LAN) differs radically from the technology used within the office. WAN technology is designed to transport data across large spans, at relatively low bit rates. LAN technology is intended to carry data within a small area, at much higher bit rates. Obviously, these two technology types cannot be connected directly to each other. We have two network types, we have two networks, and we must use some device to interconnect them. This device is a router. Unlike small businesses, larger ones will have many networks and many routers.
For the IP protocol, routers use destination-based routing. This means that the router makes decisions about where to route packets based upon the IP destination address that is in the packet. Packets with a network address of A will be routed to the output interface on the router that leads to network A. The router is able to make these decisions because it contains a routing table in its internal RAM. This routing table can be built manually by the router administrator (by use of static route commands) or can be built dynamically by use of a routing protocol. A routing protocol allows the router to enter routes into the routing table on its own, using information that it receives from other routers. Note the consistency between the router s operation and the IP addressing rules outlined in the first section. Every IP network must have a unique network address, and every host interface within a single network must have the same network address. Reference the figure marked Figure 1 below. If a router is connected to 4 networks, each network must have a unique network address. Suppose the networks are all class C, so we can conclude that the IP addresses in use on all networks have a first byte value in the range of 192-223, and that all 4 networks have a unique 3-byte value at the start of each IP address used. Each network in the drawing is assigned a unique class C network address. When we assigned host interface addresses within each network, we would ensure that the first 3 bytes of the host interface address would match the first 3 bytes of the network address indicated. We would also ensure that the last byte in the address would be unique, thus assuring a unique interface address for each host. Why Subnetting? Here is where the requirement for subnetting begins to emerge. The layout in Figure 1 requires us to use four different network addresses. These network addresses must be unique, and if this simple internetwork is connected to the internet, the network addresses used on our internetwork must not collide with addresses used by any other internetwork that is connected to the internet. So we have to use an internet registered network address. Some third party registration authority would give us the network addresses to use on out internetwork, and they would guarantee that the addresses given to us would be reserved and would not be given to anyone else who attempted to register. Given that the internet contains millions of individual internetworks, would the registration authority be very happy if we requested more than just a few network addresses? Not likely. In the real world situation, which is much more complex that the internetwork shown in Figure 1, we would probably be fortunate to get only a handful of network addresses to use on our entire internetwork. Remember in our simple Figure 1 example, four router interfaces required four network addresses. If we had dozens of routers, scores of individual networks, and hundreds of router interfaces interconnecting these networks, how could we deploy only a few network addresses in a manner that would allow the routers to be configured correctly? The answer is to use subnetting. We will take one (of some other small number) of registered network addresses and subnet the total address space provided up into smaller chunks. And we ll do this in a disciplined manner to ensure that the routers will be configured in a manner that will allow them to work properly and to always route data in the proper direction.
NETWORK 192.124.15.0 NETWORK 193.45.55.0 192.34.59.0 NETWORK 195.52.21.0 FIGURE 1 Router Setup with Four Class C Networks A reasonable setup is shown in Figure 2. Here, we have obtained one Class B network address from the registration authority, 128.191.0.0. We have chose to use the third byte of the IP address for our subnet value. Notice that, for each smaller piece of the total network, we have assigned a unique third-byte value. We say that each smaller piece of the network is a subnet. We are free to assign third-byte values in any way that we choose, since the registration authority only specified values for the first two bytes of the IP address. All we have to do is ensure that no two subnets have the same third-byte values. A shortcut is used to allow computers to understand our subnetting scheme. One or more subnet mask values are chosen when the internetwork s IP addressing is designed. These subnet masks are used when each host interface (and each router interface) is programmed with IP addressing information. Put another way, when you are working in a subnetted IP network, in order to configure an IP interface you must enter both the network address and the subnet mask for each interface that is being configured. The subnet mask values use a curious notation the decimal equivalent of their binary pattern. For the network depicted in Figure 2, the subnet mask value is 255.255.255.0. This is the decimal equivalent of a 32-bit pattern that begins with twenty-four 1 bit values followed by eight 0 bit values. The ones in the
NETWORK 128.191.1.0 NETWORK 128.191.2.0 128.191.3.0 NETWORK 128.191.4.0 FIGURE 2 Example of Subnetted Class B Network subnet mask cover the portion of the IP address which is occupied by network value + subnet value. The zeroes in the subnet mask cover the portion of the IP address which is reserved for host interface address assignment. A more realistic example of the use of subnetting and subnet masks is shown in Figure 3. In this internetwork, eight different LAN s are interconnected by the use of three routers and three T-1 spans. Imagine a corporate network that is distributed across three offices in three different cities. The registered IP network address in this example is Class B 129.11.0.0. The Figure shows 8 different subnets and two different mask values. The mask value of 255.255.255.0 is used for the LAN s, but the WAN s use 255.255.255.252. You can conclude that the network + subnet fields cover 24 bit values in the IP address for the LAN s, but they cover 30 bit values in the WAN (T-1) spans. The reason for this is that 255.255.255.252 is the decimal equivalent of thirty 1 bit values followed by two 0 bit values.
NETWORK 129.11.10.0 NETWORK 129.11.11.0 MASK=255.255.255.0 129.11.10.1 129.11.0.5 129.11.11.1 129.11.0.9 T-1 Span NETWORK 129.11.0.8 MASK = 255.255.255.252 T-1 Span NETWORK 129.11.0.4 MASK = 255.255.255.252 129.11.0.10 129.11.12.1 129.11.0.13 129.11.0.6 129.11.0.14 129.11.13.1 129.11.14.1 T-1 Span NETWORK 129.11.0.12 MASK = 255.255.255.252 NETWORK 129.11.12.0 NETWORK 129.11.13.0 NETWORK 129.11.14.0 LAN WAN FIGURE 3 REAL-WORLD CLASS B EXAMPLE
Some interesting conclusions fall out of this if you study the Figure 3. Why do we use a subnet mask value that covers 30 bit positions? This isn t too hard to figure out. In any subnetted internetwork, we have a finite and limited number of subnet values to use. For example, if we had a class B network value, the top 16 bits in the IP address would be fixed in value, we could not play with those. With a 24-bit subnet mask (shorthand language for a subnet mask value whose first 24 bits are 1 and the last 8 bits are 0 ), we would specify that we wanted the first sixteen bits in the network + subnet field to be used for network value (by definition, since we are using class B), and the last 8 bits should be used for subnet value. Such a scheme would allow the use of 256 different subnets. What if that were not enough subnets? We would have to use the subnetting bits more efficiently. For a T-1 span, we know that the WAN network will never grow beyond 2 host interfaces, one at each end of the span. There is no reason to use a subnet mask that allows 256 addresses to be placed into such a network. In fact, we could get away with specifying a subnet mask that would allow a maximum of two interfaces! It will never get bigger than that. So we could get away with using a subnet mask of 255.255.255.252, which leave only the last two bits available for interface address assignment. A two bit field is adequate for specifying two different values. The examples in this document depict use of public network addresses, that is, addresses which are registered in the global internet address space. It is actually unusual to use public addresses. Instead, business take advantage of the private address feature. Class A network 10, class B 172.16, and class C 192.168.1 192.168.254 are reserved for private use. Those will never be used by internet routers, and they will not be distributed to internet users. Instead, these address blocks are used behind a security gateway (firewall) or other network address translator. These devices ensure that the private addresses will never appear as an IP address in a packet that is routed to/from the internet. But, the important point to make in the context of this document is that, regardless of whether you are using public or private addresses, the subnetting principles and concepts are the same. Summary The topic of IP subnetting is complex and intricate. Use of proper subnetting schemes can greatly increase the number of interfaces that can be used within an IP network address space. The modern world of IP internetworking is totally dependent upon this concept, and designing or troubleshooting IP networks is impossible with a thorough understanding of subnetting concepts.