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

CIDRMaskHostsSubnets
/8255.0.0.016,777,2141
/16255.255.0.065,534256
/24255.255.255.025465,536
/25255.255.255.128126131,072
/26255.255.255.19262262,144
/27255.255.255.22430524,288
/28255.255.255.240141,048,576
/29255.255.255.24862,097,152
/30255.255.255.25224,194,304

Subnet Calculation

Binary Method

  1. Convert IP to binary
  2. Apply subnet mask
  3. Identify network and host bits
  4. 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

Calculation Tools

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

Network Tools

  • Wireshark: Traffic analysis
  • tcpdump: Packet capture
  • ping: Connectivity test
  • traceroute: Packet route

Best Practices

Subnet Planning

  1. Requirements analysis: Number of hosts per subnet
  2. Future growth: Reserve space for expansion
  3. Documentation: Maintain assignment records
  4. Standards: Use naming conventions

Address Assignment

  1. Hierarchy: Logical address structure
  2. Aggregation: Facilitate routing
  3. Reservation: Reserve ranges for services
  4. DHCP: Automate assignment

Security

  1. Segmentation: Isolate different traffic types
  2. Firewalls: Filter between subnets
  3. VLANs: Logical separation
  4. 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

Diagnostic Tools

 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