Routers use a subnet mask to determine which
parts of the IP address correspond to the network,
the subnet, and the host. The mask is a 32-bit
number in the same format as the IP address. The
mask is a string of consecutive 1s starting from the
most-significant bits, representing the network ID,
followed by a string of consecutive 0s, representing
the host ID portion of the address bits.
Each address class has a default subnet mask (A =
/8, B = /16, C = /24). The default subnet masks
only the network portion of the address, the effect
of which is no subnetting. With each bit of subnetting
beyond the default, you can create 2n–2 subnets.
The preceding example has 254 subnets, each
with 254 hosts. This counts the address ending
with .0, but not the address ending in .255.
Continuing with the preceding analogy, the subnet
mask tells the network devices how many apartments
are in the building.
Identifying Subnet Addresses
Given an IP address and subnet mask, you can
identify the subnet address, broadcast address, and
first and last usable addresses within a subnet as
follows:
1. Write down the 32-bit address and the subnet
mask below that (174.24.4.176/26 is shown
in the following figure).
2. Draw a vertical line just after the last 1 bit in
the subnet mask.
3. Copy the portion of the IP address to the left
of the line. Place all 1s for the remaining free
spaces to the right. This is the broadcast
address for the subnet.
4. The first and last address can also be found
by placing ...0001 and ...1110, respectively, in
the remaining free spaces.
5. Copy the portion of the IP address to the left
of the line. Place all 0s for the remaining free
spaces to the right. This is the subnet number.
174.24.4.176 1010111000110000000100 10110000 Host
255.255.255.192 1111111111111111111111 11000000 Mask
174.24.4.128 1010111000110000000100 10000000 Subnet
174.24.4.191 1010111000110000000100 10111111 Broadcast
At-a-Glance: IP Addressing
Network
128
10000000
10
00001010
173
10110010
46
00101110
Host
IP
Address
Subnet
Mask
This subnet mask can also be written as "/24", where 24
represents the number of 1s in the subnet mask.