bitlvl
EN

Subnet calculator

Enter an IPv4 address with a prefix length or a subnet mask. You get every address that matters, the mask in binary, and a table of smaller subnets if you want to split it.

 

Split into subnets

How subnetting works

An IPv4 address is 32 bits. The prefix length (the number after the slash) says how many of those bits, counted from the left, identify the network; the rest identify the host inside it. 192.168.1.10/24 means the first 24 bits (192.168.1) are the network and the last 8 are the host, which gives 2⁸ = 256 addresses.

The subnet mask is the same information as a dotted number: 24 one-bits followed by 8 zero-bits is 255.255.255.0. AND the address with the mask and you get the network address; OR it with the inverted mask (the wildcard) and you get the broadcast address.

  1. Write the address and the mask in binary.
  2. Network address = address AND mask (host bits forced to 0).
  3. Broadcast address = address OR wildcard (host bits forced to 1).
  4. Usable hosts = everything in between, so 2host bits − 2.

Why two addresses are lost

The all-zeros host address names the network itself and the all-ones address is the broadcast, so a /24 has 254 usable hosts, not 256. The exceptions are point-to-point links: a /31 uses both addresses as hosts (RFC 3021) and a /32 is a single host route.

Quick reference

PrefixMaskAddressesUsable
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/20255.255.240.04,0964,094
/22255.255.252.01,0241,022
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/31255.255.255.25422 (point-to-point)
/32255.255.255.25511 (host route)

Private and special ranges

10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private (RFC 1918) and never routed on the internet. 100.64.0.0/10 is carrier-grade NAT space, 169.254.0.0/16 is link-local, 127.0.0.0/8 is loopback, and 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 are reserved for documentation. The calculator labels these automatically.

Questions

How many hosts are in a /24?

256 addresses, of which 254 are usable: one is the network address and one is the broadcast.

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

They are bit-for-bit inverses. The subnet mask has 1s over the network bits (255.255.255.0); the wildcard has 1s over the host bits (0.0.0.255). Cisco access lists and OSPF configuration use wildcard masks.

What does CIDR mean?

Classless Inter-Domain Routing. It replaced the old class A/B/C system with a prefix length that can be any value from 0 to 32, so address blocks can be sized to fit. The /24 notation is CIDR notation.

How do I split a /24 into four subnets?

Add two bits to the prefix: four /26 subnets of 64 addresses each (.0, .64, .128, .192). Choose /26 in the split section above to see the table with each subnet's range.

Is 172.20.1.1 a private address?

Yes. 172.16.0.0/12 covers 172.16.0.0 through 172.31.255.255, so anything from 172.16.x.x to 172.31.x.x is private.

Why is my /31 showing two usable hosts?

RFC 3021 allows /31 on point-to-point links, where there is no need for a broadcast address. Both addresses are assigned to the two ends of the link. Most modern routers support it.