IPv4 Subnet Calculator
Calculate the network, broadcast, usable host range, mask, and host count for any IPv4 subnet.
Inputs
Restricts the subnet list to the prefixes valid for that class.
Subnet mask and its CIDR prefix length.
Enter a dotted-decimal address, e.g. 10.0.0.5
Network Address
192.168.1.0 /24
Broadcast Address
192.168.1.255
Usable Host Range
192.168.1.1 – 192.168.1.254
Usable Hosts
254
Total Addresses
256
Subnet Mask
255.255.255.0
Wildcard Mask
0.0.0.255
CIDR Notation
/24
Short
192.168.1.0/24
IP Class
Class C
Address Type
Private
Binary Subnet Mask
11111111.11111111.11111111.00000000
Binary IP
11000000.10101000.00000001.00001010
Binary ID
11000000101010000000000100001010
Hex ID
0xC0A8010A
Integer ID
3232235786
in-addr.arpa (reverse DNS)
10.1.168.192.in-addr.arpa
IPv4-Mapped IPv6 Address
::ffff:c0a8:010a
6to4 Prefix
2002:c0a8:010a::/48
Step by step
Read the /24 prefix from the subnet list
24 leading 1-bits, then 8 zero-bits
= 255.255.255.0 (11111111.11111111.11111111.00000000)
AND the address with the mask to get the network
192.168.1.10 AND 255.255.255.0
= 192.168.1.0
OR the network with the wildcard to get the broadcast
192.168.1.0 OR 0.0.0.255
= 192.168.1.255
Count the addresses in the block
2^(32 − 24) = 2^8
= 256
Subtract the unusable addresses
256 − 2 (network + broadcast)
= 254 usable hosts
How it works
The subnet mask (from the CIDR prefix) is applied to the IP address with a bitwise AND to find the network address, and the inverse (wildcard) mask gives the broadcast address. Usable hosts equal the total addresses in the block minus the network and broadcast addresses — except /31 links (RFC 3021, 2 hosts) and /32 (a single host).
Formulas
Network and broadcast address
network = ip AND mask ; broadcast = network OR NOT mask
- ip
- The 32-bit address, as four octets
- mask
- The subnet mask derived from the CIDR prefix
- ~mask
- The wildcard (inverse) mask
Usable host count
hosts = 2^(32 − cidr) − 2
- cidr
- Prefix length — the number of leading 1-bits in the mask
- − 2
- Excludes the network and broadcast addresses; /31 and /32 are exceptions
IPv4 Subnet Calculator — full guide
What a subnet mask actually does
An IPv4 address is 32 bits. A subnet mask splits those 32 bits into a network portion and a host portion. Every address that shares the same network portion is on the same local network and can be reached without a router.
The mask is a run of 1-bits followed by a run of 0-bits, which is why 255.255.255.0 and /24 mean the same thing: 24 leading ones. The slash notation is called CIDR, and it is what routers, cloud consoles and firewall rules generally want. Dotted masks survive mostly in Windows dialogs and older equipment.
The four numbers that define a subnet
For 192.168.10.0/24:
- Network address —
192.168.10.0, the identifier for the subnet. Obtained
by ANDing any address in the block with the mask.
- Broadcast address —
192.168.10.255, reaches every host at once.
Obtained by ORing the network with the inverted mask.
- Usable range —
192.168.10.1to192.168.10.254. Everything between
the two above.
- Host count — 2^(32 − prefix) total, minus the network and broadcast, so
254 here.
Why you lose two addresses (and when you don't)
The first address names the network and the last is the broadcast, so neither can be assigned to a machine. There are two exceptions worth knowing:
- /31 — RFC 3021 permits both addresses to be used on a point-to-point link,
giving 2 usable hosts from 2 addresses. Widely used on router-to-router links.
- /32 — a single host route. Common for loopbacks and for pinning a specific
address in an ACL or route table.
Prefix cheat sheet
| CIDR | Mask | Total | Usable | Typical use |
|---|---|---|---|---|
| /30 | 255.255.255.252 | 4 | 2 | Point-to-point links |
| /29 | 255.255.255.248 | 8 | 6 | Tiny device VLAN |
| /28 | 255.255.255.240 | 16 | 14 | Small server pool |
| /24 | 255.255.255.0 | 256 | 254 | Standard office LAN |
| /22 | 255.255.252.0 | 1024 | 1022 | Large flat network |
| /16 | 255.255.0.0 | 65536 | 65534 | Whole site or VPC |
Network classes, and why they mostly don't matter now
Classes A, B and C fixed the network/host split at 8, 16 and 24 bits. That system was replaced by CIDR in 1993 because it wasted enormous quantities of address space — an organisation needing 300 addresses had to take a Class B of 65,536.
Classes survive in two places: as vocabulary ("it's a class C network", usually meaning a /24), and in the default masks some tools still assume. The class selector in this calculator exists for that reason. A prefix that disagrees with the address's historical class is completely legitimate under CIDR, which is why a mismatch here produces a note rather than an error.
Private ranges worth memorising
10.0.0.0/8— 16.7 million addresses172.16.0.0/12— 1 million addresses192.168.0.0/16— 65,536 addresses169.254.0.0/16— link-local, self-assigned when DHCP fails127.0.0.0/8— loopback
Seeing a 169.254.x.x address on a machine almost always means DHCP did not answer.
Planning subnets without regret
Size for the network you will have in three years, not the one you have today, and leave gaps between allocations so a block can grow without renumbering. Renumbering a live network is genuinely painful, and address space inside a private range is effectively free — being generous costs nothing.
For IPv6 planning, see the IPv6 subnet calculator.
Guides that use this calculator
- How to Calculate a Subnet Mask (By Hand and Quickly)Work out subnet masks, network and broadcast addresses and host counts by hand — with the binary shortcuts network engineers actually use.8 min
- What Is CIDR Notation, and Why Did It Replace Network Classes?CIDR explained from first principles: what the slash number means, why classes A/B/C were abandoned, and how to read any prefix at a glance.7 min
Frequently Asked Questions
What does the CIDR prefix (/24) mean?
The prefix is how many leading bits of the address identify the network. /24 means the first 24 bits are the network portion (mask 255.255.255.0), leaving 8 bits — 256 addresses, 254 usable — for hosts.
Why are two addresses not usable?
In a normal subnet the first address is the network identifier and the last is the broadcast address, so neither can be assigned to a host. A /31 is the exception, used for point-to-point links where both addresses are usable.
What's the wildcard mask for?
The wildcard mask is the bitwise inverse of the subnet mask. It's commonly used in access control lists (ACLs) and OSPF configuration on routers to match ranges of addresses.
What does the Network Class selector do?
It filters the subnet list to the prefixes that are valid for that class: /8–/30 for Class A, /16–/30 for Class B, /24–/30 for Class C. Choose "Any" to work in pure CIDR terms with every prefix from /0 to /32 available, including /31 point-to-point links and /32 host routes. If the address you enter doesn't match the class you picked, the result still calculates correctly and adds a note — modern CIDR routing doesn't require the two to agree.
Why does the subnet dropdown show both a mask and a slash number?
They are two notations for the same thing. 255.255.255.0 and /24 both mean "the first 24 bits identify the network". Older equipment and Windows dialogs ask for the dotted mask; routers, cloud consoles and firewall rules usually want the CIDR prefix, so both are shown together.