Subnet Mask Basics
A Subnet Mask acts as a divider or filter for a 32-bit IP address, distinguishing which part of the address is the Network ID (Neighborhood) and which part is the Host ID (House Number).
Computers use the subnet mask to determine if another device is on the same network (direct communication) or a different network (requires a router).
1. Rules of the Subnet Mask
Like an IP address, a subnet mask consists of 32 bits (4 octets) and follows these rules:
- 1 (255): Represents the Network ID portion. (Fixed value)
- 0 (0): Represents the Host ID portion. (User-assignable value)
Most Common Example: 255.255.255.0
- The first three blocks (
255.255.255) identify the network. - The last block (
0) identifies the individual device.
2. Concrete Example (Calculation Process)
Let's look at a typical private network environment.
- My IP Address:
192.168.1.10 - Subnet Mask:
255.255.255.0
Performing a bitwise AND operation (result is 1 only if both bits are 1) reveals the Network ID.
| Category | Decimal Notation | Binary Notation | Meaning |
|---|---|---|---|
| IP Address | 192.168.1.10 |
11000000.10101000.00000001.00001010 |
Full Address |
| Subnet Mask | 255.255.255.0 |
11111111.11111111.11111111.00000000 |
1 is Network, 0 is Host |
| Result (AND) | 192.168.1.0 |
11000000.10101000.00000001.00000000 |
Network ID |
Interpretation: 1. The name (ID) of this network is
192.168.1.0. 2. Within this network, devices from192.168.1.1to192.168.1.254(254 total) can communicate directly. 3. The last number (10) is my unique identifier (Host ID).
3. CIDR Notation (Slash Notation)
Instead of writing the long form 255.255.255.0, we often use CIDR notation, which indicates the number of network bits (1s) after a slash (/).
| Subnet Mask | CIDR Notation | Usable Hosts | Usage |
|---|---|---|---|
255.255.255.0 |
/24 | 254 ($2^8 - 2$) | Home, Small Office (Most common) |
255.255.0.0 |
/16 | 65,534 ($2^{16} - 2$) | Medium-to-Large Networks |
255.0.0.0 |
/8 | ~16 Million ($2^{24} - 2$) | Very Large Networks |
- Note: We subtract 2 from the host count because the very first address (Network Address) and the very last address (Broadcast Address) cannot be assigned to devices.