HomeDeveloper & IT › IP Subnet Calculator

IP Subnet Calculator

Computes the network and broadcast addresses, subnet and wildcard masks, first and last host, usable and total addresses, address class and RFC 1918 private status for an IPv4 address in CIDR notation or with a dotted subnet mask, using 32-bit unsigned arithmetic.

When to use

You need to know which subnet an IPv4 address belongs to, the host range and count of a /prefix, or the mask equivalent of a prefix length.

Do not use when: The address is IPv6, you want to split a block into several subnets (VLSM planning), or you only need a number in binary or hex (use base-converter).

Formula

mask = 2^32 − 2^(32 − prefix); network = ip AND mask; broadcast = network OR NOT mask; total = 2^(32 − prefix); usable = total − 2 (prefix ≤ 30), 2 (prefix 31), 1 (prefix 32)

Classless (CIDR, RFC 4632) arithmetic on 32-bit unsigned integers; /31 follows RFC 3021 (both addresses usable on point-to-point links). Class letters are the historical classful designations only.

Inputs

ParameterTypeUnitRequiredDescription
cidrstringyesIPv4 address followed by /prefix (0–32) or by a dotted subnet mask separated by a space or slash, e.g. 192.168.1.10/26 or 192.168.1.10 255.255.255.192.

Outputs

OutputTypeUnitDescription
ip_addressstringThe address as parsed (dotted quad).
cidr_notationstringNetwork address with prefix length, e.g. 192.168.1.0/26.
network_addressstringip AND mask: the first address of the block.
broadcast_addressstringnetwork OR wildcard: the last address of the block (equals the address itself for /32).
subnet_maskstringDotted-decimal mask with prefix_length leading one bits.
wildcard_maskstringBitwise complement of the subnet mask (used in Cisco ACLs).
prefix_lengthintegerbitsNumber of network bits (the /n).
host_bitsintegerbits32 − prefix_length.
first_hoststringnetwork + 1 (for /31 and /32 the network address itself, RFC 3021).
last_hoststringbroadcast − 1 (for /31 the second address, for /32 the address itself).
usable_hostsinteger2^host_bits − 2, except 2 for /31 (RFC 3021 point-to-point) and 1 for /32.
total_addressesinteger2^host_bits including network and broadcast.
ip_classstringHistorical classful class from the first octet: A (0–127), B (128–191), C (192–223), D (224–239, multicast), E (240–255, reserved).
is_privatebooleantrue when the address lies in 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16; loopback and link-local blocks are reported separately in address_scope.
address_scopestringSpecial-use block the address belongs to (RFC 1918 private, loopback, link-local, CGNAT, multicast, reserved) or public.
binary_maskstringSubnet mask as four 8-bit groups.
binary_addressstringThe IP address as four 8-bit groups.
ip_integerintegerThe address as an unsigned 32-bit integer (a·2^24 + b·2^16 + c·2^8 + d).

Example

192.168.1.10/26: {"cidr":"192.168.1.10/26"}{"network_address":"192.168.1.0","broadcast_address":"192.168.1.63","subnet_mask":"255.255.255.192","wildcard_mask":"0.0.0.63","first_host":"192.168.1.1","last_host":"192.168.1.62","usable_hosts":62,"total_addresses":64,"prefix_length":26,"ip_class":"C","is_private":true,"ip_integer":3232235786,"binary_mask":"11111111.11111111.11111111.11000000"}

10.0.0.0/8 (whole class A private block): {"cidr":"10.0.0.0 255.0.0.0"}{"network_address":"10.0.0.0","broadcast_address":"10.255.255.255","usable_hosts":16777214,"total_addresses":16777216,"prefix_length":8,"first_host":"10.0.0.1","last_host":"10.255.255.254","ip_class":"A"}

GET https://tttkmbb.com/api/v1/calculate/subnet-calculator?cidr=192.168.1.10%2F26

Machine access

Sources

FAQ

Why does a /31 report 2 usable hosts?

RFC 3021 allows both addresses of a /31 on point-to-point links, since no broadcast address is needed; a /32 is a single host route. Every other prefix loses the network and broadcast addresses.

Can I enter the mask instead of the prefix?

Yes: 192.168.1.10 255.255.255.192 and 192.168.1.10/255.255.255.192 are both accepted. The mask must be contiguous ones followed by zeros.

Does is_private cover loopback and link-local addresses?

No, is_private is strictly RFC 1918; 127.0.0.0/8 (loopback), 169.254.0.0/16 (link-local) and 100.64.0.0/10 (carrier-grade NAT) are named in address_scope instead.

Related calculators