IP Subnet Calculator

Calculate IPv4 and IPv6 subnet information instantly with advanced network analysis tools.

IPv4

Tool5 modes · switch anytime

Calculate network, broadcast, host range, mask, wildcard, class, scope, and binary breakdown for any IPv4 address.

0–32
auto-derived from prefix

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

1

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.

2

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.

3

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.

4

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.

5

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?
Subnetting is the practice of dividing a single IP network into smaller, logically separate sub-networks (subnets). Each subnet has its own network address, broadcast address, and a defined range of usable host addresses. Subnetting reduces broadcast traffic, isolates failure and security domains, and lets a finite IPv4 address pool be allocated efficiently across departments, VLANs, and cloud subnets.
What is CIDR notation?
CIDR (Classless Inter-Domain Routing) notation expresses an IP network as the network address followed by a slash and the number of leading 1-bits in the subnet mask — for example, 192.168.1.0/24 means the first 24 bits identify the network and the remaining 8 bits identify the host. CIDR (RFC 1519, 1993) replaced the older A/B/C class system so networks can be sized at any bit boundary.
How do subnet masks work?
A subnet mask is a 32-bit number that splits an IP address into its network portion (1-bits) and host portion (0-bits). For 255.255.255.0 (/24), the first 24 bits are the network and the last 8 bits address up to 256 hosts. A device determines whether a destination is on the same subnet by ANDing both addresses with the mask and comparing the results.
What is the difference between IPv4 and IPv6?
IPv4 uses 32-bit addresses (~4.3 billion total) written as four dotted-decimal octets like 192.168.1.1. IPv6 uses 128-bit addresses (3.4 × 10^38 total) written as eight hex groups like 2001:db8::1. IPv6 adds built-in features that bolted onto IPv4 later: stateless autoconfiguration, mandatory link-local addresses, and elimination of NAT for most use cases.
How many usable hosts are in a subnet?
For an IPv4 subnet with prefix /n, the usable host count is 2^(32 − n) − 2 — one address is reserved for the network identifier and one for the broadcast. A /24 has 254 usable hosts, /27 has 30, /30 has 2. The /31 prefix is a special case (RFC 3021): both addresses are usable, making it the standard point-to-point link size.
What is VLSM?
VLSM (Variable Length Subnet Masking) uses different subnet mask lengths inside the same parent network so each sub-allocation is sized to its actual host requirement instead of being forced to a single uniform size. VLSM is supported by every modern routing protocol (OSPF, IS-IS, BGP, EIGRP) and is the foundation of efficient IPv4 address planning.
What is a private IP address?
A private IP address is one of the IPv4 ranges that RFC 1918 reserved for internal use — 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 — plus the carrier-grade NAT range 100.64.0.0/10 from RFC 6598. Private addresses are not routed on the public internet and must be translated by NAT before egress. The IPv6 equivalent is the Unique Local Address (ULA) range fc00::/7.
Why is IPv6 important?
IPv4's 4.3 billion addresses were exhausted at the regional internet registry level between 2011 and 2017, forcing carriers to deploy carrier-grade NAT. IPv6 solves this with 128-bit addresses — enough to assign a /64 to every grain of sand on Earth — and is essential for the growth of mobile networks, IoT devices, cloud workloads, and 5G/6G infrastructure.
How do I calculate a subnet?
Write the IP address and subnet mask in binary, AND them bit-by-bit (the result is the network address), set every host bit to 1 for the broadcast, and the first usable host is network+1, the last is broadcast−1. For 192.168.10.45/26: mask 255.255.255.192, network 192.168.10.0, broadcast 192.168.10.63, usable range 192.168.10.1 to 192.168.10.62. The IP Subnet Calculator does all of this instantly in your browser.
What is a wildcard mask?
A wildcard mask is the bitwise inverse of a subnet mask — every 1 becomes a 0 and every 0 becomes a 1. For /24 the subnet mask is 255.255.255.0 and the wildcard mask is 0.0.0.255. Wildcard masks are required by Cisco IOS access-control lists, OSPF network statements, and EIGRP routing configuration, and are also useful in firewall rules and BGP route-map filters.