EMZETT.
Login

Subnetting and CIDR calculation: Dividing IP networks

In short: With subnetting you divide an IP network into smaller networks; the CIDR notation /24 states how many bits belong to the network, from which addresses, broadcast and hosts can be calculated.

In more detail: An IPv4 address has 32 bits, written as four bytes (192.168.10.37). The subnet mask (or prefix length) defines which part is the network and which the hosts. CIDR (classless inter-domain routing) writes this briefly: 192.168.10.0/24 means that the first 24 bits are the network.

In Depth

The most important formulas

  • Host bits h = 32 − prefix.
  • Addresses in the network: 2^h; usable hosts: 2^h − 2 (subtract network address and broadcast).
  • Network address: host bits all 0. Broadcast: host bits all 1.
  • First host address: network address + 1, last: broadcast − 1. Example /24: h = 8 → 256 addresses, 254 hosts, mask 255.255.255.0.

Table of common prefixes

PrefixMaskAddressesHosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
Prefix /16 = 255.255.0.0 (65,534 hosts), /8 = 255.0.0.0.

Example: subnet of 192.168.10.37/26

  1. /26 → host bits 6 → block size 64.
  2. Networks in the last byte: 0, 64, 128, 192. The 37 lies in the block 0 to 63.
  3. Network address: 192.168.10.0, broadcast: 192.168.10.63.
  4. Hosts: .1 to .62 (62 of them). Dividing: one /24 into four /26 networks: .0/26, .64/26, .128/26, .192/26 (62 hosts each).

Exam and practice tips

  • Think in binary: the mask /26 in the last byte: 11000000 = 192.
  • For the task “How many subnets/hosts?”: determine the need (hosts + 2 → next power of two) and choose the smallest suitable network (VLSM: networks of different sizes).
  • Private ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
  • IPv6 uses /64 for subnets.
  • Tools: ipcalc, online calculators, the CIDR tool in the wiki. Calculate by hand first, then check.

See also: Subnet mask, Subnet, IPv6, NAT, VLAN