IP Addressing & Subnetting: A Comprehensive Guide

IP Addressing & Subnetting: A Comprehensive Guide

IP Addressing & Subnetting: A Comprehensive Guide

1) Introduction

IP addressing and subnetting are core concepts in networking. This guide provides a practical, in-depth walkthrough of IPv4/IPv6 addressing, subnet masks, CIDR, VLSM, route summarization, and plenty of worked examples with verification steps.

  • Audience: Students, network technicians, and engineers preparing for certifications.
  • Prerequisites: Basic binary/decimal familiarity and general network fundamentals.
  • Outcomes: Design efficient subnets, calculate ranges, and validate configurations.

2) IPv4 Addressing Fundamentals

An IPv4 address is 32 bits, commonly written in dotted decimal (e.g., 192.168.10.42). Each octet ranges from 0–255.

  • Binary structure: 32 bits split into 4 octets (8 bits each).
  • Two portions: Network and Host.
  • Mask defines how many bits belong to the network portion.

2.1 Classes (Legacy, for reference)

ClassRangeDefault MaskNotes
A0.0.0.0 – 127.255.255.255255.0.0.0 (/8)Very large networks
B128.0.0.0 – 191.255.255.255255.255.0.0 (/16)Medium networks
C192.0.0.0 – 223.255.255.255255.255.255.0 (/24)Small networks
D224.0.0.0 – 239.255.255.255N/AMulticast
E240.0.0.0 – 255.255.255.255N/AExperimental

2.2 Private vs Public IPv4

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

Private addresses are not routable on the public Internet and typically require NAT to reach external networks.

2.3 Special-use Addresses

  • Loopback: 127.0.0.0/8 (commonly 127.0.0.1)
  • Link-local: 169.254.0.0/16 (APIPA)
  • Network/Direct broadcast (per subnet)
  • RFC 1918 (private), RFC 5737 (documentation: 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24)

3) Subnet Masks and CIDR

The subnet mask determines how many bits identify the network. CIDR notation expresses this with a slash (e.g., /24).

3.1 Common Masks

CIDRMask# Hosts/SubnetIncrement
/24255.255.255.02541 in 4th octet
/25255.255.255.128126128 in 4th octet
/26255.255.255.1926264 in 4th octet
/27255.255.255.2243032 in 4th octet
/28255.255.255.2401416 in 4th octet
/29255.255.255.24868 in 4th octet
/30255.255.255.25224 in 4th octet
Example: Given 192.168.10.0/26
  • Block size: 64 (256 - 192)
  • Subnets: 192.168.10.0, .64, .128, .192
  • Pick subnet 192.168.10.128/26 → range .129 – .190, broadcast .191

3.2 Binary View

IP:     192.168.10.42  = 11000000.10101000.00001010.00101010
Mask:   255.255.255.192= 11111111.11111111.11111111.11000000 (/26)
Network:192.168.10.0   = 11000000.10101000.00001010.00000000
Host:                 =                         00101010
    

4) VLSM (Variable Length Subnet Mask)

VLSM lets you allocate different mask lengths per subnet to fit host counts precisely.

Requirement: From 10.10.10.0/24, create subnets for: 60 hosts, 30 hosts, 12 hosts, 2 hosts.
  1. Sort by size: 60 → /26 (62 hosts), 30 → /27 (30 usable), 12 → /28 (14), 2 → /30 (2).
  2. Allocate sequentially:
    • 10.10.10.0/26 → .1 – .62 (broadcast .63)
    • 10.10.10.64/27 → .65 – .94 (broadcast .95)
    • 10.10.10.96/28 → .97 – .110 (broadcast .111)
    • 10.10.10.112/30 → .113 – .114 (broadcast .115)
  3. Remaining: 10.10.10.116 – 10.10.10.255 for future needs.

5) Route Summarization (Supernetting)

Summarization reduces routing table size by aggregating contiguous networks with common prefix bits.

Given: 172.16.8.0/24, 172.16.9.0/24, 172.16.10.0/24, 172.16.11.0/24

Binary 3rd octet: 00001000, 00001001, 00001010, 00001011 → common prefix 000010

Summary: 172.16.8.0/22 (covers .8–.11)

6) Practical Subnetting Exercises

6.1 Exercise A

Network: 192.168.50.0/24. Create 5 subnets with ≥ 25 hosts each.

  1. Needed hosts per subnet: ≥25 → /27 (30 usable). Number of /27 subnets in /24: 8.
  2. Subnets: .0, .32, .64, .96, .128, .160, .192, .224
  3. Pick first five:
    • .0/27 → .1 – .30 (broadcast .31)
    • .32/27 → .33 – .62 (broadcast .63)
    • .64/27 → .65 – .94 (broadcast .95)
    • .96/27 → .97 – .126 (broadcast .127)
    • .128/27 → .129 – .158 (broadcast .159)

6.2 Exercise B

From 10.0.0.0/8, carve out 16 equal subnets for WAN regions.

  • 16 subnets → need 4 extra network bits → /12 (255.240.0.0)
  • Regional blocks: 10.0.0.0/12, 10.16.0.0/12, ... 10.240.0.0/12 (increments of 16 in 2nd octet)

6.3 Exercise C

Given 172.20.100.0/23, find usable range for the second /24 inside.

  • /23 spans 172.20.100.0 – 172.20.101.255
  • /24 blocks inside: 172.20.100.0/24 and 172.20.101.0/24
  • Second /24 usable: 172.20.101.1 – 172.20.101.254 (broadcast .255)

7) IPv6 Essentials

IPv6 uses 128-bit addresses in hexadecimal, separated by colons (e.g., 2001:0db8::1). It eliminates NAT in many designs and supports enormous addressing space.

7.1 Notation and Shortening

  • Leading zeros can be omitted in each hextet.
  • One sequence of consecutive all-zero hextets can be replaced with :: once.
  • Example: 2001:0db8:0000:0000:0000:0000:0000:0001 → 2001:db8::1

7.2 Prefixes

  • Typical LAN: /64
  • Point-to-point: /127 (per RFC 6164) or /64 with SLAAC disabled
  • Global Unicast: 2000::/3
  • Link-local: fe80::/10
  • Unique Local: fc00::/7 (commonly fd00::/8)

7.3 IPv6 Subnetting

Given 2001:db8:abcd::/48, create 4 /64 LANs.

  • /48 → /64 needs 16 bits for subnet IDs.
  • Allocate: 2001:db8:abcd:0000::/64, :0001::/64, :0002::/64, :0003::/64

8) Tools and Commands

8.1 Linux

# Show addresses and routes
ip addr
ip -4 route
ip -6 route

# Add address and default route
sudo ip addr add 192.168.10.10/24 dev eth0
sudo ip route add default via 192.168.10.1
    

8.2 Windows

# Show configuration
ipconfig /all
route print

# Set IP (PowerShell)
New-NetIPAddress -InterfaceAlias "Ethernet0" -IPAddress 192.168.10.10 -PrefixLength 24 -DefaultGateway 192.168.10.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet0" -ServerAddresses 1.1.1.1,8.8.8

Post a Comment

0 Comments