Subnet Mask
Table of Contents
Subnet Mask
A subnet mask is a 32-bit binary mask used to divide an IP Address into two parts: the network portion and the host portion.
The network portion identifies the network to which a host belongs, while the host portion identifies a specific host within that network.
Key Concepts
- Network portion: The bits in the subnet mask that are set to 1.
- Host portion: The bits in the subnet mask that are set to 0.
- Network prefix: The number of bits in the network portion of the subnet mask.
Subnet Mask Notation
Subnet masks are often expressed in dotted decimal notation, similar to IP addresses.
For example, a subnet mask of 255.255.255.0 has a network prefix of 24 bits and a host portion of 8 bits.
Common Subnet Masks
- Class A:
255.0.0.0(8 bits network, 24 bits host) - Class B:
255.255.0.0(16 bits network, 16 bits host) - Class C:
255.255.255.0(24 bits network, 8 bits host) - Class D:
240.0.0.0(28 bits network, 4 bits host) - Class E:
255.255.255.255(32 bits network, 0 bits host)
Calculating the Number of Hosts
The number of hosts in a subnet can be calculated using the formula:
Number of hosts = 2(number of host bits) - 2 For example, a subnet mask of 255.255.255.0 has a host portion of 8 bits, so it can accommodate 28 - 2 = 254 hosts.