CIDR & Subnet Calculator

Work out what an IPv4 or IPv6 block covers, split it into subnets, and check whether an address is inside it.

192.168.1.0/24 Private (RFC 1918)

Network192.168.1.0/24
Broadcast192.168.1.255
Netmask255.255.255.0
Wildcard0.0.0.255
Mask, binary11111111.11111111.11111111.00000000
First host192.168.1.1
Last host192.168.1.254
Addresses256
Usable hosts254
KindPrivate (RFC 1918)

Enter a longer prefix to list the subnets, like /25.

Runs in your browser. Nothing you enter is sent anywhere.

How to use it

Type a block into Block or address, such as 192.168.1.0/24 or 2001:db8::/48, or pick one of the common blocks under it. A bare address is read as one host: /32 for IPv4, /128 for IPv6.

The answer line shows the block in its normal form and what kind of range it is, such as Private (RFC 1918) or Documentation. The table under it lists Network, Broadcast (up to /30), Netmask, Wildcard and Mask, binary (IPv4 only), then First host, Last host, Addresses, Usable hosts and Kind. Copy block copies the normalized CIDR.

To cut the block into smaller subnets, type a longer prefix length into Split into (26 or /26), or pick one of the chips under it. Up to 256 subnets are listed, each with its first and last address; past that, you get the total count and the first 256.

To test membership, type one address into Check an address. The answer is Yes or No, followed by the address and the block.

Examples

An address with host bits set, split into /28 and checked against 10.20.30.100:

Block or address: 10.20.30.77/26
Split into:       /28
Check an address: 10.20.30.100
10.20.30.64/26  Private (RFC 1918)
10.20.30.77/26 has host bits set, so it normalizes to 10.20.30.64/26.

Network        10.20.30.64/26
Broadcast      10.20.30.127
Netmask        255.255.255.192
Wildcard       0.0.0.63
Mask, binary   11111111.11111111.11111111.11000000
First host     10.20.30.65
Last host      10.20.30.126
Addresses      64
Usable hosts   62
Kind           Private (RFC 1918)

4 subnets of /28.
10.20.30.64/28    10.20.30.64    10.20.30.79
10.20.30.80/28    10.20.30.80    10.20.30.95
10.20.30.96/28    10.20.30.96    10.20.30.111
10.20.30.112/28   10.20.30.112   10.20.30.127

Yes  10.20.30.100 is inside 10.20.30.64/26

A point-to-point link, 10.1.2.0/31, gives First host 10.1.2.0, Last host 10.1.2.1, Usable hosts 2 and no Broadcast row (a /32 has none either), with the note RFC 3021: a /31 has no network or broadcast address, so both addresses are usable.

An IPv6 allocation, 2001:0DB8:0000:0000:0000:0000:0000:0000/48, split into /64, comes back as 2001:db8::/48 with 1208925819614629174706176 addresses, no broadcast row, and First host 2001:db8::1, since a note says 2001:db8:: is the Subnet-Router anycast address. Under the note /64 cuts the block into 65536 subnets; the first 256 are listed., the list starts:

2001:db8::/64
2001:db8:0:1::/64
2001:db8:0:2::/64
2001:db8:0:3::/64

A zero-padded octet, 192.168.01.0/24, is rejected with "01" has a leading zero, which some tools read as octal; write "1".

Good to know

  • The prefix is the number of fixed bits. A /n IPv4 block holds 2^(32 − n) addresses; take away the network and broadcast addresses and 2^(32 − n) − 2 are usable. That’s why a /24 has 256 addresses and 254 hosts.
  • /31 and /32 keep every address. RFC 3021 lets a point-to-point /31 use both, and a /32 is one host route.
  • IPv6 has no broadcast address (RFC 4291 uses multicast), but a block’s first address is its Subnet-Router anycast address, so a /64 has 2^64 − 1 usable hosts, as Python’s ipaddress counts them. A /127 (RFC 6164) and a /128 keep every address. A /64 is the normal LAN size: SLAAC (RFC 4862) builds addresses from a 64-bit interface ID.
  • Cloud subnets reserve more. AWS and Azure each keep 5 addresses in every subnet (the first four and the last), so a /24 there gives 251 hosts, not 254.
  • Host bits are cleared, with a note. 10.20.30.77/26 isn’t a network address; the tool tells you, and works with 10.20.30.64/26. Python’s ipaddress.ip_network() rejects the unnormalized form unless you pass strict=False.
  • The wildcard is the inverted netmask. Cisco ACLs and OSPF network statements take it instead of the netmask.
  • Kind names the first well-known range that wholly contains the block: RFC 1918 private space, the RFC 6598 shared range 100.64.0.0/10 used for carrier-grade NAT, link-local, the RFC 5737 and RFC 3849 documentation ranges, multicast, loopback, unique local fc00::/7 and reserved space. A block larger than its range, like 10.0.0.0/7, is labeled Global.
  • IPv6 output follows RFC 5952: lowercase, no leading zeros, the longest run of zero groups written as ::, and IPv4-mapped addresses kept in dotted form, as in ::ffff:192.0.2.1.
  • Families don’t mix. ::ffff:192.168.1.5 checked against 192.168.1.0/24 is No: it’s an IPv6 address, even though it maps to an address in that block.

Questions

How many usable hosts are in a /24?

A /24 has 254 usable hosts out of 256 addresses: the first, .0, is the network address and the last, .255, is broadcast. Each step down halves it: a /25 has 126, a /26 has 62, a /27 has 30.

How do I calculate a subnet mask from a CIDR prefix?

Write n ones followed by 32 − n zeros and read them as four 8-bit octets: /26 is 11111111.11111111.11111111.11000000, which is 255.255.255.192. The Mask, binary row shows exactly this.

How do I find the IP range of a CIDR block?

The range runs from the network address, the block with all host bits set to 0, to the address with all host bits set to 1. For 10.20.30.64/26 that’s 10.20.30.64 to 10.20.30.127; the usable hosts are the addresses in between.

How do I check if an IP address is in a subnet?

An address is in a block when its first n bits match the network’s. Type it into Check an address; in code, Python’s ipaddress.ip_address("10.0.0.5") in ipaddress.ip_network("10.0.0.0/8") does the same test.