← Lessons
🖧 Computer Networks for Beginners
Subnet masks
## What does a mask tell us?
An IP address has two parts: the **network part** and the **host part**. The **mask** shows where it splits.
```
IP: 192.168.1.25
Mask: 255.255.255.0 (= /24)
└─ network ┘ └host┘
```
`/24` means the first **24 bits** are the network part.
| Prefix | Mask | Number of hosts |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /16 | 255.255.0.0 | 65 534 |
**Number of hosts = 2^(32 − prefix) − 2**. Why −2? Because:
- **Network address** — the very first address (for example `192.168.1.0`)
- **Broadcast address** — the very last address (for example `192.168.1.255`), used to send to everyone
are never given to computers.
## Are they on the same network?
If two addresses have the same **network part**, they are on the same network and can talk directly through a switch. If not, you need a **router**.
```
192.168.1.10/24 and 192.168.1.200/24 → same network ✅
192.168.1.10/24 and 192.168.2.10/24 → different network ❌
```
> 🧮 Problems: **Networks → Level 5–8**
💡 Want to track which lessons you've read and solve problems for points? Sign up for free or log in.