What is a subnet mask?
sobes.tech AI
Answer from AI
A subnet mask is a 32-bit number (for IPv4) or a 128-bit number (for IPv6) that determines which part of an IP address belongs to the network address and which part belongs to the host address within that network. It is used to divide the IP address into a network part and a host part.
The mask bits set to '1' correspond to the network part of the address, and the bits set to '0' correspond to the host part. When a logical AND operation is applied between the IP address and the subnet mask, the network address is obtained.
Example (IPv4):
- IP address: 192.168.1.10 (binary: 11000000.10101000.00000001.00001010)
- Subnet mask: 255.255.255.0 (binary: 11111111.11111111.11111111.00000000)
Applying logical AND:
11000000.10101000.00000001.00001010 (IP address)
AND
11111111.11111111.11111111.00000000 (Subnet mask)
------------------------------------
11000000.10101000.00000001.00000000 (Network address: 192.168.1.0)
The subnet mask can be represented in dotted decimal notation (e.g., 255.255.255.0) or in CIDR prefix notation (e.g., /24, where 24 is the number of '1' bits in the mask).