Networking Fundamentals

IP Subnetting Guide

Binary math, CIDR notation, address classes, subnet calculation, and VLSM — everything in one reference.

01

IPv4 Address Anatomy

32-Bit Address Structure

Every IPv4 address is 32 bits — written as four 8-bit octets in dotted-decimal notation.

Example: 192.168.10.1
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
192 168 10 1
Bit Position Values (left to right)
128
64
32
16
8
4
2
1
2⁷   2⁶   2⁵   2⁴   2³   2²   2¹   2⁰  → max octet = 255
Network vs Host Bits

A subnet mask divides the 32 bits into a network portion and a host portion.

192.168.10.1 /24 — Network bits (blue) + Host bits (green)
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
24 network bits
8 host bits
Subnet Mask
255
.
255
.
255
.
0
255 = 11111111 in binary  ·  0 = 00000000
02

IPv4 Address Classes

A
1.0.0.0 – 126.255.255.255
Default mask: /8 (255.0.0.0)
Networks: 126
Hosts/net: 16,777,214
First bit: 0xxxxxxx
Large enterprises, ISPs
B
128.0.0.0 – 191.255.255.255
Default mask: /16 (255.255.0.0)
Networks: 16,384
Hosts/net: 65,534
First bits: 10xxxxxx
Universities, medium corps
C
192.0.0.0 – 223.255.255.255
Default mask: /24 (255.255.255.0)
Networks: 2,097,152
Hosts/net: 254
First bits: 110xxxxx
Small offices, LANs
D
224.0.0.0 – 239.255.255.255
Purpose: Multicast groups (OSPF, PIM, IGMP)
First bits: 1110xxxx  ·  Not assignable to hosts
E
240.0.0.0 – 255.255.255.254
Purpose: Reserved / Experimental — never routed publicly
First bits: 1111xxxx  ·  255.255.255.255 = limited broadcast
03

Private & Special Addresses (RFC 1918 / RFC 5735)

RFC 1918 — Private Ranges
Class A 10.0.0.0 /8 16.7M hosts · 1 network
Class B 172.16.0.0 /12 172.16–172.31 · 1M hosts
Class C 192.168.0.0 /16 65K hosts · home / SMB

Private addresses are not routable on the public internet. NAT translates them to a public IP at the network edge.

Special-Purpose Addresses
Loopback 127.0.0.0 /8
127.0.0.1 = localhost — never leaves host
APIPA / Link-Local 169.254.0.0 /16
Auto-assigned when DHCP fails
This Network 0.0.0.0 /8
Limited Broadcast 255.255.255.255
Shared Address Space 100.64.0.0 /10
RFC 6598 — ISP carrier-grade NAT
Documentation 192.0.2.0 /24
TEST-NET-1 (also 198.51.100.0, 203.0.113.0)
04

CIDR Notation & Subnet Mask Reference

Visual — Network vs Host Bit Split by Prefix Length
/8
NET
HOST (24 bits)
16.7M hosts /12
NET
HOST (20 bits)
1M hosts /16
NET
HOST (16 bits)
65,534 /20
NET
HOST (12 bits)
4,094 /24
NET
HOST (8)
254 /28
NET
HOST(4)
14 /30
NET
2
2 hosts
Complete CIDR / Subnet Mask Quick Reference
CIDR Subnet Mask Wildcard Hosts/Subnet Subnets (from /24) Last Octet Increment Common Use
/8255.0.0.00.255.255.25516,777,214Class A network
/9255.128.0.00.127.255.2558,388,606Large ISP block
/10255.192.0.00.63.255.2554,194,302CGN / RFC 6598
/12255.240.0.00.15.255.2551,048,574172.16 private
/16255.255.0.00.0.255.25565,5341256Class B / data center
/17255.255.128.00.0.127.25532,7662128Large campus
/18255.255.192.00.0.63.25516,382464Campus segment
/19255.255.224.00.0.31.2558,190832Building block
/20255.255.240.00.0.15.2554,0941616Large VLAN
/21255.255.248.00.0.7.2552,046328Medium VLAN
/22255.255.252.00.0.3.2551,022644Server farm
/23255.255.254.00.0.1.2555101282Merged /24s
/24255.255.255.00.0.0.2552542561Standard LAN ★
/25255.255.255.1280.0.0.1271262128Half a /24
/26255.255.255.1920.0.0.6362464Small segment
/27255.255.255.2240.0.0.3130832Small team LAN
/28255.255.255.2400.0.0.15141616DMZ / mgmt VLAN
/29255.255.255.2480.0.0.76328Small server group
/30255.255.255.2520.0.0.32644Point-to-point link ★
/31255.255.255.2540.0.0.12*1282P2P (RFC 3021) — no broadcast
/32255.255.255.2550.0.0.012561Host route / loopback
05

Key Formulas

Usable Hosts per Subnet
2h 2 = usable hosts
h = number of host bits (32 − prefix). Subtract 2 for network address and broadcast address.
Example: /24 → 2⁸ − 2 = 254 hosts
Number of Subnets
2s = subnets
s = subnet bits borrowed from host portion.
Example: /24 → /26 borrows 2 bits → 2² = 4 subnets
Block Size / Subnet Increment
256 mask_octet = block size
Applies to the "interesting" octet.
Example: mask = 240 → 256 − 240 = 16 → subnets at 0, 16, 32, 48…
Network Address (AND operation)
IP AND mask = network
Bitwise AND of IP and subnet mask gives the network address.
192.168.10.65 AND 255.255.255.192 = 192.168.10.64
Broadcast Address
network OR wildcard = broadcast
OR the network address with the wildcard mask (inverted subnet mask).
192.168.10.64 OR 0.0.0.63 = 192.168.10.127
Wildcard Mask
255.255.255.255 mask = wildcard
Used in ACLs and OSPF. Invert each octet.
/26 mask 255.255.255.192 → wildcard = 0.0.0.63
06

