Skip to content
Quasar Tools Logo

CIDR Notation Calculator and Guide

CIDR notation explained: how to calculate IP ranges, subnet masks, and usable hosts — with a free CIDR calculator and step-by-step examples for every prefix length.

DH
Tutorials & How-Tos12 min read2,700 words

CIDR notation appears in every cloud console, firewall rule, and network configuration file — and most developers learn to copy-paste it without fully understanding the arithmetic behind it. Once you know how to read the prefix length, calculate the address range, and derive the subnet mask, CIDR stops being opaque and becomes a precise tool you can use confidently. This guide covers everything: the notation format, the math, common blocks, cloud-specific rules, and how to subnet a larger network into smaller pieces.

32Bits in IPv4 addressdetermines all CIDR arithmetic
/0–/32Valid prefix rangefrom 0 (entire internet) to /32 (single host)
2ⁿAddress count formulawhere n = 32 minus prefix length

What is CIDR notation?

CIDR stands for Classless Inter-Domain Routing. It is a method of representing IP addresses and their associated network boundaries using a compact two-part notation: an IP address followed by a forward slash and a prefix length. For example, `192.168.1.0/24` means the network starts at `192.168.1.0` and has a 24-bit network prefix — the first 24 bits identify the network, and the remaining 8 bits identify individual hosts within it.

CIDR was introduced in 1993 to replace the original class-based addressing system — Class A (/8), Class B (/16), and Class C (/24) — which wasted enormous amounts of address space. A company that needed 300 addresses would receive a full Class B block with 65,536 addresses. CIDR allows any prefix length from /0 (the entire internet) to /32 (a single host address), allocating exactly the size needed.

IPv4 vs IPv6 CIDR

IPv4 CIDR uses 32-bit addresses and prefix lengths from /0 to /32. IPv6 CIDR uses 128-bit addresses and prefix lengths from /0 to /128. The arithmetic works identically — 2^(address-bits - prefix) gives the block size — but IPv6 addresses are written in hexadecimal with colon separators, such as `2001:db8::/32`. This guide focuses on IPv4, which is the format encountered in most infrastructure configurations today.

  • Prefix length: The number after the slash (e.g., /24). Specifies how many leading bits are the network portion.
  • Network address: The first IP in the block — all host bits are zero (e.g., 192.168.1.0 for /24).
  • Broadcast address: The last IP in the block — all host bits are one (e.g., 192.168.1.255 for /24).
  • Usable hosts: All addresses between network and broadcast — (2^host-bits - 2) addresses.
  • Subnet mask: The binary representation of the prefix — /24 = 255.255.255.0.

Note

A /32 CIDR block (`192.168.1.5/32`) represents exactly one IP address — it is used in firewall rules and routing entries when you want to target a single host precisely. A /0 block (`0.0.0.0/0`) represents the entire IPv4 address space and appears as the default route in routing tables.

How to read CIDR notation

Reading a CIDR block means extracting four pieces of information: the network address, the broadcast address, the usable host range, and the total address count. All four are derived mathematically from the two components of the notation — the IP address and the prefix length.

The prefix length tells you the block size

The prefix length directly tells you how many bits are fixed (network) and how many bits vary (hosts). For `10.0.0.0/8`: 8 bits are fixed, 24 bits vary. Host addresses: 2^24 = 16,777,216 total. For `172.16.0.0/12`: 12 bits fixed, 20 bits vary. Host addresses: 2^20 = 1,048,576 total. Shortcut: each increment in prefix length cuts the block size in half.

The IP address anchors the block

The IP address in a CIDR block is always the network address — the first address in the range. The network address has all host bits set to zero. If you encounter a CIDR block where the IP is not the network address (e.g., `192.168.1.5/24`), the actual network address is found by applying the subnet mask to the IP address with a bitwise AND: `192.168.1.5 AND 255.255.255.0 = 192.168.1.0`. The IP CIDR Range Quick Calculator normalises the input automatically and returns the correct network address.

The interpretation of a prefix is that it is a value that is expressed with the leftmost bits of the address being the most significant.

RFC 4632 (CIDR specification)
CIDR blockTotal addressesUsable hostsSubnet mask
/816,777,21616,777,214255.0.0.0
/1665,53665,534255.255.0.0
/24256254255.255.255.0
/281614255.255.255.240
/2986255.255.255.248
/3042255.255.255.252
/3210 (host route)255.255.255.255

