UUID Studio

IPv4 Subnet Calculator

Calculate network, broadcast, mask, and host range from CIDR.

  • 🔒 No data stored or uploaded
  • âš¡ 100% client-side
  • 🆓 Free, no account

Need more than one tool at a time? Open the full Workbench - or press Ctrl+K to jump to any tool.

Create or edit JSON here (syntax colors), then format, validate, or convert - same as MongoDB $binary UUID blobs on the Convert tab once detected.

New document

About IPv4 Subnet Calculator

An IPv4 subnet splits a 32-bit address into a network part and a host part. The prefix length after the slash - the /24 in 192.168.1.0/24 - says how many leading bits identify the network, so a /24 leaves 8 bits for hosts: 256 addresses, of which 254 are usable because the first is the network address and the last is the broadcast address.

The arithmetic worth memorising is that each step in prefix length halves or doubles the block. A /24 is 256 addresses, /25 is 128, /26 is 64, /27 is 32, /28 is 16, /29 is 8, /30 is 4. Subtract two for usable hosts in each case - so a /30, with just two usable addresses, is the classic point-to-point link, and a /29 giving six usable hosts is the smallest practical subnet for a small group of devices.

Two special prefixes behave differently. A /31 has no room for network and broadcast addresses, and RFC 3021 permits both of its addresses to be used for a point-to-point link. A /32 is a single host - what you use for a specific-host firewall rule or route.

Cloud providers reserve more than the standard two. AWS takes five addresses from every subnet (network, VPC router, DNS, a future-use address, and broadcast), so an AWS /28 gives you 11 usable addresses rather than 14. Azure and Google Cloud reserve five as well. Sizing a cloud subnet with the textbook formula leaves you short.

Everything is computed in your browser and nothing is transmitted.

How to use the IPv4 Subnet Calculator

  1. Enter an address with a prefix (192.168.1.10/26) or an address and a dotted-decimal mask.
  2. Read off the network address, broadcast address, usable host range, and total and usable counts.
  3. For cloud subnets, subtract three more from the usable count - AWS, Azure and GCP each reserve five addresses rather than two.
  4. When splitting a block, check that the new subnets do not overlap and that each starts on a correct boundary.

Examples

  • Class C /24
    192.168.1.0/24
  • Small /28 block
    10.0.0.0/28

IPv4 Subnet Calculator in code

The same operation this tool performs, in the languages you are most likely to need it.

Prefix reference
# Prefix  Mask              Addresses  Usable  Typical use
# /30     255.255.255.252   4          2       point-to-point link
# /29     255.255.255.248   8          6       tiny subnet
# /28     255.255.255.240   16         14      small subnet (11 on AWS)
# /27     255.255.255.224   32         30
# /26     255.255.255.192   64         62
# /25     255.255.255.128   128        126
# /24     255.255.255.0     256        254     the classic LAN
# /23     255.255.254.0     512        510
# /22     255.255.252.0     1024       1022
# /16     255.255.0.0       65536      65534   a large VPC

# RFC 1918 private ranges
# 10.0.0.0/8        10.0.0.0     - 10.255.255.255
# 172.16.0.0/12     172.16.0.0   - 172.31.255.255
# 192.168.0.0/16    192.168.0.0  - 192.168.255.255
Python - the ipaddress module
import ipaddress

net = ipaddress.ip_network("192.168.1.0/26")
print(net.network_address)      # 192.168.1.0
print(net.broadcast_address)    # 192.168.1.63
print(net.num_addresses)        # 64
print(sum(1 for _ in net.hosts()))   # 62

# Does an address fall inside a network?
ipaddress.ip_address("192.168.1.40") in net      # True

# Split a /24 into four /26s
for sub in ipaddress.ip_network("10.0.0.0/24").subnets(new_prefix=26):
    print(sub)

