IP Subnet Calculator
Calculate IPv4 and IPv6 subnet information instantly with advanced network analysis tools.
IPv4
Calculate network, broadcast, host range, mask, wildcard, class, scope, and binary breakdown for any IPv4 address.
What is the IP Subnet Calculator?
The SamCalculator IP Subnet Calculator is a developer-focused networking utility that converts an IP address and prefix length into every piece of subnet information a network engineer, sysadmin, or cloud architect needs in production — the network and broadcast addresses, first and last usable hosts, total and usable host counts, subnet and wildcard masks, hex and binary representations, IP class, and address scope (RFC 1918 private, CGNAT, APIPA link-local, loopback, multicast, or public). It supports both IPv4 (32-bit) and IPv6 (128-bit) addressing, a live CIDR explorer for every prefix length, a Variable Length Subnet Mask (VLSM) allocator that sizes child subnets by host requirement, and a two-way binary / hex / decimal converter for fast bit-level work.
Every calculation runs entirely in your browser — no IP address, mask, or subnet plan is ever sent to a server. The tool reads alongside your terminal: design a VPC subnet plan in the VLSM tab, validate a firewall ACL with the wildcard mask in the IPv4 tab, or convert an interface address to binary while you write Wireshark filters in the Binary tab.
How IP Subnetting Works
The network/host split
Every IPv4 address is 32 bits long and is divided into a network portion (the leading bits) and a host portion (the trailing bits). The subnet mask is a second 32-bit number whose 1-bits mark the network boundary. A /24 mask (255.255.255.0) reserves the first 24 bits for the network and leaves 8 bits — 256 addresses — for hosts on that subnet.
CIDR replaced classful addressing
Before 1993, IPv4 was rigidly split into Class A (/8), Class B (/16), and Class C (/24) blocks, which wasted enormous amounts of address space. RFC 1519 introduced Classless Inter-Domain Routing (CIDR), letting networks be sized at any bit boundary from /1 to /32 — the foundation of modern internet routing.
5 Ways Developers and Engineers Use This Tool
Plan AWS / Azure / GCP subnets
Carve a VPC /16 into per-AZ /20s, then sub-allocate /24 public, private, and database subnets that fit the service's host requirement without wasting addresses.
Validate ACLs and security groups
Quickly compute the wildcard mask for Cisco IOS ACLs, OSPF area statements, and EIGRP network commands — the bitwise inverse of the subnet mask.
Audit BGP advertisements
Verify that a route's network and broadcast addresses fall inside the prefix you mean to advertise, and that no longer-prefix overlaps escape the aggregate.
Study for CCNA / Network+ / AWS exams
Walk through the binary breakdown of any address, classify by RFC scope, and rehearse the VLSM allocation algorithm before the exam.
Debug DHCP scopes and IPAM
Cross-check the network, broadcast, first-host, and last-host the DHCP server should hand out — and confirm the gateway address isn't inside the scope.
Best Practices for IP Subnetting
- Size for growth, not exact fit. A subnet that is exactly the right size today becomes a re-numbering project the moment headcount or service count grows. Round up one or two prefix lengths.
- Use VLSM to avoid waste. A /24 for a 6-server VLAN burns 246 addresses; a /29 (8 addresses, 6 usable) fits perfectly. VLSM lets every subnet match its actual host requirement.
- Use /31 for point-to-point links. RFC 3021 standardised /31 in 2000 — both addresses are usable, saving two addresses per WAN link versus the legacy /30 convention.
- Document private vs public boundaries. Mixing RFC 1918, CGNAT (100.64.0.0/10), and public space in the same subnet plan is a footgun — every IPAM and firewall rule should classify which range it lives in.
- Allocate IPv6 in /64 increments. The IPv6 standard reserves the lower 64 bits of every subnet for SLAAC autoconfiguration — never use a prefix longer than /64 on a normal LAN, even though the math allows it.
- Aggregate before you advertise. Summarising routes at borders shrinks routing tables and reduces convergence time after a topology change. Plan address space hierarchically so aggregation falls out naturally.
Why Subnetting Matters
Without subnetting, every host on a network would share a single broadcast domain — broadcast and multicast traffic from every device hitting every other device. That stops scaling around a few hundred hosts: ARP storms, broadcast amplification, mDNS chatter, and IPv4 link-local autoconfiguration noise drown the link. Subnetting splits a network into smaller broadcast domains, isolates failure and security domains, lets you apply different routing and firewall policies to different segments, and enables hierarchical routing so internet-scale routing tables stay manageable.
Subnetting is also the language of cloud networking. Every Amazon VPC, Azure VNet, and Google Cloud VPC asks for a CIDR block, then asks you to carve sub-CIDRs for each public, private, and isolated subnet. Container networks, Kubernetes pod and service CIDRs, VPN tunnels, and BGP peering sessions all speak in CIDR. A network engineer who can't subnet in their head cannot operate at speed in 2026.
Tricky Cases to Watch For
- /31 has no broadcast. RFC 3021 explicitly removes the network and broadcast reservations for /31 prefixes — both addresses are host addresses. Pre-2000 routers may not accept /31; verify firmware before deploying.
- Discontiguous masks are illegal. Subnet masks must be left-aligned with no gaps — 255.255.255.0 is valid but 255.0.255.0 is not, even though some early routers accepted it. The calculator validates this automatically.
- CGNAT looks like public space. 100.64.0.0/10 (RFC 6598, Carrier-Grade NAT) is reserved for ISPs to NAT customer traffic and is not routable on the public internet — but it is outside the RFC 1918 private ranges, so naive scripts often misclassify it.
- IPv6 prefixes longer than /64 break SLAAC. Stateless Address Autoconfiguration generates the lower 64 bits of the interface address from the MAC (RFC 4291) — using /80, /96, or /127 on a LAN breaks address assignment. Reserve those for point-to-point links and host routes.
- Multicast scoping is easy to get wrong. The 4-bit scope nibble in an IPv6 multicast address controls how far the packet travels — ff02:: (link-local), ff05:: (site-local), ff08:: (org-local), ff0e:: (global). Cross-scope leaks cause noisy routing and security headaches.
Core Subnetting Formulas
Total addresses in a subnet
total = 2^(32 − prefix)
A /24 has 2^8 = 256 addresses; a /28 has 2^4 = 16 addresses.
Usable host count (IPv4)
usable = 2^(32 − prefix) − 2 // except /31 = 2, /32 = 1
Two addresses are reserved on every IPv4 subnet: the network identifier (all-zero host bits) and the broadcast (all-one host bits).
Network address from IP and mask
network = ip AND mask // bitwise AND
Wildcard mask = bitwise NOT(mask); broadcast = network OR wildcard.
Smallest prefix for N hosts (VLSM)
prefix = 32 − ceil( log2(N + 2) )
For 60 hosts: ceil(log2(62)) = 6, so prefix = /26 (64 addresses, 62 usable).
IPv6 total addresses
total = 2^(128 − prefix)
A /64 holds 18,446,744,073,709,551,616 addresses — more than the entire IPv4 internet, squared, twice over.
Common Subnetting Mistakes
- ✗Using the network or broadcast as a host address. Most operating systems will silently let you bind to the broadcast address; routers will not deliver the packets. Always start the host range at network+1.
- ✗Overlapping CIDR blocks. AWS VPC peering, Azure VNet peering, and BGP route filters all reject overlapping CIDRs. Design your global address plan with hierarchical allocations from day one.
- ✗Forgetting that a /24 is 254 hosts, not 256. The two reserved addresses catch new engineers — a /24 has 256 total addresses but 254 usable host addresses.
- ✗Putting public addresses behind NAT unnecessarily. Tunneling a public /29 through NAT defeats the point of having it; route the /29 directly through a routed firewall instead.
- ✗Confusing subnet mask and wildcard mask in ACLs. Cisco IOS ACLs use wildcard masks; firewalls usually use subnet masks. Mixing them up creates allow-rules that accidentally cover the entire internet.
Built for Real Network Engineering
Verified math, every time
The subnet, mask, wildcard, scope, and address-type classifications in this calculator follow the canonical specifications — RFC 791 (IPv4), RFC 950 (subnetting), RFC 1918 (private addresses), RFC 3021 (/31 point-to-point), RFC 4291 (IPv6 addressing), RFC 4193 (Unique Local Addresses), RFC 4632 (CIDR), RFC 6598 (CGNAT), and the IANA IPv4 / IPv6 Special-Purpose Address Registries. Every calculation is performed in your browser using bitwise integer arithmetic — no floating-point error, no rounding, no surprises.
The companion tools — password generator, password strength checker, unit converter, and scientific calculator — round out the SamCalculator developer toolkit so you can move between the engineering tasks of network design, security, capacity planning, and conversion without leaving the browser tab.
Frequently Asked Questions
What is subnetting?
What is CIDR notation?
How do subnet masks work?
What is the difference between IPv4 and IPv6?
How many usable hosts are in a subnet?
What is VLSM?
What is a private IP address?
Why is IPv6 important?
How do I calculate a subnet?
What is a wildcard mask?
Related Calculators
- Password GeneratorGenerate strong, secure passwords with custom length and complexity.
- Password Strength CheckerCheck password strength, entropy, crack time, and breach risk.
- Unit ConverterAll-in-one converter for 40+ measurement categories with natural-language input.
- Scientific CalculatorAdvanced trig, log, exponent, root, factorial, and memory functions.
- Word CounterCount words, check readability, and analyze your writing in real-time.
- Barcode Scanner ToolScan QR codes, UPC, EAN, ISBN, and 12+ barcode formats from camera or images.
- Random Number GeneratorRandom integers, decimals, lottery picks, dice rolls, coin flips, PINs, and bingo.