mjl.
← All articles

IPv4 Subnets, Netmasks, and CIDR

networkingipv4cidrsubnetting

CIDR notation writes an IPv4 network as an address followed by the number of network bits, such as 192.0.2.0/24. It is shorter and less error-prone than writing a dotted netmask alone.

Prefix lengths

Prefix Netmask Addresses Usable hosts*
/30 255.255.255.252 4 2
/29 255.255.255.248 8 6
/28 255.255.255.240 16 14
/24 255.255.255.0 256 254
/16 255.255.0.0 65,536 65,534

*Traditional host counts exclude the network and broadcast addresses. Point-to-point links and IPv6 use different conventions.

Finding a range

For 192.0.2.37/27, the block size is 32 because /27 leaves five host bits. The ranges begin at .0, .32, .64, and so on. Therefore:

  • Network: 192.0.2.32
  • Usable range: 192.0.2.33 through 192.0.2.62
  • Broadcast: 192.0.2.63

The address 192.0.2.37 is inside that range and is usable.

Practical checks

Use a calculator for complex plans, then verify assumptions with the host or network device. A configuration such as 192.0.2.20/24 means the host considers 192.0.2.0/24 local; it does not automatically configure a gateway or DNS server.

Common mistakes

  • Assigning the network or broadcast address to a host.
  • Using overlapping subnets on connected interfaces.
  • Treating a prefix length as a host count.
  • Forgetting that firewall rules and routes still control traffic.

Return to Linux Network Configuration with Netplan to apply these calculations safely.