Topic

IPv4, CIDR, and subnet calculation

Learn to interpret IPv4 addresses, calculate prefixes, and verify networks, broadcasts, and usable ranges.

An IPv4 address identifies its network correctly only when the prefix or mask is known. This topic brings together binary calculation, host-based planning, and the practical interpretation of network, broadcast, and special-purpose ranges.

Decide what you need to calculate

  • If you have an address and prefix, calculate the network and complete range.
  • If you know the required number of devices, choose the host bits first and derive the smallest suitable prefix.
  • Before splitting a block, verify the alignment and increment of each subnet.
  • When an address is private, CGNAT, or 169.254, identify its scope before assuming that Internet connectivity itself is broken.

Always verify the result

Write the network in CIDR notation, verify the dotted-decimal mask, and count all addresses before subtracting reservations. /31 and /32 are special cases and must not be handled by blindly applying the traditional “minus two hosts” rule.

The subnet calculator shows every derived value, while the base converter lets you inspect the same address as bits or an integer. The guides explain why each result appears so you can catch a misaligned network or a prefix that cannot provide the required capacity.

Tools

Tools for this topic

Guides

Guides in a recommended order

  1. How to calculate an IPv4 subnet step by stepLearn how to obtain network, broadcast and host range from an IPv4 and a CIDR prefix, with a /27 example solved by hand.
  2. How to calculate a CIDR prefix from the required host countChoose the smallest IPv4 subnet for a host count and calculate host bits, prefix, mask, and capacity with examples.
  3. How many hosts are in an IPv4 subnet?Calculate total and usable IPv4 addresses from a CIDR prefix, including the correct treatment of /31 and /32.
  4. IPv4 network, broadcast, first and last host addressesDistinguish IPv4 subnet boundaries and calculate network, broadcast, and host range with a worked /27 example.
  5. IPv4 /31 vs /32: differences, hosts, and use casesDistinguish a /31 point-to-point network from a /32 host route and understand the addresses, broadcast, and capacity of each.
  6. CIDR vs subnet mask in IPv4Learn how a CIDR prefix converts to an IPv4 subnet mask, what each bit means, and when the two notations are equivalent.
  7. How to split a /24 network into four /26 subnetsDivide an IPv4 /24 into four /26 blocks and calculate each network, usable host range, and broadcast address in a complete example.
  8. IPv4 wildcard masks explainedCalculate the inverse of an IPv4 subnet mask, interpret its bits, and avoid treating a wildcard as an IP address.
  9. Private, CGNAT, and public IPv4 addressesIdentify RFC 1918 addresses and the shared CGNAT range, avoid mixing them up, and check other special-purpose IPv4 blocks.
  10. 169.254 IP address: APIPA, link-local, and how to fix itLearn why a device assigns itself a 169.254 IPv4 address, what link-local connectivity permits, and what to check when DHCP fails.
  11. How to convert IPv4 to decimal, binary, and hexadecimalConvert the four octets of an IPv4 address to an unsigned 32-bit integer, hexadecimal, and binary with a verifiable example.

Reviewed on by Tools in a Tab.