Subnets and Subnet Masks

NOTE
The need for network-level addressing
Never lose sight of why network-level addresses are necessary in the first place. For routing to be
accomplished, each and every data link (network) must have a unique address; in addition, each and every
host on that data link must have an address that both identifies it as a member of the network and
distinguishes it from any other host on that network.
As defined so far, a single class A, B, or C address can be used only on a single data link. To build an
internetwork, separate addresses must be used for each data link so that those networks are uniquely
identifiable. If a separate class A, B, or C address were assigned to each data link, less than 17 million
data links could be addressed before all IP addresses were depleted. This approach is obviously
impractical, [7] as is the fact that to make full use of the host address space in the previous example, more
than 65,000 devices would have to reside on data link 172.21.0.0!
[7] Seventeen million data links may seem like a lot until you consider that even a single moderate-size business may have dozens or hundreds of
data links.
The only way to make class A, B, or C addresses practical is by dividing each major address, such as
172.21.0.0, into subnetwork addresses. Recall two facts:
1. The host portion of an address can be used as desired.
2. The network portion of an IP address is determined by the address mask assigned to that interface.
Figure 2.13 shows an internetwork to which the major class B address 172.21.0.0 has been assigned. Five
data links are interconnecting the routers, each one of which requires a network address. As it stands,
172.21.0.0 would have to be assigned to a single data link, and then four more addresses would have to be
requested for the other four data links.

Notice what was done in Figure 2.13. The address mask is not a standard 16-bit mask for class B
addresses; the mask has been extended another eight bits so that the first 24 bits of the IP address are
interpreted as network bits. In other words, the routers and hosts have been given a mask that causes them
to read the first eight host bits as part of the network address. The result is that the major network address
applies to the entire internetwork, and each data link has become a subnetwork, or subnet. A subnet is a
subset of a major class A, B, or C address space.
NOTE
Subnet
NOTE
Subnet mask
The IP address now has three parts: the network part, the subnet part, and the host part. The address mask
is now a subnet mask, or a mask that is longer than the standard address mask. The first two octets of the
address will always be 172.21, but the third octet—whose bits are now subnet bits instead of host bits—
may range from 0 to 255. The internetwork in Figure 2.12 has subnets 1, 2, 3, 4, and 5 (172.21.1.0
through 172.21.5.0). Up to 256 subnets may be assigned under the single class B address, using the mask
shown.
Two words of caution are in order. First, not all routing protocols can support subnet addresses in which
the subnet bits are all zeros or all ones. The reason is that these protocols, called classful protocols, cannot
differentiate between an all-zero subnet and the major network number. For instance, subnet 0 in Figure
2.13 would be 172.21.0.0; the major IP address is also 172.21.0.0. The two cannot be distinguished
without further information.
NOTE
Classful protocols

Likewise, classful routing protocols cannot differentiate a broadcast on the all-ones subnet from an allsubnets
broadcast address.[8] For example, the all-ones subnet in Figure 2.13 would be 172.21.255.0. For
that subnet, the all-hosts broadcast address would be 172.21.255.255, but that is also the broadcast for all
hosts on all subnets of major network 172.21.0.0. Again, the two addresses cannot be distinguished
without further information. RIP version 1 and IGRP are both classful routing protocols; Chapter 7
introduces classless routing protocols, which can indeed use the all-zeros and all-ones subnets.
[8] The all-hosts IP broadcast address is all ones: 255.255.255.255. An all-hosts broadcast for a particular subnet would set all host bits to one; for
instance, an all hosts broadcast for subnet 172.21.1.0 would be 172.21.1.255. Finally, a broadcast for all hosts on all subnets sets the subnet bits
and the host bits to all ones: 172.21.255.255.
The second caution has to do with the verbal description of subnets and their masks. Subnetting the third
octet of a class B address, as is done is Figure 2.13, is very common; also common is hearing people
describe such a subnet design as "using a class C mask with a class B address," or "subnetting a class B
address into a class C." Both descriptions are wrong! Such descriptions frequently lead to
misunderstandings about the subnet design or to a poor understanding of subnetting itself. The proper
way to describe the subnetting scheme of Figure 2.12 is either as "a class B address with 8 bits of
subnetting," or as "a class B address with a 24-bit mask."
The subnet mask may be represented in any of three formats—dotted decimal, bitcount, and
hexadecimal—as shown in Figure 2.14. Dotted decimal is still the most common format, although the
bitcount format is becoming increasingly popular. Compared to dotted decimal, the bitcount format is
easier to write (the address is followed by a forward slash and the number of bits that are masked for the
network part). In addition, the bitcount format is more descriptive of what the mask is really doing and
therefore avoids the type of semantic misunderstandings described in the previous paragraph. Many
UNIX systems use the hexadecimal format.
Figure 2.14. The subnet mask in Figure 2.13 may be represented in three different formats.
Although the address mask must be specified to Cisco routers in dotted decimal, using the command
shown previously, the mask may be displayed by various show commands in any of the three formats by
using the command ip netmask-format [dec|hex|bit] in line configuration mode. For example, to
configure a router to display its masks in bitcount format, use:
Gladys(config)# line vty 0 4
Gladys(config-line)# ip netmask-format bit