Worked Example — Subnetting 192.168.10.0 /24 into /26

🔢 Step-by-Step Calculation
1
Identify prefix and host bits
/26 → 26 network bits, 6 host bits
Subnet mask: 255.255.255.192
192 in binary: 11000000
2
Calculate number of subnets
Bits borrowed: 26 − 24 = 2 bits
Subnets: 2² = 4 subnets
3
Calculate hosts per subnet
Host bits: 6
Total: 2⁶ = 64 addresses
Usable: 64 − 2 = 62 hosts
4
Calculate block size
256 − 192 = 64
Subnets increment by 64 in last octet
5
Enumerate all 4 subnets
Subnet 1: 192.168.10.0.63   (hosts: .1–.62)
Subnet 2: 192.168.10.64.127 (hosts: .65–.126)
Subnet 3: 192.168.10.128.191 (hosts: .129–.190)
Subnet 4: 192.168.10.192.255 (hosts: .193–.254)
Subnet Breakdown Table — 192.168.10.0 /26
# Network Addr First Host Last Host Broadcast
1 192.168.10.0/26 192.168.10.1 192.168.10.62 192.168.10.63
2 192.168.10.64/26 192.168.10.65 192.168.10.126 192.168.10.127
3 192.168.10.128/26 192.168.10.129 192.168.10.190 192.168.10.191
4 192.168.10.192/26 192.168.10.193 192.168.10.254 192.168.10.255
Visual Split — 4th Octet Bit Map
0
0
0
0
0
0
0
0
Subnet bits (borrowed)   Host bits
07

VLSM — Variable Length Subnet Masking

What is VLSM?

VLSM allows subnets of different sizes within the same address space — eliminating waste by right-sizing each segment. Used in almost all modern networks.

VLSM Design Rule
Largest subnet Smallest subnet
Always allocate from largest requirement to smallest. Prevents fragmentation and overlap.
Example: Allocate 10.0.0.0 /24 for 4 departments
10.0.0.0 /24 — 254 usable
Sales /25
10.0.0.0–.127
126 hosts
IT /26
10.0.0.128–.191
62 hosts
Mgmt /27
10.0.0.192–.223
30 hosts
P2P /30
10.0.0.224–.227
2 hosts
VLSM Allocation Table
Dept Need Prefix Network Range Hosts
Sales 100 /25 10.0.0.0 .1 – .126 126
IT 50 /26 10.0.0.128 .129 – .190 62
Mgmt 20 /27 10.0.0.192 .193 – .222 30
WAN Link 2 /30 10.0.0.224 .225 – .226 2
Unused / Reserved 10.0.0.228 .228 – .255 28
08

Binary ↔ Decimal Conversion Reference

Common Octet Values — Memorise These
Decimal Binary Used in Mask? Host Bits Remaining Prefix Contribution
0 00000000Yes (host octet)8+0
12810000000Yes7+1
19211000000Yes6+2
22411100000Yes5+3
24011110000Yes4+4
24811111000Yes3+5
25211111100Yes2+6
25411111110Yes1+7
25511111111Yes (net octet)0+8
09

Mental Math Tips & Exam Tricks

Block size shortcut: The block size in the "interesting" octet is always 256 − mask_octet. For /26 → 256−192 = 64. Subnets land on multiples of 64.
🧮
Powers of 2 — memorise: 2¹=2, 2²=4, 2³=8, 2⁴=16, 2⁵=32, 2⁶=64, 2⁷=128, 2⁸=256, 2¹⁰=1024, 2¹⁶=65536, 2²⁴=16.7M
🎯
Is an IP in a subnet? Find the network address (IP AND mask). If the result equals the subnet's network address, the IP is in that subnet.
📌
Network = all host bits 0. Broadcast = all host bits 1. Everything between those two is usable. The first host = network+1, last host = broadcast−1.
🔗
Point-to-point links: Use /30 (2 usable hosts) in traditional setups, or /31 per RFC 3021 on modern routers — saves addresses on WAN links.
🏷️
Supernetting (route aggregation): Combine contiguous subnets into a larger block by reducing the prefix. Four /24s → one /22. The block must start on a boundary.
🔄
Boundary check: A subnet must start on a multiple of its block size. 10.0.0.64/26 is valid (64 ÷ 64 = 1). 10.0.0.70/26 is NOT (70 is not a multiple of 64).
📐
VLSM — always size for growth: If you need 100 hosts, pick /25 (126 usable) not /26 (62 usable). Leave room — re-addressing is painful.
🌐
Wildcard mask for ACLs: Invert the subnet mask. /24 → 0.0.0.255. Used in Cisco ACLs and OSPF network statements to match ranges.
🔢
/24 subnetting shortcut: The number of subnets = 2^(new prefix − 24) and hosts per subnet = 256 / subnets − 2. Fast for Class C splits.
🛑
Reserved per subnet — always 2: Network address (all host bits 0) and broadcast (all host bits 1) are never assignable to hosts, regardless of subnet size. Except /31.
🔍
Quick prefix-to-mask: Count 1s from left. 8×255 for full octets, then the "magic" octet value for the partial one. /20 → 255.255.240.0