IPv4 Subnet Mask Calculator

Enter an IPv4 address and mask to inspect its subnet: network and broadcast address, usable host range and address count. The other calculators on the page convert between prefix lengths, dotted masks, wildcard masks and binary, hexadecimal or integer notation.

Runs locally in your browser

IPv4 subnet calculator

Shows the network address, the broadcast address and the first and last usable host of the subnet that contains the entered address.

CIDR prefix and subnet mask converter

Mask and address calculator

Wildcard mask calculator

Dotted mask and prefix length

Invert an IPv4 address

Classful network calculator

Network List×

Network Hosts Broadcast address
Start End
0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0
0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0
0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0
0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0

Required hosts to CIDR prefix

Address and number base converter

CIDR prefix to address counts

How to read subnet details from an IPv4 address and prefix

Enter 192.168.0.1 with prefix 24 and the first panel prints mask 255.255.255.0, network 192.168.0.0, first host 192.168.0.1, last host 192.168.0.254, broadcast 192.168.0.255 and 254 usable addresses.

Nine more panels share the page: prefix to dotted mask, mask to prefix, wildcard masks, bit inversion, a classful subnet list, required-host sizing, and dotted, binary, hexadecimal and integer notation. They all run in this browser tab and the page issues no request while you calculate.

  1. Type the four octets of an IPv4 address and its CIDR prefix, then press Calculate in the first panel. Each octet takes 0 to 255 and the prefix takes 0 to 32.
  2. Read mask, network, first and last usable host, broadcast and the usable address count: 254 for /24, 126 for /25, 2 for /30. A /31 or /32 prints 2 or 1 and explains why.
  3. Use the second panel for prefix to dotted mask plus hexadecimal, the third for mask and address to network, host part and broadcast, and the fourth for mask to wildcard mask.
  4. In the classful panel choose a network type (or leave Default to use the class of the address) and either a subnet count or a hosts-per-subnet value, then press Calculate. Get Network List prints the subnets of that network.
  5. The remaining panels turn required hosts into a prefix (5 hosts to /29), a prefix into address counts (/27 to 32 addresses, 30 usable) and a dotted address into binary, hexadecimal and integer form (192.168.0.1 to C0 A8 00 01 and 3232235521).

What each calculator on the page answers

What the mask arithmetic does

The mask marks the network bits. Prefix 24 is 255.255.255.0, so the first three octets address the network and the last one addresses hosts: 192.168.0.1 AND 255.255.255.0 gives the network 192.168.0.0, and OR with the inverted mask gives the broadcast 192.168.0.255. The usable range is that block without its two ends, 192.168.0.1 to 192.168.0.254, which is 2^(32−24)−2 = 254 addresses.

The block grows as the prefix shrinks: /8 on 10.0.0.5 covers 10.0.0.0 to 10.255.255.255 with 16,777,214 usable addresses, and /12 on 172.16.5.9 ends at 172.31.255.255 with 1,048,574. Prefixes 0 to 30 follow the 2^(32−prefix)−2 rule; a /31 is a point-to-point link whose two addresses are both usable (RFC 3021), and a /32 is one address with no separate network or broadcast address.

Masks that are not masks

A subnet mask is a run of 1 bits followed by a run of 0 bits, so 255.255.255.0 and 255.240.0.0 are masks and 255.0.255.0 is not. The page refuses a dotted mask that breaks the rule instead of calculating with it; the earlier script accepted 255.0.255.0 and answered 192.168.0.1 with network 192.0.0.0 and broadcast 192.255.0.255.

The same rule applies to the wildcard mask and to mask-to-prefix conversion. Input that is not a whole number in range is refused with a sentence in the language of the page rather than a wrapped value: 256.1.1.1 is no longer read as 255.1.1.1, prefix 33 is an error instead of a full mask, and a required-host figure must be between 1 and 4,294,967,294.

The classful panel and its network list

The classful panel works from the class of the address (1–127 class A, 128–191 class B, 192–223 class C; 0.0.0.0 and anything from 224.0.0.0 up is refused) or from a network type you pick, and asks for either a subnet count or a hosts-per-subnet figure. Eight subnets inside the class C address 192.168.0.1 give mask 255.255.255.224, prefix /27, eight subnets and 30 usable hosts each; asking for 1024 hosts instead gives /21 and covers eight class C networks, which the panel reports as supernetting.

Network List prints every subnet of that network with its first and last host and its broadcast address, and stops after 256 rows with a "…" row. A request that cannot fit the class is reported as an error instead of being clamped: the earlier script turned 256 requested subnets in a class C address into 128, and could print host counts such as 5592405.333333333.

Recent tools: