What Is CIDR
CIDR (Classless Inter-Domain Routing) is a flexible method for allocating IP addresses and routing. It replaced the traditional classful addressing system (Class A, B, C), allowing more granular address space allocation.
CIDR notation appends a prefix length after the IP address with a slash:
192.168.1.0/24
^^
Prefix length (network bits)
Why You Need a CIDR Calculator
- VPC network planning: Subnet design on cloud providers (AWS, Alibaba Cloud)
- Container networks: Kubernetes Pod network configuration
- Firewall rules: IP allowlist CIDR range configuration
- Server deployment: Internal IP address planning
- CDN configuration: IP range restrictions and edge node planning
- Security auditing: Analyzing IP range coverage
CIDR Fundamentals
IP Address Structure
An IPv4 address is a 32-bit binary number, typically shown in dotted decimal:
192.168.1.100
= 11000000.10101000.00000001.01100100
First 24 bits = network (/24), last 8 bits = hosts
Subnet Mask
The subnet mask distinguishes network from host portions:
| CIDR Prefix | Subnet Mask | Usable Hosts | Use Case | |-------------|-------------|-------------|----------| | /8 | 255.0.0.0 | 16,777,214 | Large organizations | | /16 | 255.255.0.0 | 65,534 | Medium networks | | /24 | 255.255.255.0 | 254 | Small networks (most common) | | /28 | 255.255.255.240 | 14 | Cloud VPC subnets | | /32 | 255.255.255.255 | 1 | Single host |
Usable Host Formula
Usable hosts = 2^(32 - prefix_length) - 2
Minus 2 because:
- Network address (all host bits 0) is not assignable
- Broadcast address (all host bits 1) is not assignable
Common CIDR Blocks
| CIDR | IPs | Description | |------|-----|-------------| | /32 | 1 | Single host | | /31 | 2 | Point-to-point link | | /30 | 4 | WAN link (2 usable IPs) | | /29 | 8 | Small subnet | | /28 | 16 | Common in cloud VPCs | | /27 | 32 | Medium subnet | | /24 | 256 | Class C size | | /16 | 65,536 | Class B size |
How to Use an Online CIDR Calculator
Using DevToolkit Pro's CIDR Calculator:
- Enter an IP address and CIDR prefix (e.g.,
192.168.1.0/24) - The tool automatically calculates:
- Network address
- Broadcast address
- Subnet mask
- Usable IP range
- Host count
- Supports IP range to CIDR conversion
Cloud VPC Network Planning Example
Alibaba Cloud VPC Subnet Design
VPC CIDR: 10.0.0.0/16 (65,536 IPs)
├── Public subnet: 10.0.1.0/24 (254 IPs) ← Web servers
├── App subnet: 10.0.2.0/24 (254 IPs) ← App servers
├── Database subnet: 10.0.3.0/24 (254 IPs) ← Databases
├── Management subnet: 10.0.4.0/28 (14 IPs) ← Bastion hosts
└── Kubernetes: 10.0.5.0/24 (254 IPs) ← Pod network
FAQ
What's the Difference Between /32 and /31?
/32 is a host route (exact match for one machine). /31 is a special format for point-to-point links that eliminates the need for network and broadcast addresses — both IPs are assignable to endpoints.
What Are Subnet Design Best Practices?
- Segment by function (web, app, database)
- Segment by environment (dev, staging, production)
- Reserve 20%+ for future expansion
- Use private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
How Do I Check If Two CIDRs Overlap?
If two CIDRs produce the same result when ANDed with each other's subnet mask, they overlap. Online CIDR calculators can detect overlap directly.
This article is brought to you by DevToolkit Pro. More developer tools at the homepage.
相关文章
Online Word Counter: Count Words, Characters, Lines Instantly
Learn how to use an online word counter to count words, characters, lines, and paragraphs. Understand Chinese vs English counting differences and use cases in writing and development.
UUID Generator: Complete Guide to Unique Identifiers (UUID, NanoID, ULID)
Understand UUID v4, NanoID, and ULID fundamentals. Learn how to use an online UUID generator, and discover best practices for databases, distributed systems, and API tracking.
Online User-Agent Parser: Identify Browser and Device Information
Learn how to parse User-Agent strings. Understand browser, operating system, and device type identification methods, and applications in data analytics and compatibility testing.