CIDR and Subnet Calculator for IPv4 and IPv6

Enter an address with a prefix length, such as 192.168.1.100/26 or 2001:db8::/32. For IPv4 you get the network and broadcast addresses, subnet and wildcard masks, the usable host range, and host counts after AWS and Google Cloud reservations. For IPv6 you get the network address, the last address and the total address count.

Related Developer Tools

Runs in your browser: your files and text are not uploaded. Free, no account needed.

Last updated: · Reviewed by the QuickTooly Team

Subnet maths

How the IPv4 Values Are Worked Out

The prefix length is the number of leading bits, out of 32, that belong to the network. The calculator builds a mask with that many 1 bits and applies it to the address:

  • Network address = address AND mask.
  • Wildcard mask = the mask with every bit inverted.
  • Broadcast address = network address OR wildcard mask.
  • Total hosts = 2(32 − prefix).
  • Usable hosts = total − 2, since the network and broadcast addresses cannot be assigned. AWS usable = usable − 3; GCP usable = usable − 2.

Worked Example: 192.168.1.100/26

  • 26 network bits leave 6 host bits, so the block holds 26 = 64 addresses.
  • Mask: 255.255.255.192, or 11111111.11111111.11111111.11000000. Wildcard: 0.0.0.63.
  • The last octet, 100, is 01100100. AND 11000000 gives 01000000 = 64, so the network address is 192.168.1.64.
  • Broadcast: 64 + 63 = 127, so 192.168.1.127.
  • Usable range: 192.168.1.65 to 192.168.1.126, which is 62 hosts. AWS leaves 59 and Google Cloud 60.

You do not need to type the network address. Any address inside the block gives the same result.

/31, /32 and Cloud Reservations

  • /31: two addresses, and both count as usable. RFC 3021 allows this on point-to-point links, where no network or broadcast address is needed. The Broadcast row then simply shows the second address.
  • /32: a single host. Network, broadcast, first and last host are all the same address. This is the form used for one host in firewall rules and route tables.
  • AWS: reserves five addresses per subnet: the network address, the next three (VPC router, DNS and one held for future use) and the broadcast address. The figure is shown for /29 and larger, but AWS only allows IPv4 subnets from /16 to /28, so the /29 value cannot occur there.
  • Google Cloud: reserves four: the network address, the default gateway, the second-to-last address and the broadcast address. Shown for /29 and larger, which is the smallest subnet Google Cloud allows.
  • Blocks too small for a reservation show "N/A (too small)".

IPv4 Prefix Reference

CIDRSubnet MaskTotal HostsUsable HostsAWS Usable
/16255.255.0.065,53665,53465,531
/20255.255.240.04,0964,0944,091
/21255.255.248.02,0482,0462,043
/22255.255.252.01,0241,0221,019
/23255.255.254.0512510507
/24255.255.255.0256254251
/25255.255.255.128128126123
/26255.255.255.192646259
/27255.255.255.224323027
/28255.255.255.240161411
/29255.255.255.248863
/30255.255.255.25242N/A

IPv6 Results

IPv6 has no broadcast address, so the calculator shows the network address, the prefix length, the last address in the block and the total number of addresses. Counts above 1018 are written as a power of two: a /64 shows 2^64.

Addresses are shortened as RFC 5952 describes: leading zeros are dropped and the longest run of zero groups becomes ::, so fe80:0:0:0:0:0:0:1 shows as fe80::1.

Input Mistakes

  • No prefix: an address without a slash gives "Invalid format - use CIDR notation like 192.168.1.0/24".
  • Mask after the slash: the tool expects /26, not /255.255.255.192.
  • Prefix out of range: 0 to 32 for IPv4, 0 to 128 for IPv6.
  • Malformed address: an empty IPv4 octet (10..0.1), more than eight IPv6 groups, or a second :: gives an "Invalid IPv4 address" or "Invalid IPv6 address" error. Extra characters after the prefix, such as /24x, give the prefix error.
  • IPv4-mapped IPv6: forms like ::ffff:192.0.2.1 are rejected; enter the IPv4 address on its own.

Subnet Questions

Why does a /31 show two usable hosts?

A /31 has no network or broadcast address. RFC 3021 allows both addresses to be used on point-to-point links, so the calculator counts both as usable.

Why do AWS and GCP show fewer hosts than Usable Hosts?

AWS reserves five addresses per subnet and Google Cloud reserves four. Usable Hosts already excludes the network and broadcast addresses, so the calculator subtracts three more for AWS and two more for Google Cloud.

Can I enter a subnet mask instead of a prefix?

No. Convert the mask to a prefix first: 255.255.255.0 is /24 and 255.255.255.192 is /26. A dotted mask after the slash gives the error "IPv4 prefix must be between 0 and 32".