~/geeksubnet/learn

Learn subnetting

A practical guide for network engineers, sysadmins and students. Last updated 2026.

This page explains how IP subnetting works, what CIDR notation actually means, how to calculate network and broadcast addresses by hand, how VLSM packs multiple sub-networks inside a parent, and why IPv6 doesn't need a broadcast address. If you came here from a search engine looking for a quick answer, scroll to the FAQ section. If you want the full picture, read it through.

You can plug any of the worked examples below directly into the live geeksubnet calculator to verify the numbers.

// table of contents

1. IPv4 basics: octets, bits, classes

An IPv4 address is a 32-bit number written as four 8-bit octets separated by dots. The address 192.168.1.42 in binary is:

11000000.10101000.00000001.00101010
  192    .  168   .   1    .   42

Each octet is a number from 0 to 255 because 8 bits give 28 = 256 possible values. The full address space is 232 ≈ 4.3 billion unique addresses — which sounded like plenty in 1981 and turned out to be the reason IPv6 exists.

Historically IPv4 addresses were grouped into classes (A, B, C, D, E) based on the leading bits, which fixed the size of the network portion. Classful addressing was abandoned in 1993 in favor of CIDR. Today the only thing left of "class" is a label some calculators still display.

2. CIDR notation

CIDR — Classless Inter-Domain Routing — replaced classful addressing with a flexible prefix length approach. Instead of assuming the network/host split is fixed, you write it explicitly: 192.168.1.0/24 means "the first 24 bits identify the network, the remaining 8 are for hosts".

A /24 has 8 host bits → 28 = 256 total addresses, of which 2 are reserved (network and broadcast), leaving 254 usable host addresses. A /16 has 16 host bits → 65,536 total. A /30 has 2 host bits → 4 total, 2 usable (perfect for point-to-point links between two routers).

The prefix can range from /0 (the entire IPv4 space, used as the default route) up to /32 (a single host).

3. The subnet mask

The subnet mask is the same idea expressed in dotted-decimal: a 32-bit number where leftmost bits are 1 (network) and rightmost are 0 (host). /24 as a mask is 255.255.255.0; /16 is 255.255.0.0; /30 is 255.255.255.252.

To find the network address from any IP and mask, you AND them bit by bit. Take 192.168.1.42 / 255.255.255.0:

IP   : 11000000.10101000.00000001.00101010
mask : 11111111.11111111.11111111.00000000
AND  : 11000000.10101000.00000001.00000000  →  192.168.1.0

The wildcard mask is the bitwise NOT of the subnet mask. For /24 it's 0.0.0.255. Cisco ACLs use wildcards instead of regular masks, which trips up everyone exactly once.

4. Network and broadcast addresses

Inside any subnet, two addresses are reserved:

For 192.168.1.0/24: network = 192.168.1.0, broadcast = 192.168.1.255, usable host range = 192.168.1.1 to 192.168.1.254.

Two important corner cases: a /31 has no broadcast and no network — both addresses are usable for two-hosts point-to-point links (RFC 3021). A /32 identifies a single host with no usable range.

5. VLSM — packing variable-size subnets

VLSM (Variable Length Subnet Masking) means subnetting with different prefix lengths inside one parent network — the right way to allocate address space without waste.

Suppose you have 10.0.0.0/16 and four departments needing 500, 100, 50 and 25 hosts. Naïvely giving each department a /24 wastes thousands of addresses. With VLSM:

  1. Sort by host count, descending.
  2. For each department, find the smallest prefix that fits N+2 hosts (network + broadcast).
  3. Allocate it from the start of the parent and advance the cursor.
DepartmentHosts neededAllocatedRange
Engineering50010.0.0.0/2310.0.0.1 – 10.0.1.254 (510 usable)
Sales10010.0.2.0/2510.0.2.1 – 10.0.2.126 (126 usable)
Ops5010.0.2.128/2610.0.2.129 – 10.0.2.190 (62 usable)
Guest WiFi2510.0.2.192/2710.0.2.193 – 10.0.2.222 (30 usable)

Total used: 728 addresses out of 65,536 in the /16. The rest stays free for future growth. Try the worked example in the geeksubnet VLSM solver.

6. Supernetting / aggregation

