Back to Tools

CIDR Calculator

Calculate IP address ranges from CIDR notation. Convert between CIDR, subnet masks, and IP ranges. Essential for configuring SPF records and understanding IP allowlists.

About this tool

If you've ever needed to authorize a range of IP addresses in an SPF record or configure a firewall allowlist for your mail server, you've encountered CIDR notation. It's the standard way to express IP address ranges compactly — instead of listing hundreds of individual IPs, you write something like 198.51.100.0/24 and cover all 256 addresses at once. This calculator converts between CIDR notation, subnet masks, and IP ranges so you don't have to do the binary math yourself.

How CIDR notation works

An IPv4 address is 32 bits long. The number after the slash tells you how many of those bits are fixed (the network portion), and the remaining bits are variable (the host portion). A /24 means 24 bits are fixed and 8 are variable, giving you 2^8 = 256 possible addresses. A /32 means all bits are fixed — it's a single IP. A /16 means 16 bits are variable, giving you 65,536 addresses. The most common ranges you'll encounter in email: /32 (single server), /28 (16 IPs — a small dedicated pool), /24 (256 IPs — a typical allocation from an ISP or cloud provider).

CIDR in email authentication

SPF records are where most email senders encounter CIDR. When you add ip4:198.51.100.0/24 to your SPF record, you're authorizing every IP from 198.51.100.0 to 198.51.100.255 to send email for your domain. This is essential when your ESP or mail infrastructure uses a pool of IPs that can change. Instead of listing each IP individually (and hitting SPF's 10-lookup limit), a single CIDR range covers them all with one mechanism. Use our SPF generator to build records with proper CIDR notation.

Common CIDR mistakes in email setups

The biggest mistake is authorizing too broad a range. Using /16 (65,536 IPs) in your SPF record when your ESP only uses 4 IPs from that range means you're also authorizing thousands of IPs you don't control — potentially including spammers on the same network. Be as specific as possible. If your provider uses 198.51.100.10 through 198.51.100.14, a /28 or even listing individual /32 entries is safer than a /24. Ask your provider for their exact IP ranges rather than guessing.

IPv6 CIDR considerations

IPv6 uses the same CIDR concept but with 128-bit addresses. A typical IPv6 allocation is /48 (for organizations) or /64 (for subnets). In SPF records, you'd use the ip6: mechanism with CIDR notation, like ip6:2001:db8::/48. As more mail servers adopt IPv6, you'll need to include both ip4 and ip6 ranges in your SPF configuration. After setting up your ranges, verify them with the DNS propagation checker to ensure your records are visible globally.

Frequently Asked Questions

What is CIDR notation and why should I care?

CIDR (Classless Inter-Domain Routing) is a compact way to represent IP address ranges. Instead of listing 256 individual IPs, you write 192.168.1.0/24. If you manage SPF records, firewalls, or any email infrastructure, you'll encounter CIDR notation regularly. This calculator saves you from doing the binary math to figure out which IPs a CIDR range covers.

How is CIDR used in SPF records?

SPF records use CIDR to authorize IP ranges efficiently. For example, ip4:198.51.100.0/24 authorizes all 256 IPs in that range to send email for your domain. This is much more practical than listing individual IPs, especially when your ESP uses a pool of sending servers. Each ip4 or ip6 mechanism with CIDR counts as one lookup against SPF's 10-lookup limit.

What does the /24, /28, /32 mean exactly?

The number after the slash is the prefix length — it tells you how many bits of the 32-bit IPv4 address are fixed. /32 = 1 IP (all bits fixed). /31 = 2 IPs. /30 = 4 IPs. /28 = 16 IPs. /24 = 256 IPs. /16 = 65,536 IPs. Each step down doubles the number of addresses. For email SPF records, you'll most commonly see /24 through /32.

What's the difference between a subnet mask and CIDR?

They express the same thing differently. A subnet mask of 255.255.255.0 is equivalent to /24 — both mean the first 24 bits define the network. CIDR notation is more compact and is the modern standard. Our calculator converts between both formats. The subnet mask 255.255.255.240 equals /28 (16 addresses), and 255.255.255.252 equals /30 (4 addresses).

How do I know what CIDR range to use in my SPF record?

Ask your email service provider for their exact sending IP ranges. Don't guess or use broader ranges than necessary. If your provider sends from 4 specific IPs, use four /32 entries or find the smallest CIDR block that covers all four. Using a /16 when you only need a /28 authorizes thousands of IPs you don't control, which weakens your SPF protection.

Does CIDR work the same way with IPv6?

Same concept, but IPv6 addresses are 128 bits instead of 32. Common IPv6 allocations are /48 (organization-level) and /64 (subnet-level). In SPF records, you'd use ip6:2001:db8::/48 format. The math scales identically — a /64 gives you 2^64 addresses (a truly massive number). As IPv6 adoption grows in email infrastructure, you'll need ip6 entries alongside ip4 in your SPF records.

Can I use CIDR to restrict who can connect to my mail server?

Yes. CIDR is widely used in firewall rules and access control lists. You might allow SMTP connections only from your office IP range (e.g., 203.0.113.0/28) or restrict relay access to specific subnets. Most mail server software (Postfix, Exchange, etc.) supports CIDR notation in its access configuration files.