IPv4 Subnet Calculator

Enter an IPv4 address with a CIDR prefix or a subnet mask to get the network address, broadcast address, usable host range, number of hosts, subnet mask and wildcard mask — with the binary working. It runs in your browser.

Subnet calculator

For example 192.168.1.10, or 192.168.1.10/24 with the prefix included.
Optional. A mask typed here, or a prefix written after the address, takes priority over the list.
Examples

Enter an IPv4 address and press Calculate.

How subnetting works

An IPv4 address is 32 bits, written as four numbers from 0 to 255 separated by dots, such as 192.168.1.10. A subnet mask splits those 32 bits into two parts: a run of 1 bits at the start for the network, and a run of 0 bits at the end for the host. Every address that shares the same network bits belongs to the same subnet and can reach each other directly, without going through a router. CIDR notation (Classless Inter-Domain Routing) writes the mask as a slash and a number, such as /24, instead of spelling it out as 255.255.255.0. The number after the slash — the prefix length — is simply a count of how many of the 32 bits are network bits.

This calculator takes an address and a prefix (or a typed subnet mask) and works out everything that follows from them: the network address, the broadcast address, the range of addresses a host can actually use, how many of those there are, the wildcard mask, and what kind of address it is — private, public, loopback, and so on. Every calculation is 32-bit integer arithmetic that runs in your browser; nothing you type is sent anywhere, and there is no lookup service behind it.

The two inputs

You need an IPv4 address and something that fixes the prefix length. There are three ways to give the calculator that second part, and it checks them in this order:

  • Type the prefix straight into the address box, as in 192.168.1.10/24. This takes priority over everything else.
  • Type a dotted subnet mask, such as 255.255.255.0, into the second field. This is used if the address box has no slash.
  • Otherwise the calculator falls back to the prefix length selected in the dropdown, which defaults to /24 and lists every value from /0 to /32 with its matching mask, so the list doubles as a lookup table.

A mask you type must be contiguous — every 1 bit before every 0 bit, as in 255.255.255.0 or 255.255.255.192. Something like 255.255.0.255, where a 0 bit is followed by a 1 bit, is not a valid subnet mask and the calculator rejects it. Each of the four numbers in an address or mask must be from 0 to 255, and a number written with a leading zero, such as 01 or 010, is refused rather than guessed — some tools read a leading zero as octal and others as decimal, so the same text would mean two different addresses depending on who reads it.

How the values are worked out

Everything the calculator shows comes from bitwise operations on the address and the mask, both treated as 32-bit numbers:

  • Network address — address AND mask. Every host bit is forced to 0.
  • Broadcast address — network OR wildcard mask. Every host bit is forced to 1.
  • Wildcard mask — the mask with every bit flipped. For /24 it is 0.0.0.255. Cisco access control lists and OSPF configuration use the wildcard mask instead of the subnet mask.
  • Total addresses — 2 raised to the power of (32 − prefix). A /24 has 2⁸ = 256 addresses.
  • Usable hosts — normally the total minus the network and broadcast addresses, since neither can be assigned to a device. The first usable address is the network address plus one; the last is the broadcast address minus one.

Worked example 1: 192.168.1.10/24

  1. /24 means 24 network bits, so the mask is 255.255.255.0.
  2. Network address: set the 8 host bits to 0 — 192.168.1.0.
  3. Broadcast address: set the host bits to 1 — 192.168.1.255.
  4. Usable hosts: 192.168.1.1 to 192.168.1.254, which is 2⁸ − 2 = 254 out of 256 total addresses.
  5. Wildcard mask: 0.0.0.255. Address type: private (RFC 1918).

Worked example 2: 172.16.4.2/30

A /30 leaves only 2 host bits, so there are 2² = 4 total addresses. The mask is 255.255.255.252. Masking 172.16.4.2 against it gives a network address of 172.16.4.0 and a broadcast address of 172.16.4.3, leaving 172.16.4.1 and 172.16.4.2 as the two usable addresses — 4 − 2 = 2 hosts. This is the size normally used for a point-to-point link between two routers, with one address on each end.

Worked example 3: 203.0.113.8/28

/28 leaves 4 host bits, so 2⁴ = 16 total addresses and 14 usable ones. The mask is 255.255.255.240. The network address is 203.0.113.0 and the broadcast address is 203.0.113.15, so hosts run from 203.0.113.1 to 203.0.113.14. The calculator labels the whole 203.0.113.0/24 block as documentation space under RFC 5737 — it is reserved for manuals and examples like this one, and is never assigned to a real network.

The /31 and /32 exceptions

