What CIDR notation is
CIDR (Classless Inter-Domain Routing) notation writes a block of IP addresses as an address and a prefix length: 10.20.0.0/22. The prefix length says how many leading bits are fixed. All addresses that share those bits belong to the block.
CIDR replaced the old fixed classes A, B and C in the 1990s and is described in RFC 4632 for IPv4. IPv6 uses the same notation from the start. Firewalls, cloud security groups, Kubernetes network policies and reverse proxy allow lists all speak CIDR.
This calculator turns a CIDR block into its first and last address, size and masks, and checks whether a given address falls inside it. It handles IPv4 and IPv6.
How a CIDR block is worked out
The prefix length becomes a mask: that many 1 bits followed by 0 bits. AND the address with the mask to get the first address; set all the host bits to 1 to get the last.
10.20.0.0/22
Address 00001010.00010100.000000|00.00000000
Mask 11111111.11111111.111111|00.00000000 = 255.255.252.0
<------ 22 network bits ------>|<- 10 host bits ->
First 10.20.0.0
Last 10.20.3.255 (all 10 host bits set)
Size 2^10 = 1,024 addresses| IPv4 prefix | Addresses | Netmask | Common use |
|---|---|---|---|
| /32 | 1 | 255.255.255.255 | A single host |
| /31 | 2 | 255.255.255.254 | A point-to-point link |
| /30 | 4 | 255.255.255.252 | A small link with 2 usable hosts |
| /28 | 16 | 255.255.255.240 | A small subnet |
| /24 | 256 | 255.255.255.0 | A typical LAN or cloud subnet |
| /16 | 65,536 | 255.255.0.0 | A virtual network or VPC |
| /8 | 16,777,216 | 255.0.0.0 | A very large private range |
Usable hosts in IPv4
In a traditional IPv4 subnet, the first address names the network and the last is the broadcast address, so neither is given to a host. A /24 has 256 addresses and 254 usable hosts. A /31 is the exception: RFC 3021 allows both addresses on a point-to-point link. A /32 is a single host.
Cloud providers often reserve a few more addresses at the start of each subnet for their own routers and DNS; check your provider’s documentation for the exact count.
IPv6
IPv6 addresses are 128 bits, written as eight groups of four hex digits, with :: standing for one run of zero groups. There is no broadcast address. A single LAN is normally a /64, which holds 2^64 addresses; sites are often given a /48 or /56.
This calculator prints IPv6 addresses in the canonical short form of RFC 5952: lowercase, leading zeros dropped, and the longest run of zero groups replaced by ::.
Special ranges worth recognizing
Some ranges are reserved for particular uses. The calculator labels them when a block falls inside one.
| Range | Meaning | Defined in |
|---|---|---|
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private networks, not routed on the internet | RFC 1918 |
100.64.0.0/10 | Shared address space for carrier-grade NAT | RFC 6598 |
127.0.0.0/8, ::1/128 | Loopback | RFC 1122, RFC 4291 |
169.254.0.0/16, fe80::/10 | Link-local | RFC 3927, RFC 4291 |
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Documentation and examples | RFC 5737 |
2001:db8::/32 | IPv6 documentation and examples | RFC 3849 |
fc00::/7 | IPv6 unique local addresses, the private range | RFC 4193 |
224.0.0.0/4, ff00::/8 | Multicast | RFC 5771, RFC 4291 |
What this calculator does and does not do
- It reads an IPv4 or IPv6 CIDR block, or a single address, which it treats as a /32 or /128.
- It shows the first and last address, the number of addresses, and for IPv4 the usable hosts, netmask and wildcard mask; for IPv6 the full expanded form.
- It warns when you type an address with host bits set, such as
10.20.3.17/22, and shows the block it actually names. - It checks whether an address is inside the block.
- It labels private, documentation, loopback and other special ranges.
- It rejects ambiguous input such as IPv4 parts with leading zeros, which some systems read as octal.
- It does not split a block into subnets or merge several blocks into one.
How to use it
- Type a block such as
203.0.113.0/24or2001:db8:1234::/48. - Read the first and last address and the size.
- If a warning says host bits are set, use the network address it shows in your configuration.
- Type an address in the second field to check whether the block covers it.
- Copy the CIDR into your firewall, security group or proxy allow list.
CIDR in identity infrastructure
Address ranges come up whenever you restrict who can reach part of an identity system.
Restricting the Keycloak admin console
Keycloak has no IP allow list of its own for the admin console. The usual approach is to block or restrict the admin paths at the reverse proxy or load balancer in front of it, allowing only office, VPN or bastion ranges. Keycloak can also serve the admin console on a separate host name with the hostname-admin option, which makes it easier to keep that host internal.
Trusting a reverse proxy
Behind a proxy, Keycloak reads the client’s address and the original scheme from forwarded headers when proxy-headers is set. Only the proxy should be able to reach Keycloak directly; otherwise anyone can send forged forwarded headers. Restrict access to Keycloak’s port to the proxy’s addresses with a network rule.
Outbound allow lists
Identity providers call out to other systems: LDAP directories, SMTP servers, external identity providers and webhook targets. Firewalls that limit outbound traffic need those systems’ ranges.
Conditional access by network
Some organizations require a second factor only from outside the corporate network. That rule needs a precise list of the corporate ranges, and checking an address against them is exactly what the second field of this calculator does.
Common mistakes
- Writing an address with host bits set, such as
10.20.3.17/22, where the network address10.20.0.0/22was meant. Some tools silently fix it, others reject it, and some match something different. - Off-by-one prefixes: a /23 is twice the size of a /24, and a /25 half.
- Forgetting IPv6. A rule that allows an IPv4 range does nothing for users who connect over IPv6.
- Allowing a whole cloud provider’s range when only one of your services lives there. Anyone else on that provider is then allowed too.
- Writing IPv4 parts with leading zeros, such as
010.001.000.000, which some parsers read as octal. - Trusting client IP headers such as
X-Forwarded-Forwithout checking that the request came from your own proxy.
Security notes
IP restrictions are a useful outer layer, not authentication. Addresses can be shared, as with carrier-grade NAT and VPNs, and they change. Keep strong authentication, including a second factor, on admin access even when it is restricted by network.
Keep allow lists as narrow as you can, and review them. Ranges for offices and VPNs that no longer exist are a common leftover.
Splitting and combining blocks
Each step in prefix length halves or doubles a block. A /22 splits into two /23s, four /24s or eight /25s, and two neighboring /24s combine into a /23 only if they start on a /23 boundary.
| Block | Splits into | Ranges |
|---|---|---|
10.20.0.0/22 | Four /24s | 10.20.0.0/24, 10.20.1.0/24, 10.20.2.0/24, 10.20.3.0/24 |
10.20.0.0/23 | Two /24s | 10.20.0.0/24, 10.20.1.0/24 |
10.20.1.0/24 and 10.20.2.0/24 | Cannot combine | They do not share a /23; the smallest single block covering both is 10.20.0.0/22 |
When planning networks for a cluster, leave room: pod and service ranges must not overlap each other, the node network, or any network you connect to through VPN or peering.