IP Subnetting: the critical facts

Everything you need to read, plan and troubleshoot subnets — IPv4 and IPv6.

What is a subnet?

An IP network is split into subnets so routers know which addresses live together on one link. The prefix length (the /24 in 192.168.1.0/24) says how many leading bits of the address identify the network; the remaining bits identify hosts inside it. Fewer network bits = bigger subnet; more network bits = more, smaller subnets.

The one rule that matters: two devices can talk directly only if they agree they are in the same subnet — same network bits, same mask. Mismatched masks are one of the most common causes of "it pings sometimes" problems.

IPv4 essentials

IPv4 CIDR table

CIDRNetmaskTotal IPsUsable hostsTypical use
/32255.255.255.25511Host route / loopback
/31255.255.255.25422Point-to-point link
/30255.255.255.25242Legacy point-to-point
/29255.255.255.24886Small DMZ / static block from ISP
/28255.255.255.2401614Small office
/27255.255.255.2243230Branch site
/26255.255.255.1926462Department VLAN
/25255.255.255.128128126Larger VLAN
/24255.255.255.0256254The classic LAN
/23255.255.254.0512510Two /24s merged (watch broadcast volume)
/22255.255.252.01,0241,022Campus VLAN / large DHCP scope
/20255.255.240.04,0964,094Site aggregate
/16255.255.0.065,53665,534Organisation aggregate
/8255.0.0.016,777,21616,777,21410.0.0.0/8 private space

Reserved & special IPv4 ranges (memorise these)

RangePurpose
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private addressing (RFC 1918) — never routed on the internet
100.64.0.0/10Carrier-grade NAT (RFC 6598) — seen on ISP connections without a real public IP
127.0.0.0/8Loopback (localhost)
169.254.0.0/16Link-local / APIPA — a device showing this failed to get DHCP
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Documentation ranges (safe for examples)
224.0.0.0/4Multicast
240.0.0.0/4Reserved / experimental

Subnetting by hand: a 60-second method

  1. Take the prefix, e.g. /27. Host bits = 32 − 27 = 5, so the block size is 25 = 32.
  2. Subnets start at multiples of the block size in the "interesting" octet: .0, .32, .64, .96, .128 …
  3. Your address falls in the block at or below it: 10.1.1.70/27 → network 10.1.1.64, broadcast 10.1.1.95, hosts .65–.94.

Use the calculator to verify your working.

IPv6 essentials

Anatomy of a global unicast address

A typical address splits into three parts. Everything you do when "subnetting IPv6" happens in the middle one:

Global routing prefixSubnet IDInterface ID
Example2001:db8:acad00ff0000:0000:0000:0001
Bits48 (from your provider)16 (yours to plan)64 (identifies the host)
Who controls itISP / RIRYouThe device (SLAAC) or you (static/DHCPv6)

With a /48 allocation you get a 16-bit Subnet ID — 65,536 LANs — and you never think about host counts again: every LAN holds 264 addresses regardless.

Subnet on the nibble

Each hex digit is 4 bits — a nibble. Subnet on nibble boundaries (/48 → /52 → /56 → /60 → /64) and prefixes stay readable: each step changes exactly one hex digit, so you can see subnet membership at a glance and delegate reverse DNS (ip6.arpa) cleanly. A /54 "works" but makes humans and DNS miserable.

Inside a /48You getEach is
split to /5216 blocks4,096 /64s — e.g. one per region or building
split to /56256 blocks256 /64s — e.g. one per site or customer
split to /604,096 blocks16 /64s — e.g. one per small office
split to /6465,536 LANsone VLAN each

Try it live: put 2001:db8::/48 into the calculator and use "Split this subnet".

A worked /48 plan

A common convention: spend the first nibble of the Subnet ID on function, the rest on instance:

PrefixUse
2001:db8:acad:0000::/64Network infrastructure (loopbacks, management)
2001:db8:acad:1xx::/64Staff VLANs (101 = site 1, 102 = site 2…)
2001:db8:acad:2xx::/64Servers / DMZ
2001:db8:acad:3xx::/64Guest / IoT
2001:db8:acad:fxx::/64Labs and testing

Hex digits in prefixes can encode meaning (site number, VLAN id) — something IPv4 never had room for. Many shops simply put the VLAN number in the subnet ID: VLAN 20 → …:20::/64.

How hosts get addresses (and why /64 is sacred)

IPv6 subnetting facts & myths

IPv6 prefix table

PrefixContainsTypical use
/3265,536 /48sISP / LIR allocation
/4865,536 /64sOne site / customer
/56256 /64sResidential / small-business delegation
/6418.4 quintillion addressesOne LAN / VLAN
/1272 addressesRouter-to-router link (RFC 6164)
/1281 addressHost route / loopback

Recognising IPv6 address types at a glance

