Skip to content
MeasureMate

Network Calculator

Calculate an IPv4 subnet from an address and CIDR prefix: network and broadcast addresses, subnet and wildcard masks, host range and host count.

/
Quick Presets
192.168.1.0
Network Address
192.168.1.255
Broadcast Address
255.255.255.0
Subnet Mask
0.0.0.255
Wildcard Mask
192.168.1.1
First Usable Host
192.168.1.254
Last Usable Host
254
Total Usable Hosts
256
Total Addresses in /24

Updated Formula covered by automated tests

Give this subnet calculator any IPv4 address and a CIDR prefix length, and it works out the block that address belongs to: the network address, the broadcast address, the subnet mask in dotted-decimal form, the wildcard mask used in router access lists, the first and last assignable host, and how many devices the block can hold.

Network administrators reach for it when carving a company’s address space into VLANs, when writing firewall rules or cloud security groups that must match a range exactly, and when troubleshooting why two machines that look like neighbors cannot talk to each other. Students preparing for networking certifications use it to check subnetting drills done by hand.

Only IPv4 is covered. IPv6 subnetting follows the same prefix idea but with 128-bit addresses, and its convention of /64 for every LAN makes host counts a non-issue.

The formula

Mask = p one-bits followed by (32 − p) zero-bits
Network = IP AND Mask; Broadcast = Network OR (NOT Mask)
Addresses in block = 2^(32 − p); Usable hosts = 2^(32 − p) − 2 (for p ≤ 30)
p
Prefix length, the number after the slash: how many leading bits identify the network (0 to 32)
IP
The address you entered, treated as a 32-bit binary number
Mask
Subnet mask: p ones followed by 32 − p zeros, for example /26 = 255.255.255.192
NOT Mask
The wildcard (inverse) mask, used by Cisco ACLs and OSPF statements, for example 0.0.0.63 for a /26
AND, OR
Bitwise operations applied to each of the 32 bits

An IPv4 address is a 32-bit number written as four 8-bit octets. The prefix splits it into a network part and a host part. Setting all host bits to zero gives the network address, and setting them all to one gives the broadcast address; neither can be assigned to a device on an ordinary LAN, which is where the minus 2 comes from.

Two prefixes are exceptions. RFC 3021 (2000) allows /31 blocks on point-to-point links, where there are only two endpoints and no need for broadcast, so both addresses are usable. A /32 names exactly one address and is used for loopback interfaces and host routes.

CIDR, introduced in RFC 1519 in 1993 and updated by RFC 4632, replaced the old class A, B and C system, which only allowed /8, /16 and /24 networks. Allowing any prefix length slowed the exhaustion of IPv4 space and let routers summarize many small networks into one route.

Worked example

Luis, who runs the network for a small clinic, sees a printer at 10.20.30.77/26 and needs the range of its VLAN so he can write a firewall rule and pick a free static address.

  1. 1 Host bits: 32 − 26 = 6, so the block holds 2⁶ = 64 addresses and the mask is 255.255.255.192 (192 = 256 − 64).
  2. 2 Find the block: blocks in the last octet start at 0, 64, 128 and 192; 77 ÷ 64 = 1 remainder 13, so the network starts at 1 × 64 = 64, giving network address 10.20.30.64.
  3. 3 Broadcast: 64 + 64 − 1 = 127, so the broadcast address is 10.20.30.127.
  4. 4 Usable range: 10.20.30.65 to 10.20.30.126, which is 64 − 2 = 62 hosts.
  5. 5 Wildcard mask for the ACL: 255 − 192 = 63, written 0.0.0.63.

Result: The printer sits in 10.20.30.64/26. Luis can allow 10.20.30.64 0.0.0.63 in the firewall rule and assign any unused address from .65 to .126.

Before you rely on the result

  • IPv4 only; IPv6 addresses are not accepted.
  • The tool does not know whether an address is already in use, reserved by your cloud provider (AWS, Azure and Google Cloud each reserve several addresses per subnet), or covered by DHCP. Check your own allocation records before assigning.
  • Leading zeros in an octet are read as decimal (010 means 10), whereas some older software reads them as octal. Avoid leading zeros in configuration files.

Frequently asked questions

Why does a /24 give 254 hosts and not 256?

A /24 contains 256 addresses, but the first (all host bits zero, for example 192.168.1.0) identifies the network and the last (192.168.1.255) is the broadcast address. That leaves 192.168.1.1 to 192.168.1.254 for devices, and one of those is usually taken by the router.

Can I really use both addresses in a /31?

Yes, on a point-to-point link between two routers, as defined in RFC 3021. Most modern router and firewall operating systems support it, and it saves half the addresses compared with a /30. Do not use a /31 for a LAN segment with more than two devices.

Which subnet size should I choose for 50 devices?

Pick the smallest block whose usable count covers today’s devices plus growth. A /26 gives 62 hosts, which is tight for 50; a /25 gives 126 and leaves room for phones, printers and guests. Remember to count the gateway and any addresses reserved for DHCP exclusions.

What is the difference between a subnet mask and a wildcard mask?

They are bitwise inverses. The subnet mask marks network bits with 1s (255.255.255.192), while the wildcard mask marks the bits a rule should ignore with 1s (0.0.0.63). Cisco access lists and OSPF network statements use the wildcard form; interface configuration uses the subnet mask.

Which address ranges are private?

RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private networks. Shared carrier space 100.64.0.0/10 (RFC 6598) and link-local 169.254.0.0/16 are also not routed on the public internet.

Sources

All technology