The IP addressing scheme provides a flexible solution to the task of addressing thousands of networks, but it is not without problems. The original designers did not envision the Internet growing as large as it has; at that time, a 32-bit address seemed so large that they quickly divided it into different classes of networks to facilitate routing rather than reserving more bits to manage the growth in network addresses. (Who ever thought we would need a PC with more than 640KB of memory?) To solve this problem, and to create a large number of new network addresses, another way of dividing the 32-bit address was developed, called subnetting.
An IP subnet modifies the IP address by using host address bits as additional network address bits. In other words, the dividing line between the network address and the host address is moved to the right, thus creating additional networks but reducing the number of hosts that can belong to each network.
When IP networks are subnetted, they can be routed independently, which allows a much better use of address space and available bandwidth. To subnet an IP network, you define a bit mask, known as a subnet mask, in which a bit pattern cancels out unwanted bits so that only the bits of interest remain.
Working out subnet masks is one of the most complex tasks in network administration and is not for the faint of heart. If your network consists of a single segment (in other words, there are no routers on your network), you will not have to use this type of subnetting; but if you have two or more segments (or subnets), you will have to make some sort of provision for distributing IP addresses appropriately. Using a subnet mask is the way to do just that.
The subnet mask is similar in structure to an IP address in that it has four parts, or octets, but now it defines three elements (network, subnet, and host) rather than two (network and host). It works a bit like a template that, when superimposed on top of the IP address, indicates which bits in the IP address identify the network and which bits identify the host. If a bit is on (such as a 1) in the mask, that equivalent bit in the address is interpreted as a network bit. If a bit is off (such as a 0) in the mask, the bit is part of the host address. The 32-bit value is then converted to dotted decimal notation. In general, you will use only one subnet mask on your network.
A subnet is only known and understood locally; to the rest of the Internet, the address is still interpreted as a standard IP address. Table 3.2 shows how this works for the standard IP address classes.
Default Subnet Masks for Standard IP Address Classes
Class - Subnet Mask Bit Pattern - Subnet Mask
A - 11111111 00000000 00000000 00000000 - 255.0.0.0
B - 11111111 11111111 00000000 00000000 - 255.255.0.0
C - 11111111 11111111 11111111 00000000 - 255.255.255.0
Routers then use the subnet mask to extract the network portion of the address so that they can send the data packets along the proper route on the network.
Because all the Class A and Class B networks are taken, you are most likely to encounter subnet-related issues when working with a Class C network. In the next section, you’ll get a detailed look at how to subnet a Class C network.
When faced with the choice of whether or not to subnet your network, you must remember several of the advantages to subnetting. The following list summarizes the advantages of the subnetting solution.
It reduces the size of routing tables.
It minimizes network traffic.
It isolates networks from others.
It maximizes performance.
It optimizes IP address space.
It enhances the ability to secure a network.
Subnetting a Class C Network
How do you find out the values that you can use for a Class C network subnet mask? Remember from a previous discussion that InterNIC defines the leftmost three octets in the address, leaving you with the rightmost octet for your own network addresses. If your network consists of a single segment, you have the following subnet mask:
11111111 11111111 11111111 00000000
When expressed as a decimal number, this is:
Because all of your addresses must match these leftmost 24 bits, you can do what you’d like with the last 8 bits, given a couple of exceptions that we’ll look at in a moment.
You might decide to divide your network into two equally sized segments, with, for example, the numbers 1 through 127 as the first subnet (00000001 through 01111111 in binary), and the numbers 128 through 255 as the second subnet (10000000 through 11111111 in binary). Now the number inside the subnets can vary only in the last seven places, and the subnet mask becomes:
In binary this is:
Tip Use the Windows Calculator in scientific mode (choose View Ř Scientific) to look at binary-to-decimal and decimal-to-binary conversions. Click the Bin (binary) button and then type the bit pattern that you want to convert. Click the Dec (decimal) button to display its decimal value. You can also go the other way, and display a decimal number in binary form.
Now let’s get back to the exceptions mentioned earlier. The network number is the first number in each range, so the first subnet’s network number is X.Y.Z.0, and the second is X.Y.Z.128 (X, Y, and Z are the octets assigned by InterNIC). The default router address is the second number in each range—X.Y.Z.1 and X.Y.Z.129—and the broadcast address is the last address, or X.Y.Z.127 and X.Y.Z.255. You can use all the other addresses within the range, as you see fit, on your network.
Class C Network Divided into Four Subnets Network Number - First Address - Broadcast Address
X.Y.Z.0 X.Y.Z.1 X.Y.Z.63
X.Y.Z.64 X.Y.Z.65 X.Y.Z.127
X.Y.Z.128 X.Y.Z.129 X.Y.Z.191
X.Y.Z.192 X.Y.Z.193 X.Y.Z.255
Class C Network Divided into Eight Subnets Network Number - First Address - Broadcast Address
X.Y.Z.0 X.Y.Z.1 X.Y.Z.31
X.Y.Z.32 X.Y.Z.33 X.Y.Z.63
X.Y.Z.64 X.Y.Z.65 X.Y.Z.95
X.Y.Z.96 X.Y.Z.97 X.Y.Z.127
X.Y.Z.128 X.Y.Z.129 X.Y.Z.159
X.Y.Z.160 X.Y.Z.161 X.Y.Z.191
X.Y.Z.192 X.Y.Z.193 X.Y.Z.223
X.Y.Z.224 X.Y.Z.225 X.Y.Z.255