Given an address and a mask, you can determine the classful network, the subnetwork, and the subnetwork’s broadcast number. You do so with a logical AND operation between the IP address and subnet mask. You obtain the broadcast address by taking the subnet number and making the host portion all 1s. Table 1-17 shows the logical AND operation. Notice that the AND operation is similar to multiplying bit 1 and bit 2; if any 0 is present, the result is 0.
Table 1-17 AND Logical Operation
Bit 1 | Bit 2 | AND |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
As an example, take the IP address 150.85.1.70 with subnet mask 255.255.255.224, as shown in Table 1-18. Notice the 3 bold bits in the subnet mask. These bits extend the default Class C prefix (/24) 3 bits to a mask of /27. As shown in Table 1-18, you perform an AND operation of the IP address with the subnet mask to obtain the subnetwork. You obtain the broadcast number by making all the host bits 1. As shown in bold, the subnet mask reaches 3 bits in the fourth octet. The subnetwork is identified by the five rightmost 0s in the fourth octet, and the broadcast is identified by all 1s in the 5 rightmost bits.
Table 1-18 Subnetwork of IP Address 150.85.1.70
Binary First, Second, and Third Octets | Binary Fourth Octet | Dotted-Decimal IP | ||
IP address | 10010110 01010101 00000001 | 010 | 00110 | 150.85.1.70 |
Subnet mask | 11111111 11111111 11111111 | 111 | 00000 | 255.255.255.224 |
Subnetwork | 10010110 01010101 00000001 | 010 | 00000 | 150.85.1.64 |
Major Network Portion | Subnet | Host | ||
Broadcast address | 10010110 01010101 00000001 | 010 | 11111 | 150.85.1.95 |
Variable-Length Subnet Masking
Variable-length subnet masking (VLSM) is a process used to divide a network into subnets of various sizes to prevent wasting IP addresses. If a Class C network uses 255.255.255.240 as a subnet mask, 16 subnets are available, each with 14 IP addresses. If a point-to-point link needs only 2 IP addresses, 12 IP addresses are wasted. This problem scales further with Class B and Class A address spaces. With VLSM, small LANs can use /28 subnets with 14 hosts, and larger LANs can use /23 and /22 masks with 510 and 1022 hosts, respectively. Point-to-point networks use a /30 mask, which supports 2 hosts.
There isn’t one way to subdivide a network, so there is no single correct way to create subnets. The best practice is to divide large networks into smaller subnets that can be assigned to sites. Then you can further divide each site subnet into smaller subnets for data, VoIP, wireless LAN, and other subnets to be used in site VLANs. Furthermore, WAN and point-to-point links, router, and switch loopback addresses are allocated IP subnets.