NewDanbyte 0.20.0: Known vulnerabilities, device dependencies and DiscoveryRelease notes
Blog/Guide

Subnetting and prefix hierarchy: a practical guide

A practical guide to subnetting and prefix hierarchy: CIDR, aggregation, container and active prefixes, utilization, and how an IPAM keeps the tree consistent.

Danbyte5 min read
subnettingCIDRIPAMprefixes

Subnetting can look like arithmetic on bits, but the structure underneath it is a tree. Every address you manage sits somewhere in a hierarchy of prefixes. When that tree is clean, questions like "is this range free?" and "who owns this space?" can be answered by looking at it.

A quick CIDR refresher

An IP prefix is an address plus a prefix length, which is the number of leading bits that are fixed. In 10.0.0.0/24, the first 24 bits are the network and the remaining 8 are for hosts. That gives 256 addresses, of which 254 are usable once you subtract the network and broadcast addresses.

There is one rule worth memorizing: each bit you add to the prefix length halves the block, and each bit you remove doubles it.

  • /24 is 256 addresses, the size most people mean by "a subnet"
  • /23 is 512 addresses, or two /24s merged
  • /25 is 128 addresses, or half a /24
  • /16 is 65,536 addresses, a large aggregate

The same logic applies to IPv6, which has far more room. A /64 is the standard host subnet, and you carve site and region aggregates out of shorter prefixes like /48 or /56.

From aggregate to host

A useful network is more than a flat list of /24s. It is a hierarchy with three conceptual layers:

  1. Aggregates (supernets) are the big blocks you were allocated or reserved, for example 10.0.0.0/16 for a region or an RFC 1918 range for the whole org.
  2. Child prefixes are subnets carved from an aggregate: a per-site /20, then a per-VLAN /24 inside it.
  3. Hosts are the individual addresses assigned to interfaces, VIPs, and gateways.

Prefixes nest cleanly because CIDR boundaries are powers of two. A /20 contains exactly sixteen /24s, and a /24 contains 256 addresses. Nothing overlaps as long as you split on real boundaries and never let two children claim the same bits.

Container and active prefixes

Some prefixes hold hosts and some only hold other prefixes, so it helps to give each prefix a role:

  • A container (or "aggregate") prefix exists to be subdivided. 10.0.0.0/16 and a site's 10.0.0.0/20 are containers, and you would never assign a host directly into them.
  • An active prefix is a real subnet that is in use and where addresses are handed out. 10.0.0.0/24 (the Servers VLAN) is active.

The distinction matters because utilization means different things at each layer. For an active /24, utilization is how many of its 254 hosts are assigned. For a container, utilization is how much of its space has been carved into child prefixes. It is a rollup of the prefixes beneath it and does not count hosts.

Worked example: carving a /16 into sites

Say you have 10.0.0.0/16 for a region. Split it into per-site /20s (4,096 addresses, sixteen /24s each), then split each site into per-VLAN /24s:

10.0.0.0/16      Region EU        container   65,536 addr
├─ 10.0.0.0/20   Site: Aarhus     container    4,096 addr  (10.0.0.0-10.0.15.255)
│   ├─ 10.0.0.0/24  Servers VLAN   active        254 hosts
│   ├─ 10.0.1.0/24  Users VLAN     active        254 hosts
│   └─ 10.0.2.0/24  Mgmt  VLAN     active        254 hosts
├─ 10.0.16.0/20  Site: Berlin     container    4,096 addr  (10.0.16.0-10.0.31.255)
│   └─ 10.0.16.0/24 Servers VLAN   active        254 hosts
└─ 10.0.32.0/20  Site: reserved   container    4,096 addr  (spare for growth)

A /16 gives you sixteen /20s (10.0.0.0/20, 10.0.16.0/20, 10.0.32.0/20, … 10.0.240.0/20), which fits up to sixteen sites. If you reserve a couple of empty /20s at the start, a new site can be added later without renumbering anything.

What a clean hierarchy gives you

A clean tree pays off in four concrete ways:

  • Route aggregation. Aarhus is one contiguous /20, so it is advertised as a single route where a loose plan would need three separate /24s. Address plans that can be summarized keep routing tables and firewall rules small.
  • Utilization rollup. You can ask "how full is Region EU?" and get a real answer, because each container's usage is the sum of its children. Sparse /20s stand out as candidates to reclaim.
  • Overlap prevention. Allocating from the top down makes it structurally hard to book the same range twice: a child must fit inside its parent, and siblings cannot collide.
  • Delegation. A site team can own its /20 and create /24s inside it for itself, without the authority or the ability to touch another site's space.

How an IPAM keeps it consistent

A spreadsheet can represent this hierarchy, but it cannot enforce it. Nothing stops two rows from claiming 10.0.1.0/24, and nobody recomputes utilization when a subnet fills up. A purpose-built IPAM treats the prefix tree as the source of truth:

  • It nests a new prefix under its correct parent automatically, based on the CIDR math, so the tree stays accurate as you add subnets.
  • It rejects overlaps and out-of-bounds children when they are created, before they turn into a routing incident.
  • It shows live utilization at every level: hosts within an active subnet, and child coverage within a container. You can check capacity whenever you need to and do not have to wait for a quarterly audit.
  • It lets you find the next available /24 (or /26, or /64) inside a chosen parent, so you do not have to look for gaps by eye.

Danbyte models this with aggregates, containers, active prefixes, and host assignments in one tree, and all of it is in the free, open-source release. You can self-host it on your own hardware and use the prefix features described here. Through the REST API, your automation can work with the same tree, for example to find the next free /24 in Berlin.

Once the hierarchy is in place, most day-to-day addressing decisions follow from it, because the tree already shows where a new subnet belongs.

Run Danbyte on your own server

Danbyte is free and open source, and it does IPAM and DCIM in one application. One command installs it on a new Ubuntu or Debian server.