The Role of Subnet Masks
Subnet masks designate which bits of an IP address represent the network portion and which bits represent the host portion. Default subnet masks are used with Class A, Class B, and Class C IP addresses, as follows:
Class A: 255.0.0.0
Class B: 255.255.0.0
Class C: 255.255.255.0
The Class A subnet mask tells you the first 8 bits of the IP address represent the network portion of the address. The remaining 24 bits represent the host portion of the address. Let's say a host has the IP address 10.25.65.32. Using the default subnet mask, the network address would be 10.0.0.0. The host component of the address would be 25.65.32.
The Class B subnet mask tells you the first 16 bits of the IP address represent the network portion of the address. The remaining 16 bits represent the host address within the network. If a host has the IP address 172.20.33.33, the network portion of the address would be 172.20.0.0. The host component would be 33.33.
The Class C subnet mask tells you the first 24 bits of the IP address represent the network portion of the address. The remaining 8 bits represent the host address within the network. If a host has the IP address 192.168.2.3, the network portion of the address would be 192.168.2.0. The host component would be 3.
The ANDing Process
When a source host attempts to communicate with a destination host, the source host uses its subnet mask to determine whether the destination host is on the local network or a remote network. This is known as the ANDing process.
The AND function has the following properties:
If the two compared values are both 1, the result is 1.
If one of the values is 0 and the other is 1, the result is 0.
If both of the compared values are 0, the result is 0.
The source and destination IP addresses are compared to the source's subnet mask using the ANDing process. An AND result is created for each of the addresses. If the result is the same, the hosts are on the same network. If the result is different, the destination host is on a remote network. All traffic destined for that remote host should be directed to the router indicated in the source host's routing table. If no explicit route is defined in the routing table, the traffic is directed to the source host's default gateway.
Figure 3.4 shows two hosts that want to communicate. Host A (with IP address 172.16.2.4) wants to communicate with Host B (with IP address 172.16.3.5). If the subnet mask for Host A is 255.255.0.0, will the hosts communicate using local transmissions or will they send information to the default gateway?
Figure 3.4 Using the ANDing process.
When converted to binary, the address 172.16.2.4 is as follows:
10101100 00010000 00000010 00000100
When converted to binary, the address 172.16.3.5 is as follows:
10101100 00010000 00000011 00000101
If the ANDing process is performed, the result for Host A using its subnet mask of 255.255.0.0 is
HOST A's IP Address 10101100 00010000 00000010 00000100 Host A's Subnet Mask 11111111 11111111 00000000 00000000 ANDING Result 10101100 00010000 00000000 00000000
The result for Host B is
HOST B's IP Address 10101100 00010000 00000011 00000101 Host A's Subnet Mask 11111111 11111111 00000000 00000000 ANDing Result 10101100 00010000 00000000 00000000
As you can see, the two results match. This indicates that, as far as Host A is concerned, the two hosts are on the same physical network. Communication can occur directly between the two hosts. In fact, the same holds true because host B would have the same subnet mask since the hosts are on the same network.
Day 5, "The Art of Subnet Masking," further examines the art of subnet masking. It also examines the use of nonstandard subnet masking to further segment a group of IP addresses into smaller segments. This process, which ignores the default subnet masks used by address classes, is commonly referred to as Classless Internet Domain Routing (CIDR).
Common Subnet Mask Problems
As previously discussed, the subnet mask determines whether a destination host is on the local network or a remote network. Most troubleshooting of subnet masking is performed using the WINIPCFG, IPCONFIG, and PING utilities.
The IPCONFIG Utility
In some TCP/IP implementations, the IPCONFIG utility is called IFCONFIG. Whatever the name, this utility reveals the current TCP/IP configuration for the host on which the command is run. This includes the configuration of the IP address, subnet mask, default gateway and DNS server, and other TCP/IP configuration settings.
The following are symptoms that incorrect subnet masks have been implemented on your network:
You can communicate with hosts on the local network, but you can't communicate with remote hosts.
You can communicate with all hosts on the remote network except one specific host. When you try to communicate with that host, you receive messages such as Timed out warnings.
You can't communicate with a host on the local network because your host believes it is located on a remote network and incorrectly forwards the packet to the default gateway.