Advanced:subnet mask
From ProPHOTO WIKI
Contents |
Introduction
Since IP Addresses are used across multiple networks, the address is actually segmented and each portion used for a different function. The subnet mask is used to determine how the address is aranged, so that devices know how to make use of it correctly. As such, it is a critical setting that must be configured on all devices connected to a network.
Note: The following sections detail the operation of the use of subnet masks on IP networks. This is an advanced topic and most users will not have to understand these details to set up a small network. The information has been provided for those who are interested in digging a little deeper.
Applying the Subnet Mask
The subnet mask is applied by using a logical AND operation on the bits composing it and the IP Address in question. This means that the octets lining up with 255s in the subnet mask are the subnetwork portion. That number is used to identify individual networks within a larger structure. The remaining octets are the host number and uniquely identify the individual hosts on the network. For instance, if the address 192.168.101.103 was on a network using a subnet mask of 255.255.255.0, then the subnet number would be 192.168.101.x and the host number would be 103.
Note that octets in the subnet mask can be values other than 0 or 255. When this is the case, the binary form of the subnet mask needs to be expanded and compared to the binary form of the IP Address. Any bits that appear as 1 in both the address and subnet mask should be carried through, while others should remain set to 0. See figure 1 for an illustration of this technique using a subnet mask of 255.255.254.0.
Subnetting
When attempting to communicate with another host, devices must first determine whether that host is on the local network. If the device is connected to an external network, then it must use a router to find the target device. If, however, it is a local device then it can attempt to contact it directly.
This determination is done by looking at the subnetwork portion of the IP Address. On a network using the subnet mask 255.255.255.0, for instance, the first three octets of the address are examined. If the two addresses share the same subnetwork, then the device will attempt to communicate directly. If they are different, however, it will contact the router to try and reach the target device.
For instance, if the laptop (192.168.0.100) in figure 2 wanted to send a message to the desktop (192.168.0.101) it would first compare the IP Addresses. As both hosts have the same subnet number (the red portion), the laptop will simply send the message directly to the desktop.
If, however, it then wanted to communicate with the handheld computer (192.168.1.100) it would see that it is on a seperate subnetwork. At this stage, it would contact router A (192.168.0.1) on its network and ask it to send the message to the handheld. The router would then use the subnetwork number to find the desired network and eventually forward it on to router B (192.168.1.1). At that stage it would finally be delivered to the handheld.
Routing
Routers on the network maintain tables containing lists of where other local subnetworks are located and how to properly route data between them. When the subnetwork is outside of that local list, each router will pass it along to a higher-level router until one is found that can route it appropriately. As such, the information provided by the subnet number is critical to communication between interconnected networks.
Ramifications
The primary ramification that most users will run into is the limitations it imposes on usable IP Addresses. As noted above, for devices to be able to directly communicate they must share the same subnetwork number. For instance, on a network using a subnet mask of 255.255.255.0 the first three numbers in the addresses of all devices must be identical. If any of those numbers are different, then devices will not be able to directly communicate with one another.

