Working with Subnets
The subnet mask defines how many bits after the network ID will be used for the subnet ID. The subnet ID can vary in length, depending on the value you select for the subnet mask. As the subnet ID grows larger, fewer bits are left for the host ID. In other words, if your network has many subnets, you will be limited to fewer hosts on each subnet. If you have only a few subnets and require only a few bits for the subnet ID, you can place more hosts on a subnet.
By the Way
Note that the address class also defines how many bits will be available for the subnet ID. The mask
specifies 19 bits for the network ID and subnet ID together. If this mask is used with a Class B address (which has a 16-bit network ID), only three bits are available for subnetting. The same mask is used with a Class A address (which has an 8-bit network ID); 11 bits are available for subnetting.
The assignment of subnet IDs (and hence the assignment of a subnet mask) depends on your network configuration. The best solution is to plan your network first and determine the number and location of all network segments, then assign each segment a subnet ID. You'll need enough subnet bits to assign a unique subnet ID to each subnet. Save room, if possible, for additional subnet IDs in case your network expands.
A simple example of subnetting is a Class B network in which the third octet (the third term in the dotted decimal IP address) is reserved for the subnet number. In Figure 5.6, the network 126.96.36.199 is divided into four subnets. The IP addresses on the network are given the subnet mask 255.255.255.0, signifying that the network ID and subnet mask span three octets of the IP address. Because the address is a Class B address (see Hour 4), the first two octets in the address form the network ID. Subnet A in Figure 5.6 therefore has the following parameters:
Network ID: 188.8.131.52
Subnet ID: 0.0.128.0
Host IDs of either all ones or all zeros cannot be assigned. The configuration shown in Figure 5.6 therefore supports a possible 254 subnets and 254 addresses per subnet. This is a very sensible solution as long as you don't have more than 254 addresses on a subnet and as long as you have access to a Class B network address (which are getting harder to find).
It often isn't possible to assign a full octet to the subnet ID. On a Class C network, for instance, if you assigned a full octet to the subnet ID, you wouldn't have any bits left for the host ID. Even on a Class B network, you might not be able to use a full octet for the subnet ID, because you might need to make room for more than 254 hosts on a subnet. The subnetting rules do not require you to place the subnet ID at an octet boundary. The concept of a subnet ID that doesn't fall on an octet boundary is easy to visualize in binary form but becomes a bit more confusing when you return to dotted decimal format.
Consider a Class C network that must be divided into five small subnets. The class addressing rules provide 8 bits after the network ID to use for the subnet ID and the host ID in a Class C network. You could designate three of those bits for the subnet ID using this subnet mask:
The remaining five bits are then available for the host ID. The three bits of the subnet ID provide eight possible bit patterns. As mentioned earlier, the official subnetting rules exclude the all-ones pattern and the all-zeros pattern from the pool of subnet IDs (although many routers actually support the assignment of the all-ones or all-zeros subnet ID). In any case, this configuration is sufficient for five small subnets. The five bit places of the host ID offer 32 possible bit combinations. Excluding the all-zeros pattern and the all-ones pattern, the subnets could each hold 30 hosts.
To express this subnet mask in dotted decimal notation, follow the procedure described in the preceding section:
Suppose you start placing hosts on this subnetted network (see Figure 5.7). Because this network is a Class C network, the first three octets will be the same for all hosts. To obtain the fourth octet of the IP address, simply write down the binary subnet ID and host ID in their respective bit positions. In Figure 5.7, for instance, the subnet ID field for Subnet C has the bit pattern 011. Because this pattern is on the left end of the octet, the bit positions of the subnet ID actually represent the pattern 01100000, which means that the subnet number is 96. If the host ID is 17 (binary 10001), the fourth octet is 01110001, which converts to 113. The IP address of this host is therefore 184.108.40.206.
Table 5.1 shows the binary pattern equivalents of the dotted notation subnet masks. This table shows all valid subnet mask patterns. The Description column in Table 5.1 tells how many additional one bits are present beyond the one bits present in the default mask provided by the class designation. These mask bits are available for the subnet ID. For example, the default Class A mask has eight one bits; the row that displays two mask bits means there are eight plus two, or a total of 10 ones bits present in the subnet mask.
By the Way
Some of the patterns in Table 5.1 are not very practical, and are included for illustration purposes only. For instance, a Class C network with six subnet bits has only two bits left for assigning host IDs. Of those two bits, the all-ones address (11) is reserved for broadcast, and the all-zeros address (00) is typically not used. This subnet therefore only has room for two hosts.