Supernetting is the inverse of subnetting: combining several adjacent networks into a single shorter prefix. Routing protocols love this because it reduces the size of routing tables.

Example: 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24 all share the prefix 192.168.0.0/22. Advertising one /22 instead of four /24s is what BGP route aggregation does at internet scale.

Aggregation only works when the networks are contiguous and on a power-of-two boundary. 192.168.0.0/24 + 192.168.2.0/24 can't be supernetted because 192.168.1.0/24 is in the middle.

7. IPv6: same idea, bigger numbers

IPv6 is 128 bits instead of 32. Written as eight 16-bit groups in hexadecimal separated by colons: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Compression rules let you collapse leading zeros and replace one run of zero groups with ::: 2001:db8:85a3::8a2e:370:7334.

IPv6 has no broadcast — multicast handles all one-to-many delivery. The address space is 2128 ≈ 3.4 × 1038, big enough that wasting a /64 per LAN is the norm rather than the exception.

Common prefix scopes:

8. Common subnets cheat sheet

CIDRMaskTotalUsableTypical use
/30255.255.255.25242point-to-point links
/29255.255.255.24886tiny subnet, lab, mgmt
/28255.255.255.2401614small office segment
/27255.255.255.2243230small VLAN
/26255.255.255.1926462medium VLAN
/25255.255.255.128128126half a /24
/24255.255.255.0256254"the classic LAN"
/23255.255.254.0512510large department
/22255.255.252.010241022building / floor
/16255.255.0.06553665534"a class B"
/8255.0.0.01677721616777214"a class A"

9. FAQ

What does /24 mean in an IP address?

It means the first 24 bits of the 32-bit address identify the network, leaving 8 bits for hosts. A /24 has 256 addresses, of which 254 are usable (network and broadcast are reserved).

How do I calculate the broadcast address?

Take the network address and set every host bit to 1. For 192.168.1.0/24, the host bits are the last 8 — set them all to 1 and you get 192.168.1.255.

What is the difference between /30 and /31?

A /30 gives you 4 addresses with 2 usable hosts plus network and broadcast. A /31 gives 2 addresses with both usable per RFC 3021, designed specifically for two-host point-to-point links to save addresses.

How many usable hosts in a /22?

A /22 has 10 host bits → 1024 total addresses. Subtract 2 (network + broadcast) = 1022 usable hosts.

What is the subnet mask for /27?

255.255.255.224. The 224 in the last octet is binary 11100000 — the leading three 1s are part of the network prefix that extends past the third octet boundary.

What is RFC 1918?

RFC 1918 defines three private IPv4 ranges that are never routed on the public internet: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They're used for internal networks behind NAT.

What does CIDR stand for?

Classless Inter-Domain Routing. It's the system that replaced classful IP allocation in 1993, letting prefixes be any length from /0 to /32 instead of fixed at /8, /16, or /24.

Why is the loopback address 127.0.0.1?

The entire 127.0.0.0/8 block is reserved for loopback. By convention everyone uses 127.0.0.1, but any address in that range refers to the local host.

What is VLSM and when do I use it?

VLSM lets you subdivide a network into pieces of different sizes. Use it whenever your subnets need different host counts — e.g. a 500-host department and a 4-router point-to-point link shouldn't both consume a /24.

How do I aggregate multiple networks into one?

Find the longest prefix length that's still common to all networks. 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24 all share the first 22 bits, so they aggregate to 192.168.0.0/22. The networks must be contiguous and aligned to a power-of-two boundary.

Does IPv6 have a broadcast address?

No. IPv6 dropped broadcast entirely. One-to-many delivery is handled by multicast (ff00::/8), which is more efficient because hosts only process traffic for groups they've joined.

What does 169.254.x.x mean?

It's the link-local block (169.254.0.0/16). Hosts auto-configure a 169.254 address when DHCP fails. Seeing one usually means: your DHCP server is unreachable, or the network cable is unplugged, or the WiFi associated but couldn't get a lease.

Is 0.0.0.0/0 a valid network?

It represents the entire IPv4 address space — the "default route" in routing tables. A packet matched by 0.0.0.0/0 is sent toward the upstream gateway when no more specific route exists.

Try the calculator → ← back to geeksubnet