# Do two blocks overlap? Check before you allocate.
a = ipaddress.ip_network("10.0.0.0/22")
b = ipaddress.ip_network("10.0.2.0/24")
print(a.overlaps(b))            # True
Command line
# ipcalc, if installed
ipcalc 192.168.1.10/26

# Without it
python3 -c "import ipaddress,sys; n=ipaddress.ip_network(sys.argv[1], strict=False); \
print(n.network_address, n.broadcast_address, n.num_addresses)" 192.168.1.10/26

# List every address in a small block
python3 -c "import ipaddress; print('\n'.join(str(h) for h in ipaddress.ip_network('192.168.1.0/29').hosts()))"

When you need this

  • Sizing a VPC subnet before creating it, so you do not run out of addresses.
  • Working out whether two CIDR blocks overlap before allocating one.
  • Converting between a prefix length and a dotted-decimal mask.
  • Checking whether a specific address falls within a firewall or security-group rule.
  • Splitting a larger block into evenly sized subnets for separate tiers.

Common problems and what causes them

Forgetting the two reserved addresses
A /24 has 256 addresses but 254 usable: the first is the network address and the last is broadcast. Sizing a subnet for exactly as many hosts as the block has addresses leaves you two short.
Cloud providers reserving five, not two
AWS, Azure and GCP each reserve five addresses per subnet. An AWS /28 gives 11 usable addresses, not 14. This regularly breaks a deployment sized with the textbook formula.
A host address used where a network address belongs
192.168.1.10/24 describes a host within 192.168.1.0/24. Configuration that expects a network will either reject it or silently normalise it - Python's ip_network requires strict=False to accept it at all.
Overlapping CIDR blocks
10.0.0.0/22 covers 10.0.0.0 through 10.0.3.255, so 10.0.2.0/24 sits inside it. Overlaps cause routing ambiguity and are rejected by most cloud VPCs - check with an overlap test before allocating.
Confusing prefix length with usable hosts
A larger prefix number means a smaller network. /24 is bigger than /26. It is a common slip when reading a table quickly, and it results in a subnet a quarter of the intended size.
Choosing a VPC range that collides with a future peer
192.168.0.0/24 and 10.0.0.0/24 are extremely common defaults, so a VPC using one will eventually conflict with a partner network or VPN you want to peer with. Pick a less obvious block inside 10.0.0.0/8 from the start - renumbering later is painful.

FAQ

How many usable hosts are in a /24?
254. The block holds 256 addresses; the first is the network address and the last is the broadcast address. On AWS, Azure or GCP it is 251, because they reserve five.
What is a /26 subnet?
A block of 64 addresses with 62 usable, mask 255.255.255.192. A /24 splits into exactly four /26s - useful when you want four separate subnets from one class-C-sized block.
Why does AWS give me fewer addresses than the calculator says?
AWS reserves five addresses in every subnet: the network address, the VPC router, DNS, one reserved for future use, and the broadcast address. So subtract five rather than two. Azure and GCP do the same.
What is the smallest subnet I can use?
For a point-to-point link, a /31 - RFC 3021 allows both of its two addresses to be used. Otherwise a /30 gives two usable addresses, and a /29 with six usable is the smallest practical subnet for a handful of devices. A /32 is a single host, used for specific routes and firewall rules.
How do I tell whether two CIDR blocks overlap?
Compare their ranges: they overlap if either block's network address falls inside the other. In Python, ipaddress.ip_network(a).overlaps(ipaddress.ip_network(b)). Do this before allocating, because overlapping ranges break VPC peering and cause routing ambiguity.
Which private ranges can I use?
The RFC 1918 blocks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Pick something non-obvious within 10.0.0.0/8 for anything you may later peer with another network, since 192.168.0.0/24 and 10.0.0.0/24 are so widely used that collisions are likely.
Does it support IPv6?
No, this calculator is IPv4 only - IPv6 subnetting works differently and deserves its own dedicated tool.

Related reading