HomeGuidesHow to Subnet IPv4 Networks

How to Subnet IPv4 Networks

8 min readUpdated June 2026Subnetting

Subnetting is the process of dividing a large IP network into smaller segments. Every router, every network design, and every CompTIA Network+ exam question about subnetting follows the same rules — once you understand them, the maths becomes quick and predictable.

Why subnetting exists

Without subnetting, every device on a network would be in the same broadcast domain. A broadcast sent by one device reaches every other device — fine for 20 hosts, catastrophic for 2,000. Subnetting creates smaller broadcast domains, improves security (devices in different subnets need a router to communicate), and makes IP address allocation efficient.

IPv4 address structure

Every IPv4 address is 32 bits, written as four octets (e.g. 192.168.1.100). The address has two parts:

  • Network portion — identifies which network the address belongs to
  • Host portion — identifies the specific device within that network

The subnet mask (or CIDR prefix) defines where the split is. A /24 means the first 24 bits are network, the last 8 are host.

CIDR notation

CIDR (Classless Inter-Domain Routing) notation writes the prefix length after a slash: 192.168.1.0/24. This replaces the old class-based system and the verbose dotted-decimal mask (255.255.255.0). Both mean the same thing — you'll need to recognise both on exams.

Key formula
Usable hosts = 2^(32 − prefix) − 2. The −2 removes the network address (all host bits = 0) and the broadcast address (all host bits = 1). A /26 gives 2^(32−26) − 2 = 2^6 − 2 = 62 usable hosts.

The fast subnetting method

On timed exams you need a method that works in under 30 seconds. Here it is:

Step 1 — Find the block size

Block size = 256 − interesting octet of the subnet mask. For a /26 the mask is 255.255.255.192, so block size = 256 − 192 = 64.

Step 2 — List the network addresses

Starting from 0, add the block size each time: 0, 64, 128, 192. These are your four /26 networks within a /24.

Step 3 — Find the ranges

Given 192.168.1.100/26: the host (100) falls in the 64–127 range. So:

Network address:   192.168.1.64
First usable host: 192.168.1.65
Last usable host:  192.168.1.126
Broadcast:         192.168.1.127

Common prefix reference

PrefixMaskHostsBlock size
/24255.255.255.0254256
/25255.255.255.128126128
/26255.255.255.1926264
/27255.255.255.2243032
/28255.255.255.2401416
/29255.255.255.24868
/30255.255.255.25224

VLSM — Variable Length Subnet Masking

VLSM lets you assign different-sized subnets to different segments, wasting as few addresses as possible. The approach: sort your requirements largest to smallest, assign the smallest subnet that fits each one.

Example: you need subnets for 50 hosts, 20 hosts, and a point-to-point WAN link. Assign /26 (62 hosts), /27 (30 hosts), and /30 (2 hosts) respectively.

Exam tip
CompTIA N+ nearly always asks you to find the "most efficient" subnet for a given host count — that means the smallest prefix that still fits. For 50 hosts, /27 (30 hosts) is too small; /26 (62 hosts) is correct.
🧮
Practice in NetForge
IP Subnet Calculator — practise in your browser →
🌳
Practice in NetForge
VLSM Planner — design address plans interactively →
Free access

Get exam-ready with every lab and mock exam

Every interactive lab and CompTIA Network+ and Security+ exam practice feature is open to everyone at no cost.