Subnetting Basics
Subnetting is the process of dividing a large network into smaller networks.
01Why Subnetting?
- Efficiency - Better use of IP addresses
- Security - Isolate networks from each other
- Performance - Reduce broadcast traffic
- Management - Organize the network
02IP Address Structure
IPv4 address consists of 32 bits:
code
192.168.1.100
↓
11000000.10101000.00000001.01100100
Network and Host Part:
code
[Network Part][Host Part]
192.168.1 .100
Network addr Device addr
03Subnet Mask
Subnet mask separates network and host part:
| Subnet Mask | CIDR | Network Bits | Host Bits |
|---|---|---|---|
| 255.0.0.0 | /8 | 8 | 24 |
| 255.255.0.0 | /16 | 16 | 16 |
| 255.255.255.0 | /24 | 24 | 8 |
| 255.255.255.128 | /25 | 25 | 7 |
| 255.255.255.192 | /26 | 26 | 6 |
04CIDR Notation
code
192.168.1.0/24
↓
24 bits network
8 bits host
/24 Example:
code
Mask: 255.255.255.0
Binary: 11111111.11111111.11111111.00000000
←── 24 bits ──→←── 8 bits ──→
Network Host
05Host Calculation
Formula: 2^n - 2 = Number of usable hosts
| CIDR | Host Bits | Total | Usable |
|---|---|---|---|
| /24 | 8 | 256 | 254 |
| /25 | 7 | 128 | 126 |
| /26 | 6 | 64 | 62 |
| /27 | 5 | 32 | 30 |
| /28 | 4 | 16 | 14 |
| /29 | 3 | 8 | 6 |
| /30 | 2 | 4 | 2 |
Why -2?
- 1 address: Network address (first)
- 1 address: Broadcast address (last)
06Special Addresses
Each subnet has 2 special addresses:
code
192.168.1.0/24
Network Address: 192.168.1.0 (unusable)
First Host: 192.168.1.1
Last Host: 192.168.1.254
Broadcast: 192.168.1.255 (unusable)
07Example: /26 Subnetting
Let's divide 192.168.1.0/24 into 4 subnets:
| Subnet | Network | Host Range | Broadcast |
|---|---|---|---|
| 1 | 192.168.1.0 | .1 - .62 | 192.168.1.63 |
| 2 | 192.168.1.64 | .65 - .126 | 192.168.1.127 |
| 3 | 192.168.1.128 | .129 - .190 | 192.168.1.191 |
| 4 | 192.168.1.192 | .193 - .254 | 192.168.1.255 |
08Summary
- Subnetting = Dividing network
- Subnet mask separates network and host
- CIDR notation: /24, /25, /26...
- Host count: 2^n - 2