How to calculate CIDR ranges

Calculating a CIDR range by hand requires binary arithmetic — but the process is systematic and predictable once you have done it a few times. These four steps apply to any CIDR block.

1

Identify network and host bits

For `192.168.10.0/22`, the prefix is 22. Convert each octet to binary: `192.168.10.0` = `11000000.10101000.00001010.00000000`. The first 22 bits (network portion) are `11000000.10101000.000010` — shared across all addresses in the block. The remaining 10 bits are the host portion.

2

Calculate the block size

Host bits = 32 - 22 = 10. Block size = 2^10 = 1,024 addresses. Usable hosts = 1,024 - 2 = 1,022. This is a moderately large subnet — appropriate for a medium office network or a cloud VPC subnet serving multiple application tiers.

3

Find the network and broadcast addresses

The network address is the IP with all host bits zeroed: `192.168.8.0` (the network portion occupies the 3rd octet starting at bit 16, so the /22 boundary aligns at multiples of 4 in the third octet). The broadcast address has all host bits set to 1: `192.168.11.255`. Use the IP CIDR Range Quick Calculator to verify — manual binary arithmetic is error-prone at non-octet-aligned prefixes.

4

Derive the subnet mask

Fill 22 bits with 1s followed by 10 zeros: `11111111.11111111.11111100.00000000`. Convert to decimal: 255.255.252.0. The third octet: `11111100` = 252. Confirm with the Subnet Mask Cheat Generator which produces reference tables for any prefix length on demand.

IP CIDR Range Quick Calculator

Calculate the full IP range, subnet mask, network address, broadcast address, and usable host count for any CIDR block — browser-local, instant results.

Open tool

Common CIDR blocks reference

A handful of CIDR blocks appear repeatedly in network configurations, firewall rules, and cloud VPC setups. Recognising them by sight speeds up infrastructure work significantly.

Private network ranges (RFC 1918)

  • 10.0.0.0/8: 16.7 million addresses. Class A private range — used for large enterprise networks and cloud VPCs that need massive address space.
  • 172.16.0.0/12: 1 million addresses. Docker's default network range is 172.17.0.0/16, carved from this block.
  • 192.168.0.0/16: 65,536 addresses. The standard home and small office range — almost every home router defaults to 192.168.1.0/24 or 192.168.0.0/24.
  • 169.254.0.0/16: Link-local range. Automatically assigned when DHCP fails — seeing a 169.254.x.x address usually means a DHCP connectivity problem.
  • 127.0.0.0/8: Loopback range. 127.0.0.1 is the standard loopback address; the entire /8 is reserved and never routed.

Special-purpose CIDR blocks

  • 0.0.0.0/0: The default route — matches every IP address. Used in routing tables to forward all unmatched traffic to a gateway.
  • x.x.x.x/32: Single host — used in firewall rules and BGP advertisements to target one specific IP address.
  • x.x.x.x/31: Two-address block — RFC 3021 allows these for point-to-point links where no network/broadcast is needed.
  • x.x.x.x/30: Four-address block (2 usable) — traditional point-to-point WAN link size, still common in router-to-router connections.

Tip

When planning VPC address spaces, start with a /16 for the VPC and carve /24 subnets from it. A /16 gives 256 non-overlapping /24 subnets — enough to separate production, staging, development, and management networks across multiple availability zones with room to grow.

CIDR in cloud and DevOps

Cloud platforms use CIDR blocks for every network segmentation decision — VPCs, subnets, security groups, route tables, and peering connections all reference CIDR notation. Understanding the constraints of each platform prevents configuration errors that are time-consuming to diagnose and fix.

AWS VPC CIDR rules

AWS VPCs accept primary CIDR blocks between /16 (65,536 addresses) and /28 (16 addresses). AWS reserves 5 IP addresses per subnet — the network address, the VPC router (`x.x.x.1`), the DNS server (`x.x.x.2`), a future-use address (`x.x.x.3`), and the broadcast address. For a /28 subnet, only 11 of 16 addresses are usable. VPC CIDR blocks from different peered VPCs or on-premises networks must not overlap — CIDR range conflicts are the most common cause of VPC peering failures.

Kubernetes and container networking

