CIDR Explained: What It Is & How It Works
In this article
CIDR stands for Classless Inter-Domain Routing. It is a method for allocating and specifying IP addresses and routing data packets on networks, including the internet. In plain terms, CIDR lets you define a range of IP addresses in a compact way, replacing the older class-based system. It is not slang or informal—it is a standard technical term defined in RFC 1518 and RFC 1519 (1993) and still used today in networking, cloud configuration, and home router settings.
Why CIDR Was Created
Before CIDR, IP addresses were assigned in fixed classes: Class A (huge blocks), Class B (medium), and Class C (small). This was wasteful—a company needing 300 addresses had to take a Class B block of 65,536, wasting most of them. By the early 1990s, the IPv4 address space was running out. CIDR solved this by allowing networks to be divided into arbitrary-sized blocks, not just the fixed classes. It also enabled route aggregation (supernetting), which reduced the size of internet routing tables.
How CIDR Notation Works
CIDR notation looks like an IP address followed by a slash and a number, e.g., 192.168.1.0/24. The number after the slash is the prefix length—it tells you how many leading bits of the address are fixed (the network part). The remaining bits are for host addresses.
For IPv4, an address is 32 bits. So /24 means the first 24 bits are the network, leaving 8 bits for hosts. That gives 28 = 256 possible addresses, but the first and last are reserved (network and broadcast), so usable hosts are 254.
For IPv6, addresses are 128 bits, and CIDR is used the same way—e.g., 2001:db8::/32.
How to Calculate CIDR Blocks
To figure out what a CIDR block covers, you need to convert the prefix length to a subnet mask and then determine the range.
- Convert prefix length to subnet mask: For IPv4, a /24 corresponds to 255.255.255.0. A /16 is 255.255.0.0. A /30 is 255.255.255.252.
- Find the network address: The network address is the first address in the block. For example,
192.168.1.0/24starts at 192.168.1.0. - Find the broadcast address: The last address in the block. For /24, that's 192.168.1.255.
- Usable hosts: Total addresses minus 2 (network and broadcast). For /24, that's 254.
Common CIDR blocks you might see:
/32– a single IP address (no hosts)./30– 4 addresses, 2 usable (often used for point-to-point links)./24– 256 addresses, 254 usable (typical home network)./16– 65,536 addresses, 65,534 usable./0– the entire internet (all addresses).
CIDR in Home Networking
Most home routers use CIDR internally, even if you don't see the notation. When you set your router's DHCP range to 192.168.1.100 to 192.168.1.200, you're effectively using a /24 block. If you change the subnet mask to 255.255.255.0, that's the same as /24.
When you configure a static IP on a device, you often enter the subnet mask in decimal form (e.g., 255.255.255.0) rather than CIDR notation. But some advanced router settings and firewall rules use CIDR notation directly. For example, you might block a range like 10.0.0.0/8 to prevent traffic to a private network.
CIDR in Cloud and VPC Configuration
If you use cloud services like AWS, Google Cloud, or Azure, you'll encounter CIDR when setting up a Virtual Private Cloud (VPC) or subnets. For instance, you might create a VPC with 10.0.0.0/16 and then create subnets like 10.0.1.0/24 and 10.0.2.0/24. The cloud provider will validate that your CIDR blocks don't overlap and that they are within the allowed ranges.
When choosing a CIDR block for a VPC, you need to ensure it doesn't conflict with other networks you'll connect to (like your office or home). Common private ranges are:
10.0.0.0/8– very large, up to 16 million addresses.172.16.0.0/12– about 1 million addresses.192.168.0.0/16– 65,536 addresses.
Common CIDR Mistakes and Misconceptions
One frequent mistake is confusing the prefix length with the number of addresses. A /24 is not “24 addresses”—it's 256 addresses. The prefix length refers to bits, not count.
Another misconception is that CIDR is only for IPv4. It's also used for IPv6, where the prefix length is written the same way, e.g., 2001:db8:1234::/48.
People also often forget that the first and last addresses in a subnet are not usable for hosts. For example, in 192.168.1.0/24, .0 is the network address and .255 is the broadcast address. If you try to assign them to a device, it will fail.
If That Did Not Work: Troubleshooting CIDR Issues
If you're having trouble with a CIDR configuration, follow these steps:
- Double-check the prefix length: Make sure you didn't accidentally type /23 instead of /24. A one-bit difference doubles or halves the range.
- Verify the network address: The network address must be aligned to the block size. For example,
192.168.1.0/24is valid, but192.168.1.10/24is not—the network address should be .0. - Check for overlaps: If you're creating subnets, ensure they don't overlap. For instance,
10.0.0.0/24and10.0.0.128/25overlap because the second is inside the first. - Restart the router or cloud instance: After changing CIDR settings, a restart may be needed.
- Consult the official documentation: For cloud providers, refer to their VPC and subnet guides.
Frequently Asked Questions
What does /24 mean in CIDR?
/24 means the first 24 bits of the IP address are the network part. For IPv4, that leaves 8 bits for host addresses, giving 256 total addresses (254 usable). It's equivalent to a subnet mask of 255.255.255.0.
How do I convert a subnet mask to CIDR?
Count the number of consecutive 1s in the binary representation of the subnet mask. For example, 255.255.255.0 is 11111111.11111111.11111111.00000000, which has 24 ones, so it's /24.
Can CIDR be used for IPv6?
Yes. CIDR notation is used for IPv6 just like IPv4. For example, 2001:db8::/32 means the first 32 bits are the network prefix. IPv6 addresses are 128 bits, so prefix lengths can go up to /128.
Why do I need CIDR when setting up a home router?
Most home routers use a default /24 subnet (192.168.1.0/24 or similar). You may need CIDR notation if you're configuring advanced routing, firewall rules, or connecting multiple networks. It's also essential for understanding how your router assigns IP addresses.
What is the difference between CIDR and VLSM?
CIDR is the overall concept of classless addressing and routing. VLSM (Variable Length Subnet Masking) is a technique that allows you to use different subnet masks within the same network, which is a practical application of CIDR. In other words, VLSM is how you implement CIDR in a network design.