Subnet Mask is a 32-bit number that is used to partition IP addresses into a network ID and a host ID. Subnet masks are used by TCP/IP services and applications to determine whether a given IP address on an internetwork is a local network address or a remote network address.

How It Works
Subnet masks are represented as four-octet dotted-decimal numbers, just as IP addresses are, except that the most common values for an octet in a subnet mask are 0 and 255. In binary notation, decimal 0 represents the octet 00000000, and decimal 255 represents 11111111.
A subnet mask consists of 32 binary digits, the first n of which are 1s and the remaining of which are 0s. When the subnet mask is logically ANDed with a 32-bit IP address of a TCP/IP host, the result is the network ID of the host – the portion of the host’s IP address that identifies which network the host is on. When the inverse of the subnet mask (for example, NOT mask) is logically ANDed with the IP address of the host, the result is the host ID of the host – the portion of the host’s IP address that uniquely identifies the host on its network.
For example, consider the IP address 207.61.16.119 and the subnet mask 255.255.255.0. Converting these two numbers to binary and ANDing them gives the host’s Network ID:
Host = 11001111 00111101 00010000 01110111
Mask = 11111111 11111111 11111111 00000000
AND = 11001111 00111101 00010000 00000000
= 207.61.16.0 = network ID
Taking the logical NOT of the subnet mask and ANDing it with the host’s IP address gives the host’s Host ID:
Host = 11001111 00111101 00010000 01110111
NOT Mask = 00000000 00000000 00000000 11111111
AND = 00000000 00000000 00000000 01110111
= 0.0.0.119 = host ID
Two types of subnet masks are used in TCP/IP networking:
- Default subnet masks: Partition IP addresses into their network ID and host ID portions
- Custom subnet masks: Further partition the network ID into a number of separate subnets by using a process called subnetting
Default subnet masks
The default subnet masks for IP address classes A, B, and C are shown in the following table. The table also shows how these subnet masks would partition an IP address such as w.x.y.z into a network ID and a host ID portion.
Default Subnet Masks for IP Addresses
Class | Default Subnet Mask | Network ID | Host ID |
A | 255.0.0.0 | w | x.y.z |
B | 255.255.0.0 | w.z | y.z |
C | 255.255.255.0 | w.x.y | z |
Ascend routers
Some TCP/IP configuration programs, such as those for Ascend routers, use a different notation for specifying subnet masks. They append a suffix of the form /n to the host’s IP address to indicate the subnet mask, in which n equals the number of binary 1s in the subnet mask. Thus, for example, 207.61.16.119/24 signifies 207.61.16.119/255.255.255.0.