Last updated · reviewed for accuracy

Subnetting & CIDR

By the end of this lesson you can take any address like 192.168.1.70/26 and answer, without a calculator: which network is this, what mask does it use, and how many devices fit in it.

What is subnetting?

Subnetting is the practice of dividing one IP network into smaller networks called subnets. Each subnet gets a share of the parent’s address space, defined by a subnet mask or CIDR prefix, so routers can treat it as a separate destination and administrators can isolate groups of devices.

The word sounds like a technique, but it’s really an act of drawing borders. An IPv4 address is 32 bits. The prefix decides how many of those bits name the network and how many are left to name hosts inside it. Move the border right and you get more, smaller networks; move it left and you get fewer, bigger ones.

Why do networks use subnets?

Networks are subnetted to limit broadcast traffic, to create security boundaries between groups of devices, and to make address space easy to plan and route. A flat network with hundreds of hosts becomes noisy and impossible to reason about; subnets keep each segment small and intentional.

  • Broadcast containment. Every ARP request and DHCP discover floods its subnet. Fifty devices per segment is calm; five hundred is a permanent low-grade storm.
  • Security boundaries. Finance and guest Wi-Fi should not share a segment. Traffic between subnets must pass a router, which is where your firewall rules live.
  • Address planning. “Third floor is 10.0.3.0/24” turns an outage report into a location instantly.

How does CIDR notation work?

CIDR notation writes a network as address/prefix, where the prefix counts how many leading bits of the address identify the network. 192.168.1.0/26 means the first 26 bits are the network and the remaining 6 bits number its hosts: 64 addresses, 62 of them usable.

The prefix and the dotted mask are the same fact in two costumes: /26 is a mask with 26 leading one-bits, i.e. 255.255.255.192. The sizes you’ll meet daily:

Common IPv4 prefixes and their capacity
Prefix Subnet mask Total addresses Usable hosts Typical use
/24 255.255.255.0 256 254 The classic office or home LAN
/26 255.255.255.192 64 62 A department or a floor
/27 255.255.255.224 32 30 A small team or server group
/30 255.255.255.252 4 2 Router-to-router links
/31 255.255.255.254 2 2 Point-to-point links (RFC 3021)

How do you calculate a subnet by hand?

AND the address with the mask in binary: wherever the mask has a 1, keep the address bit; wherever it has a 0, write 0. The result is the network address. Set all host bits to 1 instead and you get the broadcast address; everything between is the host range.

Take 192.168.1.70/26: a host address someone gives you in a ticket. Which subnet does it live in?

binary AND: 192.168.1.70/26worked example
address   192.168.1.70    11000000.10101000.00000001.01000110
mask /26  255.255.255.192 11111111.11111111.11111111.11000000
─────────────────────────────────────────────────────────
network   192.168.1.64    11000000.10101000.00000001.01000000
broadcast 192.168.1.127   11000000.10101000.00000001.01111111

So .70 lives in 192.168.1.64/26, whose hosts run from .65 to .126. The shortcut for your head: with a /26 the “block size” in the last octet is 256 − 192 = 64, so subnets start at 0, 64, 128, 192, and 70 falls in the block that starts at 64.

Worked example: split a /24 into four subnets

Your team gets 192.168.1.0/24 and needs four equal segments. Borrow two host bits (2² = 4 subnets) and the prefix becomes /26:

192.168.1.0/24 divided into four /26 subnets
Subnet Network Host range Broadcast Usable
1 192.168.1.0/26 .1 – .62 .63 62
2 192.168.1.64/26 .65 – .126 .127 62
3 192.168.1.128/26 .129 – .190 .191 62
4 192.168.1.192/26 .193 – .254 .255 62

Classful addressing vs CIDR

Classful addressing (1981–1993) fixed network sizes by the first octet: class A gave 16.7 million hosts, class C gave 254, with nothing in between. CIDR replaced it by letting the prefix fall on any bit, so networks are sized to actual need and routes aggregate cleanly.

Classful vs CIDR at a glance
Classful (legacy) CIDR (current)
Network sizes Three fixed sizes (A: /8, B: /16, C: /24) Any prefix from /0 to /32
Mask implied by First octet of the address Explicit prefix or mask, always stated
Waste Enormous: need 300 hosts? Take 65,534. Minimal: take a /23 (510 hosts)
Routing tables One route per class network Aggregation: many networks, one summary route
Status Obsolete since 1993 (RFC 1519) How the internet routes today

You’ll still hear “class C” as slang for a /24. Nod politely, write /24.

Try it yourself

Type any address in CIDR notation and hit Calculate: the math above runs live in your browser.

Try it yourself runs locally

Try 10.0.0.0/8, 172.16.5.9/20 or a /31 to see the RFC 3021 exception.

Related tool: Subnet Calculator

The full Subnet Calculator also shows the binary working and splits a network into equal subnets for you. Related lessons: IPv4 addressing · IPv6 addressing · NAT & private ranges.

Common mistakes to avoid

  • Assigning the network or broadcast address to a host. 192.168.1.64 in a /26 is the network’s name, not a usable address. Devices configured with it will misbehave quietly.
  • Reading a /26 as “everything in the last octet.” .70 and .200 look like neighbours but sit in different /26 subnets. They need a router to talk.
  • Forgetting the gateway consumes a host address. A “62 usable” subnet has 61 left once the router takes its customary first address.
  • Mismatched masks on the same segment. If one host thinks the network is /24 and another /26, one-way ping mysteries follow.

Frequently asked questions

How many usable hosts are in a /26 subnet?

A /26 subnet contains 64 total addresses (2⁶ host bits). Two of them are reserved (the network address and the broadcast address) which leaves 62 usable host addresses. The general formula is 2^(32 − prefix) − 2.

What is the difference between a subnet mask and a CIDR prefix?

They express the same information in two notations. The CIDR prefix counts the mask’s leading one-bits: 255.255.255.192 has 26 leading ones, so it is written /26. Prefix notation is shorter and is what routers and modern tools use.

Why do you subtract 2 when counting usable hosts?

Every classic subnet reserves its first address to name the network itself and its last address for broadcast. Neither can be assigned to a device. The exceptions are /31 point-to-point links (RFC 3021) and /32 host routes, which have no reserved pair.

Do I still need subnetting with IPv6?

Yes: the concept carries over, only the pain goes away. IPv6 LANs are almost always /64, there is no broadcast address to reserve, and address space is so large that you plan prefixes for structure and routing rather than to conserve addresses.