IP/CIDR Calculator
Check if IP addresses fall within CIDR ranges, calculate subnet details, and verify webhook provider IP allowlists.
How CIDR notation works
CIDR (Classless Inter-Domain Routing) notation writes a block of IP addresses as a starting address and a prefix length, such as 192.30.252.0/22. The number after the slash is how many of the 32 bits in an IPv4 address are fixed. The remaining bits can be anything, so a /22 leaves 10 free bits and covers 210 = 1,024 addresses, from 192.30.252.0 to 192.30.255.255.
The netmask is the same prefix written as an address: 22 one-bits followed by 10 zero-bits, or 255.255.252.0. The wildcard mask is its inverse, 0.0.3.255, which some firewalls and ACLs expect instead.
CIDR prefix cheat sheet
| Prefix | Netmask | Wildcard | Addresses |
|---|---|---|---|
/8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 |
/16 | 255.255.0.0 | 0.0.255.255 | 65,536 |
/20 | 255.255.240.0 | 0.0.15.255 | 4,096 |
/22 | 255.255.252.0 | 0.0.3.255 | 1,024 |
/24 | 255.255.255.0 | 0.0.0.255 | 256 |
/25 | 255.255.255.128 | 0.0.0.127 | 128 |
/26 | 255.255.255.192 | 0.0.0.63 | 64 |
/27 | 255.255.255.224 | 0.0.0.31 | 32 |
/28 | 255.255.255.240 | 0.0.0.15 | 16 |
/29 | 255.255.255.248 | 0.0.0.7 | 8 |
/30 | 255.255.255.252 | 0.0.0.3 | 4 |
/31 | 255.255.255.254 | 0.0.0.1 | 2 |
/32 | 255.255.255.255 | 0.0.0.0 | 1 |
In a normal subnet the first address (network) and last address (broadcast) are not assigned to hosts, so usable hosts are the total minus two. /31 point-to-point links and /32 single hosts are the exceptions.
Check if an IP is in a range in code
The test is the same everywhere: mask both addresses with the prefix and compare. In Python, the standard library does it for you:
import ipaddress
ipaddress.ip_address("192.30.253.10") in ipaddress.ip_network("192.30.252.0/22")
# TrueIn JavaScript, with no dependencies:
function ipToInt(ip) {
return ip.split('.').reduce((acc, octet) => (acc << 8) + Number(octet), 0) >>> 0;
}
function inCidr(ip, cidr) {
const [range, bits] = cidr.split('/');
const mask = bits === '0' ? 0 : (~0 << (32 - Number(bits))) >>> 0;
return (ipToInt(ip) & mask) >>> 0 === (ipToInt(range) & mask) >>> 0;
}
inCidr('192.30.253.10', '192.30.252.0/22'); // true
inCidr('192.30.251.1', '192.30.252.0/22'); // falseThe >>> 0 keeps the values unsigned. Without it, addresses above 128.0.0.0 turn negative in JavaScript's 32-bit bitwise operations.
IP allowlists for webhooks
Many webhook providers publish the IP ranges they send from, and a common hardening step is to accept webhook requests only from those ranges. Two things to keep in mind: providers change their ranges, so load them from the provider's published list rather than hard-coding them, and an allowlist is a complement to signature verification, not a replacement for it.
Hookbase sources can enforce an IP allowlist with CIDR ranges, and Hookbase can deliver to your servers from a fixed egress IP so that you can allowlist Hookbase in turn. See the IP filtering guide and static IP delivery.
Frequently asked questions
How do I check if an IP address is in a CIDR range?+
Enter the IP and the range (for example 192.30.253.10 and 192.30.252.0/22) in the checker above. Under the hood, both addresses are converted to 32-bit numbers and compared after applying the network mask: if the masked values are equal, the IP is inside the range.
How many IP addresses are in a /24?+
A /24 has 256 addresses (2 to the power of 32 minus 24). In a normal subnet, the first is the network address and the last is the broadcast address, which leaves 254 usable host addresses.
What does /32 mean in CIDR notation?+
A /32 is a single IPv4 address: all 32 bits are fixed. Allowlists often use /32 entries for individual servers, such as the static IP a webhook sender delivers from.
Does this CIDR calculator support IPv6?+
No, this tool works with IPv4 addresses and ranges. IPv6 CIDR uses the same idea with 128-bit addresses, so a /64 leaves 64 bits for hosts.
Why do webhook providers publish IP ranges?+
So receivers can allowlist them. Accepting webhook requests only from the provider's published ranges blocks forged requests at the network edge, as an extra layer on top of signature verification.
Want more? Try IP filtering and allowlisting in Hookbase
Get started free with no credit card required.