If your network uses a default subnet mask—255.0.0.0 for Class A, 255.255.0.0 for Class B, or 255.255.255.0 for Class C—you have a classful domain. I like to associate the term classful with mindful—that is, you're mindful that you're working in an open domain with no subnetworks (subnets). Actually, your entire domain is a subnet, but it isn't further divided into sub-subnets.
A classful domain can be a very busy place, with all your network traffic whizzing around the same set of pathways. Switches, which operate at the data-link layer, separate collision domains, but they do nothing to separate broadcast domains because broadcasts happen at the network layer.
If you have a router, you can group portions of your network into subnets to cut down on the number of broadcasts. For example, you might want to group your infrastructure gear (including your server farm and printers) into one subnet, the marketing department into another subnet, and the sales department into another subnet. Subnetting can be a handy tool for busy networks.
If you have subnets, you have a classless domain with a classless subnet mask. A classless subnet mask, also known as a variable-length subnet mask (VLSM), borrows bits from an IP address' host section and gives them to the address' network section. "Classless" and "variable length" stem from the fact that subnet mask addresses don't fit into standard IP's Class A, B, and C format.
The only problem with subnetting is performing the binary calculations necessary to derive the subnet addresses—I prefer to work with decimal numbers when possible. I can teach you a little bit about Classless Inter-Domain Routing (CIDR) and let you in on an easy nonbinary mathematical trick. These two pieces of information will help you decipher the "slash notation" that you see in technical support literature and will make subnetting quick and easy.
First, a quick overview of subnetting and CIDR. The Internet Engineering Task Force (IETF) realized early on that IP addresses would run out sooner rather than later. In 1985, Request for Comments (RFC) 950 proposed subnetting to extend the number of available IP addresses. In 1993, RFCs 1517, 1518, 1519, and 1520 described CIDR as a standard for subnetting.
CIDR bought some time for resolving the IP address dilemma and provided a way to limit the growing number of entries in Internet backbone routing tables. Internet backbone routers can handle tens of thousands of entries but eventually become overloaded. Thanks mostly to CIDR, backbone routers today hover at a manageable number of routes in their routing tables.
You can find more information about CIDR at http://public.pacbell.net/ dedicated/cidr.html. In this article, I want to focus on the notation that emanated from the CIDR routing technique. CIDR notation offers an alternative to the old-fashioned Class A, B, and C addressing terminology, but you still must understand the basics of the traditional IP address format.
Traditional Class A, B, and C addresses are made up of four 8-bit bytes. The 8-bit binary numbers are typically represented by their decimal equivalents separated by dots (e.g., 184.108.40.206). Figure 1 shows that Class A addresses use the first 8 bits for the network and the last 24 bits for the host. Class B addresses use the first 16 bits for the network and the last 16 bits for the host, and Class C addresses use the first 24 bits for the network and the last 8 bits for the host. Subnet mask addresses are often represented in the same dotted-decimal format.
CIDR notation uses a slash followed by the number (in decimal) of network bits in the address (e.g., /8, pronounced "slash 8"). Suppose you have a network using the reserved Class A address 10.0.0.0 and a classful subnet. You could say that your network is 10.0.0.0/8, which is the same as a 255.0.0.0 subnet mask. For a reserved Class B address, such as 172.20.0.0, you could use the CIDR notation 172.20.0.0/16 or the subnet mask notation 255.255.0.0 to specify that you're subnetting on the 16th bit. For a Class C address, you might use 220.127.116.11/24 or 255.255.255.0.
An 8-bit byte yields eight possible subnet values: 128, 192, 224, 240, 248, 252, 254, and 255. Table 1, page 110, shows these subnet values in subnet masks for each class and shows their CIDR equivalents. Each subsequent CIDR value borrows one more bit from the host section and moves it to the network section. Thus, if you subnet the Class C address 192.16 .1.0 with a 240 mask (i.e., 255.255.255 .240), you have network 18.104.22.168/28. (Remember that the 0 is a placeholder. Sixteen possible subnets are associated with the /28 CIDR value.) If you subnet 22.214.171.124 with a 248 mask (i.e., 255.255 .255.248), you have network 126.96.36.199/29.
The 255 subnet value identifies a classful subnet, so it isn't relevant to a discussion of classless subnetting. However, the other seven subnet values do permit classless subnetting. With the list of subnet values and Table 1 handy, you're ready to start subnetting.
Magic Number Subnetting
Suppose you have a Class C network address of 188.8.131.52 and you want to apply a subnet mask that will yield four subnets, each with 50 or fewer hosts. Which mask would you use? Well, you could go through the trouble of calculating the subnet value in binary. (For a refresher course about working with the binary numbers used in IP addresses and subnet masks, see the sidebar "Binary Numbers and Subnet Masks," page 108.) Or, you could employ a little trial and error, find what I call the "magic number," and use that number in a few simple calculations to find the appropriate subnet value.
For a Class C address, to find the number of hosts per subnet that a given subnet value will yield, simply subtract the subnet value from 256 (the overall number of hosts). Here's where the trial and error comes in. Pick one of the seven classless subnet values—say, 192—and subtract it from 256 to get a magic number of 64. However, you need to take one more step to find the actual number of hosts you can use per subnet for the Class C 192 subnet value. Because you need the first number in a subnet for the network and the last number for broadcast, subtract 2 from 64. Therefore, the actual number of hosts per subnet from the Class C 192 subnet value is 62.
Next, divide 256 by the magic number 64 to find the number of subnets you can expect: 4. You can break out 4 subnets from the Class C 192 value, which is exactly the number of subnets you wanted. Now you can put your infrastructure gear, servers, and printers in the first subnet; your marketing department in the second; your sales department in the third; and IT in the fourth:
Subnet 2, Marketing184.108.40.206-127
Subnet 3, Sales220.127.116.11-191
Subnet 4, IT18.104.22.168-255
The numbers in bold type identify the range of addresses available in each subnet. Remember, though, that in each subnet, you can't use the first and last numbers. The four networks in CIDR notation would be 22.214.171.124/26, 126.96.36.199/26, 188.8.131.52/26, and 184.108.40.206/26, respectively.
For Class B subnet values, you must perform one additional calculation to find the number of hosts per subnet. After you find the magic number, you multiply it by 256, then subtract 2. So, for the Class B 192 subnet value, you perform the following calculations:
64 * 256 = 16,384
16,384 - 2 = 16,382
Thus, the Class B 192 subnet value yields 16,382 usable hosts per subnet. The number of subnets from the Class B subnet 192 value is the same as for the Class C 192 subnet value, which is 4 (i.e., 256 divided by 64).
To find the number of usable hosts for the Class A 192 subnet value, perform the following three calculations:
64 * 256 * 256 = 4,194,304
4,194,304 - 2 = 4,194,302
The Class A 192 subnet value yields 4,194,302 usable hosts per subnet. The number of subnets is the same as the number of subnets for the Class C and Class B 192 subnet values.
Understanding CIDR notation and magic-number math is the first step to implementing classless subnetting. You'll encounter CIDR notation in support documents, and you'll need the magic-number math when you try to solve subnetting problems. I strongly encourage network administrators considering whether to go through Cisco Certified Network Associate (CCNA) training to do so. You'll receive a wealth of subnetting, switching, and routing information that will prove enormously useful to you in your administration career.