Kubernetes uses CIDR blocks for three separate address spaces: the node network (physical or cloud subnet), the pod CIDR (each pod gets a unique IP), and the service CIDR (ClusterIP services). These three ranges must not overlap with each other or with any external network the cluster needs to communicate with. The default pod CIDR in many distributions is `10.244.0.0/16`; the default service CIDR is `10.96.0.0/12`. Docker uses `172.17.0.0/16` for its default bridge network.

Firewall and security group rules

Security groups and firewall rules use CIDR blocks to specify permitted source or destination ranges. `0.0.0.0/0` allows traffic from any IP — use this only for public-facing services. `10.0.0.0/8` restricts traffic to the private address range. `/32` entries target individual IPs for allowlisting specific servers or developer workstations. Use the DNS Record Validator alongside CIDR tools to verify that DNS resolution aligns with your intended IP ranges.


Warning

Never assign overlapping CIDR blocks to peered VPCs, VPN connections, or Direct Connect gateway routes. AWS, Azure, and GCP all reject peering requests where CIDR blocks overlap, but the error message is not always clear about which specific ranges conflict. Use the IP CIDR Range Quick Calculator to check whether two proposed blocks share any addresses before configuring network peering.

Subnetting with CIDR

Subnetting is the process of dividing a larger CIDR block into smaller, non- overlapping blocks. This is how you create multiple subnets inside a VPC, assign separate ranges to different departments or availability zones, or carve out a dedicated block for management traffic.

The subnetting rule

Every time you increase the prefix length by 1, you split the block in half. A /24 block (256 addresses) becomes two /25 blocks (128 addresses each), or four /26 blocks (64 addresses each), or eight /27 blocks (32 addresses each). The subnets must be aligned — the starting address of each subnet must be a multiple of the block size. A /26 block contains 64 addresses, so valid /26 networks start at 0, 64, 128, or 192 in the last octet.

Worked subnetting example

Divide `10.0.0.0/24` into 4 equal subnets. Add 2 to the prefix: /26. Block size: 2^(32-26) = 64. The four /26 subnets are: `10.0.0.0/26` (addresses 0–63), `10.0.0.64/26` (addresses 64–127), `10.0.0.128/26` (addresses 128–191), and `10.0.0.192/26` (addresses 192–255). Each provides 62 usable host addresses. Verify each block with the IP CIDR Range Quick Calculator to confirm they are non-overlapping and correctly aligned.

  • +1 prefix = ÷2 block size: /24 → two /25, /16 → two /17, /8 → two /9.
  • +2 prefix = ÷4 block size: /24 → four /26, useful for dividing by availability zone.
  • +3 prefix = ÷8 block size: /24 → eight /27, useful for tier separation (web, app, db, mgmt).
  • Alignment requirement: Subnet start addresses must be multiples of the subnet block size.
  • Summarisation (supernetting): Multiple contiguous subnets can be described by a shorter prefix — four /26 subnets summarise as one /24.

Common CIDR mistakes

CIDR errors in infrastructure configurations are often silent — the network may appear to work until an edge case triggers the misconfiguration. These are the most common mistakes and how to catch them before deployment.

Overlapping ranges in peered networks

The most costly CIDR mistake is assigning overlapping blocks to networks that will later be connected. `10.0.0.0/16` in VPC A and `10.0.10.0/24` in VPC B overlap — the /24 is entirely contained within the /16. Peering will be rejected. Plan all CIDR allocations in a central spreadsheet or IP address management (IPAM) system before provisioning. Always check with the IP CIDR Range Quick Calculator whether two proposed ranges intersect.

Misaligned subnet boundaries

A subnet like `10.0.0.10/24` is syntactically valid but the network address is actually `10.0.0.0/24` — the `.10` is a host address within that network, not a network address. Many tools and cloud consoles silently normalise this, but some reject it or behave unexpectedly. Always verify that the IP address you enter is the network address for the given prefix length. The CIDR calculator flags this automatically.

Choosing prefix lengths without planning for growth

A /29 subnet (6 usable hosts) is sufficient for a VPN concentrator with 4 IP addresses — until you add two more devices six months later and run out of space. Expanding a subnet requires reconfiguration of routes, firewall rules, and possibly VPC peering. Choose prefix lengths with at least 50% headroom: if you need 20 hosts, use /27 (30 usable hosts) rather than /28 (14 usable hosts).

Warning

AWS, Azure, and GCP each reserve different numbers of IP addresses within a subnet. AWS reserves 5, Azure reserves 5, GCP reserves 4. Always subtract the platform's reservation from the usable host count when capacity planning — a /28 in AWS gives 11 usable addresses, not 14.

