IP Subnet Calculator

Work out network address, broadcast, usable host range and host count from any IPv4 or IPv6 CIDR block.

An address and a prefix length, separated by a slash. IPv4 and IPv6 both work. Host bits are masked off automatically.

Network address 192.168.1.0
Broadcast address 192.168.1.255
Subnet mask 255.255.255.0
Prefix /24
First usable host 192.168.1.1
Last usable host 192.168.1.254
Usable hosts 254
Total addresses 256
IP version IPv4

What it does

Enter a network in CIDR notation — an address and a prefix length, like 192.168.1.0/24 — and this tool works out the network address, the subnet mask, the broadcast address, the first and last usable host, and how many addresses the block contains. It handles IPv4 and IPv6, and it deals correctly with the edge cases that trip up a lot of calculators: point-to-point links, single-host routes, and the fact that IPv6 has no broadcast address at all. It runs entirely in your browser.

How it works

An IPv4 address is 32 bits, usually written as four decimal octets. An IPv6 address is 128 bits, written as groups of hexadecimal digits. In both cases the address is really just one long binary number, and a subnet is a decision about where to cut it in two.

The number after the slash — the prefix length — says how many bits from the left belong to the network. Everything to the right is the host portion, free to vary within that network. In 192.168.1.0/24 the first 24 bits identify the network and the remaining bits identify hosts inside it.

The subnet mask is the same information written as an address: a solid run of 1 bits for the network portion followed by 0 bits for the host portion. It is a run rather than an arbitrary pattern because the split has to be a single clean cut — that constraint is why masks always come out as familiar values like 255.255.255.0 and never something like 255.0.255.0. Applying the mask is a bitwise AND: the address AND the mask clears every host bit and leaves the network address.

That AND is also why host bits set in your input are masked off rather than rejected. Typing 172.16.5.23/20 is perfectly meaningful — it is a specific host, described along with the network it sits in. A correct calculator reports the network as 172.16.0.0; a lazy one throws an error and tells you the input is invalid.

The address count follows directly from how many host bits are left over. With p prefix bits on an IPv4 address there are 32 − p host bits, and each bit doubles the range, so the block holds 2(32 − p) addresses. For IPv6 the exponent is taken from 128 instead. This is a formula, not a lookup table, which matters at the extremes: 0.0.0.0/0 is the entire IPv4 space at 232 addresses, and a modest-looking IPv6 /48 holds 280 — a number too large for any native integer type, which is why the count here is computed with arbitrary precision.

Usable hosts are normally two fewer than the total. The all-zeros host value is the network address itself — the identifier for the subnet, used in routing tables — and the all-ones host value is the broadcast address, which reaches every host on the segment at once. Neither can be assigned to a machine, so a block of 256 addresses gives 254 usable ones.

There are two exceptions, and they are exceptions in different directions. A /31 has only two addresses, so subtracting two would leave none — and RFC 3021 says that on a point-to-point link, where there are exactly two ends and broadcast is meaningless, both addresses are usable. A /31 therefore has no broadcast address and two usable hosts, not zero. RFC 6164 makes the same argument for IPv6 /127 links. A /32 is the other degenerate case: one address, no host range to speak of, no broadcast — it is a single-host route, and that one address is usable.

IPv6 has no broadcast address whatsoever. It was removed from the protocol and replaced by multicast, so there is no all-ones address to reserve and nothing to subtract: every address in an IPv6 prefix is usable. When this tool shows a blank broadcast field for an IPv6 block, that is the correct answer and not a gap — a calculator that reports the last address as a "broadcast" for IPv6 is inventing something the protocol does not have.

Worked example

For 192.168.1.0/24 the prefix covers the first three octets, so the mask is 255.255.255.0 and the network address is 192.168.1.0. Eight host bits remain, giving 256 addresses in total. The first of those is the network address and the last, 192.168.1.255, is the broadcast address, so the assignable range runs from 192.168.1.1 to 192.168.1.254 — 254 usable hosts. This is the block behind most home and small-office routers, which is why 192.168.1.x looks familiar.

Common uses

  • Planning a network: deciding how to carve an allocation into subnets per site, floor, or VLAN, and checking each one is large enough for the devices it has to hold plus room to grow.
  • Cloud VPC design: AWS, Azure and GCP all take CIDR blocks for VPCs and subnets, and getting the sizes wrong is painful to undo — a VPC CIDR usually cannot be shrunk after creation.
  • Firewall and ACL rules: confirming that a rule written as a CIDR block covers exactly the addresses you intended, and no others.
  • Reading a routing table: working out which of several overlapping routes actually matches an address, since the longest prefix wins.
  • Checking a DHCP pool: making sure the pool sits inside the subnet and does not collide with the gateway or with statically assigned addresses.
  • Point-to-point links: sizing router-to-router links as /31 pairs instead of wasting a four-address block on two endpoints.

Frequently asked

What does /24 mean?

It means the first 24 bits of the address are the network portion, fixed for every host in that subnet, and the rest are free to vary. Twenty-four bits is exactly three octets, so a /24 corresponds to the mask 255.255.255.0 and holds 256 addresses, 254 of them assignable. It is the most common subnet size in small networks because it lines up neatly with the dotted-decimal notation.

Why are two addresses unusable?

Because two host values are reserved by convention and by protocol. The address with all host bits set to zero is the network — it names the subnet in routing tables rather than a machine on it. The address with all host bits set to one is the broadcast address, which delivers a packet to every host on the segment simultaneously; assigning it to a host would make it impossible to address that host individually. The exceptions are /31 and /32 on IPv4, and IPv6 generally.

How many hosts are in a /26?

A /26 leaves six host bits, so 26 = 64 addresses, of which 62 are usable. The mask is 255.255.255.192, and a /24 divides into exactly four such subnets. The same arithmetic gives 25 = 32 addresses and 30 usable for a /27, and 24 = 16 addresses and 14 usable for a /28: each step up in prefix length halves the block.

What is the difference between a subnet mask and a CIDR prefix?

They carry the same information in two notations. 255.255.255.0 and /24 both say "the first 24 bits are the network". The dotted mask is the older form, from the era when it was written out in full on every interface; CIDR notation is more compact and makes the bit count explicit, which is why routing and cloud configuration use it. This tool shows both. IPv6 only ever uses prefix notation in practice.

Does IPv6 have a broadcast address?

No. IPv6 dropped broadcast entirely and uses multicast instead — for example ff02::1 reaches all nodes on the local link, which achieves the same thing without forcing every device to process every broadcast packet. The practical consequence for subnetting is that nothing is reserved at the top of the range, so an IPv6 prefix has as many usable addresses as it has addresses.

Why does my calculator disagree about /31?

Older or simpler calculators apply the "subtract two" rule unconditionally and report zero usable hosts, which was correct before RFC 3021 was published in 2000 and is wrong now. Modern routers support /31 on point-to-point links, and using them halves the address waste compared with the old practice of allocating a four-address block per link.

Can I put a host address in instead of the network address?

Yes. Entering 172.16.5.23/20 works and reports the network 172.16.0.0, because the host bits are masked off with a bitwise AND rather than treated as an error. This is usually what you want: you have an address off a machine and you want to know what network it belongs to.