The “total minus two” rule for usable hosts has two exceptions, both handled by the calculator rather than left as a wrong answer:

  • /31 — RFC 3021 allows a /31 on a point-to-point link, where there is no need for a separate network or broadcast address. Both of the two addresses are usable, so the result table shows “None” for broadcast and 2 for usable hosts instead of 0.
  • /32 — a single host route: one address, and it is its own network, broadcast and only usable host at once.

Outside of those two, if the address you typed happens to be the network address or the broadcast address of the subnet it falls into, the calculator adds a note saying so — that address describes the subnet itself and cannot be handed to a device.

Reading the result

The heading above the table shows the network address and prefix together, such as 192.168.1.0/24, with the address and mask you entered underneath it for reference. The “Subnet details” table lists the network address, broadcast address, first and last usable host, usable host count, total address count, subnet mask, wildcard mask, CIDR notation, address type and the historical class (A, B or C — a scheme from before CIDR existed, kept here only as background, since CIDR is what actually decides a subnet's size today). Below that, an “In binary” table shows the address, the mask, and the result of ANDing them together, so you can see the network-bit split directly rather than take the decimal numbers on trust.

Common mistakes

  • Assuming every /24 subtracts exactly 2. That holds for /0 through /30. A /31 keeps both addresses and a /32 is a single address — see the exceptions above.
  • Typing a non-contiguous mask. A mask like 255.255.0.255 mixes 0 bits and 1 bits out of order and is not a real subnet mask; the calculator rejects it with an explanation rather than silently producing a number.
  • Reading the broadcast address as usable. It marks every host on the subnet at once; sending a normal packet to it, or assigning it to one device, is a configuration error.
  • Confusing the subnet mask with the wildcard mask. They are bitwise opposites of each other. Router and firewall configuration that asks for a wildcard mask (Cisco access lists, OSPF network statements) wants the inverted value, not the mask itself.

What this calculator does not do

It works out one subnet from one address and one prefix — it does not split a block into several smaller subnets, does not do IPv6, and does not check whether an address is actually reachable or in use anywhere. The address type it reports (private, loopback, documentation and so on) comes from the IANA IPv4 Special-Purpose Address Registry, matched by range, not by contacting any server. For other calculations, the https://easycalculatorsmart.com/category/specialized/ category lists the rest of the site's specialized calculators.

Common prefix lengths

CIDRSubnet maskAddressesUsable hosts
/8 255.0.0.0 16,777,216 16,777,214
/16 255.255.0.0 65,536 65,534
/20 255.255.240.0 4,096 4,094
/22 255.255.252.0 1,024 1,022
/23 255.255.254.0 512 510
/24 255.255.255.0 256 254
/25 255.255.255.128 128 126
/26 255.255.255.192 64 62
/27 255.255.255.224 32 30
/28 255.255.255.240 16 14
/29 255.255.255.248 8 6
/30 255.255.255.252 4 2
/31 255.255.255.254 2 2
/32 255.255.255.255 1 1

Private, loopback and other special ranges

10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private ranges for internal networks. 127.0.0.0/8 is loopback, 169.254.0.0/16 is link-local, 100.64.0.0/10 is shared carrier-grade NAT space, and 224.0.0.0/4 is multicast. The calculator labels an address that falls in any of these, following the IANA special-purpose registry.

Standards behind the calculation

Frequently asked questions

What is a subnet mask?

A 32-bit value that marks which part of an IPv4 address identifies the network and which part identifies a host. The network bits are 1s and the host bits are 0s: 255.255.255.0 is 24 ones followed by 8 zeros.

What does /24 mean?

CIDR notation: the number of 1 bits at the start of the mask. /24 is the same as 255.255.255.0, /16 is 255.255.0.0 and /26 is 255.255.255.192.

How many hosts does a subnet have?

A subnet has 2 to the power of (32 − prefix) addresses. Two of them — the network address and the broadcast address — cannot be assigned to hosts, so a /24 has 256 addresses and 254 usable hosts.

Why does /31 have two usable hosts?

RFC 3021 allows a /31 on point-to-point links, where there is no need for a network or broadcast address. Both addresses can be used, so the usual “minus two” does not apply. A /32 is a single address.

How is the network address calculated?

By a bitwise AND of the address and the mask: every host bit is set to 0. The broadcast address sets every host bit to 1 instead.

What is a wildcard mask?

The mask with every bit inverted. For /24 it is 0.0.0.255. Cisco access control lists and OSPF configuration use wildcard masks rather than subnet masks.

Why is 192.168.01.1 rejected?

A leading zero is read as an octal number by some systems and as decimal by others, so 01 and 010 can mean different addresses. The calculator refuses it rather than guessing.

Is the address I enter sent anywhere?

No. The calculation runs entirely in your browser. Nothing is looked up online.

More in Specialized All calculators

Explore more calculators

Free calculators for maths, money, school, health, dates and more — no sign-up.

All calculators