Subnet Mask Cheat Generator

Generate complete subnet mask reference tables for any prefix length — useful for network design documentation and training.

Open tool

Key takeaways

  • CIDR notation expresses an IP address range as `IP/prefix` — the prefix length specifies how many bits are the network portion, with the rest identifying hosts.
  • Block size formula: 2^(32 - prefix length) gives total addresses; subtract 2 for usable hosts in IPv4.
  • Use the IP CIDR Range Quick Calculator to instantly get the network address, broadcast address, subnet mask, and host count for any CIDR block.
  • Private ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 — none of these are routed on the public internet.
  • Subnetting increases the prefix length by N to divide a block into 2^N equal subnets — each subnet start address must align to a multiple of the subnet block size.
  • Overlapping CIDR blocks in peered VPCs or connected networks cause routing failures — always verify non-overlap before provisioning.
  • Cloud platforms (AWS, Azure, GCP) each reserve 4–5 addresses per subnet — plan capacity with those reservations included, not just the raw usable host formula.

Frequently Asked Questions

CIDR stands for Classless Inter-Domain Routing. CIDR notation expresses an IP address and its associated network mask as a single compact string — an IP address followed by a forward slash and a prefix length, such as 192.168.1.0/24. The prefix length specifies how many leading bits of the address define the network. CIDR replaced the older class-based addressing system (Class A, B, C) to allow more flexible and efficient allocation of IP address space.

The formula is 2^(32 - prefix length) for IPv4. Subtract 2 from the result to get the number of usable hosts — one address is reserved for the network identifier and one for the broadcast address. For /24: 2^(32-24) = 2^8 = 256 total addresses, 254 usable hosts. For /28: 2^(32-28) = 2^4 = 16 total addresses, 14 usable hosts. The IP CIDR Range Quick Calculator on Quasar Tools computes this automatically for any prefix.

The subnet mask for /24 is 255.255.255.0. This is derived by filling the first 24 bits with 1s and the remaining 8 bits with 0s, then converting each 8-bit octet to decimal: 11111111.11111111.11111111.00000000 = 255.255.255.0. Common subnet masks: /8 = 255.0.0.0, /16 = 255.255.0.0, /24 = 255.255.255.0, /28 = 255.255.255.240, /30 = 255.255.255.252.

A /24 block contains 256 IP addresses (254 usable hosts) and has a subnet mask of 255.255.255.0. A /16 block contains 65,536 IP addresses (65,534 usable hosts) and has a subnet mask of 255.255.0.0. The smaller the prefix number, the larger the network and the more IP addresses it contains. A /16 is 256 times larger than a /24 — it could be subdivided into 256 separate /24 networks.

Count the number of consecutive 1-bits in the subnet mask from left to right. The count is the CIDR prefix length. For 255.255.255.0: convert each octet to binary — 11111111.11111111.11111111.00000000 — and count the leading 1s: 24. So 255.255.255.0 = /24. For 255.255.240.0: 11111111.11111111.11110000.00000000 has 20 leading 1s = /20.

For a small office with up to 254 devices, /24 (192.168.x.0/24) is the standard choice — it provides 254 usable addresses with the subnet mask 255.255.255.0. For very small networks (under 14 devices), /28 reduces the broadcast domain and is appropriate for point-to-point links or small server segments. AWS VPCs require a minimum block size of /28 and allow up to /16. Always reserve headroom for future growth — a /24 is safe for most office deployments.

RFC 1918 defines three private IP address ranges reserved for internal network use: 10.0.0.0/8 (10.0.0.0 to 10.255.255.255 — 16,777,216 addresses), 172.16.0.0/12 (172.16.0.0 to 172.31.255.255 — 1,048,576 addresses), and 192.168.0.0/16 (192.168.0.0 to 192.168.255.255 — 65,536 addresses). These ranges are not routed on the public internet and are used for home networks, office networks, and cloud VPCs.

In AWS, every VPC requires a primary CIDR block between /16 (65,536 addresses) and /28 (16 addresses). Subnets within the VPC are created from smaller CIDR blocks carved out of the VPC range. AWS reserves 5 addresses per subnet: the network address, VPC router, DNS resolver, future use, and broadcast. For a /24 subnet, 251 addresses are usable (not 254). Azure and GCP follow the same CIDR-based subnet model with similar reservations.

ShareXLinkedIn

Related articles