Starts withTypeMeaning
2xxx: / 3xxx:Global unicast (2000::/3)Public, internet-routable
fe80:Link-local (fe80::/10)Every IPv6 interface has one; valid only on its own link — this is what next-hops and neighbours use
fd (or fc)Unique local, ULA (fc00::/7)The IPv6 analogue of RFC 1918 private space
ffMulticast (ff00::/8)ff02::1 = all nodes, ff02::2 = all routers on link
::1Loopbacklocalhost
2001:db8:Documentation (RFC 3849)Examples only — never configure in production
::ffff:a.b.c.dIPv4-mappedAn IPv4 address represented inside the IPv6 API

Public vs private IP — and "what is my IP?"

Devices on a typical network hold a private address (RFC 1918 for IPv4, ULA for IPv6) and reach the internet through NAT, which rewrites traffic to your router's public address. That public address is what websites — including the "Your public IP" panel on this site — see. If the panel shows an address starting with 100.64–100.127, your ISP is using carrier-grade NAT and you don't have a dedicated public IPv4 address. IPv6 usually skips NAT entirely: your device's global unicast address is public (firewalled, not translated).

Common pitfalls checklist

Regular Expressions: the practical guide

A working reference for regex — the pattern language for finding, validating and extracting text. Written for the JavaScript flavour, which is what the Regex tester on this site runs.

The mental model: a regex is a tiny search pattern. Most characters match themselves; a handful of metacharacters have special powers. The engine scans the text left to right and reports where the pattern matches — and, with groups, which pieces it captured.

How matching works

Literals vs metacharacters

Letters and digits match themselves. These characters are special and must be escaped with a backslash to match them literally: . ^ $ * + ? ( ) [ ] { } | \. For example, a literal dot is \. — bare . means "any character".

Metacharacter cheat-sheet

TokenMatches
.Any character except newline (also newlines with the s flag)
\d / \DA digit [0-9] / a non-digit
\w / \WA word char [A-Za-z0-9_] / a non-word char
\s / \SWhitespace (space, tab, newline) / non-whitespace
[abc]Any one of a, b or c
[^abc]Any character except a, b or c
[a-z]Any character in the range a–z
|Alternation — "this or that"

Character classes

Square brackets [...] match exactly one character from the set inside. Ranges use a hyphen ([0-9a-f] = a hex digit), and a leading ^ negates the set ([^"] = any character that isn't a quote). Inside a class most metacharacters lose their power — . is a literal dot — but to include a literal ] escape it, and put a literal - first or last so it isn't read as a range.

Anchors and boundaries

TokenAsserts
^Start of the string (or start of a line with the m flag)
$End of the string (or end of a line with the m flag)
\bA word boundary — the edge between a \w and a non-\w
\BNot a word boundary

Anchors match a position, not a character. To validate that a whole value matches (not just part of it), wrap the pattern in ^…$.

Quantifiers

TokenRepeats the preceding item
*0 or more times
+1 or more times
?0 or 1 time (makes it optional)
{3}Exactly 3 times
{2,}2 or more times
{2,4}Between 2 and 4 times
Greedy vs lazy: quantifiers are greedy by default — they grab as much as possible. Add a ? to make them lazy (smallest match). On the text <a><b>, the pattern <.*> matches the whole thing, but <.*?> matches just <a>.

Groups, capturing and backreferences

Alternation

cat|dog matches "cat" or "dog". Scope it with a group: gr(a|e)y matches "gray" or "grey" (and captures the a/e); gr(?:a|e)y does the same without capturing.

Flags

FlagEffect
gGlobal — find every match, not just the first
iCase-insensitive
mMultiline — ^ and $ match at every line break
sDotall — . also matches newlines
uUnicode mode (needed for \p{…} property escapes and astral characters)

In the tester, tick the g/i/m/s boxes. In code the flags trail the pattern: /\d+/gi.

Lookahead and lookbehind

These are zero-width assertions — they check what comes next or before, without consuming those characters.

TokenAsserts the match is…
(?=...)followed by … (positive lookahead)
(?!...)not followed by … (negative lookahead)
(?<=...)preceded by … (positive lookbehind)
(?<!...)not preceded by … (negative lookbehind)

Example: \d+(?= USD) matches just the number in "50 USD"; (?<=\$)\d+ matches just the digits in "$50".

Worked examples

PatternMatches
^\d{4}-\d{2}-\d{2}$An ISO date like 2026-06-26 (the whole string)
\b\d{1,3}(?:\.\d{1,3}){3}\bAn IPv4-shaped address (shape only — doesn't enforce 0–255)
[\w.+-]+@[\w-]+\.[\w.-]+A basic email address
#?[0-9a-fA-F]{6}\bA hex colour such as #1a2b3c
https?://[^\s]+An http/https URL up to the first space
(\w+)\s+\1\bAn accidentally repeated word ("the the")

Validation regexes for email, URL or IP are always approximations — great for catching typos, not for guaranteeing correctness. For strict checks, use a real parser/validator.

Common gotchas

Build and test any of these live in the Regex tester on the Utilities page.