Subnetting - Subnets
Subnetting is the technique of dividing an IP network into multiple smaller subnets to optimize IP address usage and improve network management.
What is Subnetting?
Subnetting is the process of taking a large IP network and dividing it into smaller subnets using subnet masks. This allows more efficient use of IP addresses and improves network security and performance.
Fundamental Concepts
Subnet Mask
- Function: Defines which part of the IP is network and which part is host
- Format: 32 bits in IPv4, 128 bits in IPv6
- Notation: Dotted decimal (255.255.255.0) or CIDR (/24)
Network Address
- Function: Identifies the specific subnet
- Calculation: IP AND Subnet mask
- Example: 192.168.1.0/24
Broadcast Address
- Function: Address to send to all hosts in the subnet
- Calculation: Last address of the subnet
- Example: 192.168.1.255/24
Host Addresses
- Function: Addresses assignable to devices
- Range: Between network address and broadcast
- Example: 192.168.1.1 - 192.168.1.254
IPv4 Network Classes
Class A
- Range: 1.0.0.0 - 126.255.255.255
- Default mask: 255.0.0.0 (/8)
- Networks: 126 networks
- Hosts per network: 16,777,214 hosts
Class B
- Range: 128.0.0.0 - 191.255.255.255
- Default mask: 255.255.0.0 (/16)
- Networks: 16,384 networks
- Hosts per network: 65,534 hosts
Class C
- Range: 192.0.0.0 - 223.255.255.255
- Default mask: 255.255.255.0 (/24)
- Networks: 2,097,152 networks
- Hosts per network: 254 hosts
Classes D and E
- Class D: 224.0.0.0 - 239.255.255.255 (Multicast)
- Class E: 240.0.0.0 - 255.255.255.255 (Experimental)
CIDR (Classless Inter-Domain Routing)
CIDR Notation
- Format: IP/number of network bits
- Example: 192.168.1.0/24
- Advantage: Flexibility in subnet size
CIDR Mask Table
| CIDR | Mask | Hosts | Subnets |
|---|
| /8 | 255.0.0.0 | 16,777,214 | 1 |
| /16 | 255.255.0.0 | 65,534 | 256 |
| /24 | 255.255.255.0 | 254 | 65,536 |
| /25 | 255.255.255.128 | 126 | 131,072 |
| /26 | 255.255.255.192 | 62 | 262,144 |
| /27 | 255.255.255.224 | 30 | 524,288 |
| /28 | 255.255.255.240 | 14 | 1,048,576 |
| /29 | 255.255.255.248 | 6 | 2,097,152 |
| /30 | 255.255.255.252 | 2 | 4,194,304 |
Subnet Calculation
Binary Method
- Convert IP to binary
- Apply subnet mask
- Identify network and host bits
- Calculate valid addresses
Practical Example
Network: 192.168.1.0/26
Mask: 255.255.255.192
IP: 192.168.1.0
Binary: 11000000.10101000.00000001.00000000
Mask: 11111111.11111111.11111111.11000000
Network bits: 26
Host bits: 6
Hosts per subnet: 2^6 - 2 = 62 hosts
Resulting Subnets
Subnet 1: 192.168.1.0/26
- Network: 192.168.1.0
- Hosts: 192.168.1.1 - 192.168.1.62
- Broadcast: 192.168.1.63
Subnet 2: 192.168.1.64/26
- Network: 192.168.1.64
- Hosts: 192.168.1.65 - 192.168.1.126
- Broadcast: 192.168.1.127
VLSM (Variable Length Subnet Masking)
Concept
- Definition: Use of different subnet masks in the same network
- Advantage: Maximum optimization of address space
- Usage: Networks with different subnet sizes
VLSM Example
Main network: 192.168.1.0/24
Required subnets:
- LAN1: 50 hosts β /26 (62 hosts)
- LAN2: 20 hosts β /27 (30 hosts)
- LAN3: 10 hosts β /28 (14 hosts)
- Point-to-point links: 2 hosts β /30 (2 hosts)
VLSM Assignment
192.168.1.0/26 β LAN1 (50 hosts)
192.168.1.64/27 β LAN2 (20 hosts)
192.168.1.96/28 β LAN3 (10 hosts)
192.168.1.112/30 β R1-R2 Link
192.168.1.116/30 β R2-R3 Link
192.168.1.120/30 β R3-R4 Link
IPv6 Subnetting
IPv6 Characteristics
- Length: 128 bits
- Notation: Hexadecimal separated by colons
- Subnetting: Simpler than IPv4
- Example: 2001:db8::/64
IPv6 Structure
| 48 bits | 16 bits | 64 bits |
| Global | Subnet | Interface ID |
| Routing | ID | (EUI-64) |
IPv6 Subnetting
Main network: 2001:db8::/48
Subnets:
2001:db8:1::/64 β LAN1
2001:db8:2::/64 β LAN2
2001:db8:3::/64 β LAN3
2001:db8:ffff::/64 β Point-to-point links
Online Calculators
- Subnet Calculator: Automatic calculation
- IP Calculator: Advanced tools
- CIDR Calculator: CIDR conversion
Network Commands
1
2
3
4
5
6
| # Linux/Unix
ipcalc 192.168.1.0/26
netmask 192.168.1.0 255.255.255.192
# Windows
netsh interface ip show config
|
- Wireshark: Traffic analysis
- tcpdump: Packet capture
- ping: Connectivity test
- traceroute: Packet route
Best Practices
Subnet Planning
- Requirements analysis: Number of hosts per subnet
- Future growth: Reserve space for expansion
- Documentation: Maintain assignment records
- Standards: Use naming conventions
Address Assignment
- Hierarchy: Logical address structure
- Aggregation: Facilitate routing
- Reservation: Reserve ranges for services
- DHCP: Automate assignment
Security
- Segmentation: Isolate different traffic types
- Firewalls: Filter between subnets
- VLANs: Logical separation
- Monitoring: Monitor traffic between subnets
Common Use Cases
Corporate Network
10.0.0.0/8 (Private network)
Subnets:
10.1.0.0/16 β Headquarters
10.2.0.0/16 β North Branch
10.3.0.0/16 β South Branch
10.10.0.0/24 β Servers
10.20.0.0/24 β DMZ Network
10.30.0.0/24 β Management Network
Data Center
172.16.0.0/12 (Private network)
Subnets:
172.16.1.0/24 β Web Servers
172.16.2.0/24 β DB Servers
172.16.3.0/24 β App Servers
172.16.10.0/24 β Storage Network
172.16.20.0/24 β Management Network
Home Network
192.168.1.0/24 (Private network)
Subnets:
192.168.1.0/26 β Main devices
192.168.1.64/26 β IoT devices
192.168.1.128/26 β Guest network
192.168.1.192/26 β Reserved
Subnet Troubleshooting
Common Problems
- Incorrect configuration: Misconfigured masks
- IP conflicts: Duplicate addresses
- Routing: Incorrect routes
- DHCP: Misconfigured ranges
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| # Verify IP configuration
ip addr show
ifconfig
# Test connectivity
ping 192.168.1.1
ping6 2001:db8::1
# Verify routes
ip route show
route -n
# Verify ARP
arp -a
ip neigh show
|
Verification Commands
1
2
3
4
5
6
7
8
| # Verify subnet mask
ipcalc -m 192.168.1.0/26
# Verify host range
ipcalc -h 192.168.1.0/26
# Verify broadcast
ipcalc -b 192.168.1.0/26
|
References
Glossary
- CIDR: Classless Inter-Domain Routing
- VLSM: Variable Length Subnet Masking
- EUI-64: Extended Unique Identifier
- SLAAC: Stateless Address Autoconfiguration
- DHCPv6: Dynamic Host Configuration Protocol for IPv6
- NDP: Neighbor Discovery Protocol
- RA: Router Advertisement
- RS: Router Solicitation