IP Subnet Calculator – CIDR, Network & Host Range | Compu Tools
IP / Subnet Calculator
An IP subnet calculator takes an IPv4 address and subnet information and computes all the essential network parameters: network address, broadcast address, first and last usable host, host count, wildcard mask, IP class, and whether the address is private, public, loopback, or link-local. Subnetting is the practice of dividing a larger IP address block into smaller logical segments to control broadcast domains, enforce security boundaries, and allocate addresses efficiently. It is a daily task for network engineers, DevOps teams, cloud architects, and embedded systems developers who configure VPCs, routing tables, firewall ACLs, and microcontroller network interfaces.
This tool supports three input formats — CIDR notation (e.g. 192.168.1.0/24), IP + prefix length (e.g. 10.0.0.0 with /8), and IP + subnet mask (e.g. 172.16.0.0 with 255.240.0.0) — and keeps all three in sync automatically as you type. A color-coded 32-bit binary layout visualizes the network portion (blue) and host portion (orange) of every address field at a glance, making it ideal for teaching subnetting concepts or verifying calculations before deploying firewall rules or cloud VPC configurations.
How to Use This Subnet Calculator
- Select your input format — Choose the tab that matches how you have your network information. CIDR Notation is the most common form (e.g. 192.168.1.0/24 or 10.10.5.1/30). IP + Prefix and IP + Mask accept the same data in split form — useful when your configuration tool outputs IP and mask separately.
- Enter your network address or host address — You can enter a host address (e.g. 192.168.1.100/24) or the network address itself. The calculator applies a bitwise AND of the IP and mask to normalize to the network address automatically, so you do not need to pre-compute it.
- Read the subnet analysis — All key values appear in the result cards: network address, broadcast address, subnet mask, wildcard mask, first and last usable host, total and usable host counts, CIDR notation, IP class (A/B/C/D/E), and address scope (Private/Public/Loopback/Link-Local/Multicast). Click any card to copy the value to the clipboard.
- Inspect the binary layout — The 32-bit bit table shows all four address rows in binary. Network bits are highlighted blue, host bits set to 1 are orange, and host bits set to 0 are light gray. This is useful for verifying mask boundaries and understanding how subnetting works at the bit level.
- Copy all results — Use the Copy button in the Subnet Analysis header to export all computed values as a formatted plain-text block, ready to paste into documentation, a ticket, or a configuration file.
Subnet Math: How the Calculation Works
Every subnet calculation reduces to three binary operations on 32-bit integers. The following walkthrough uses 192.168.1.100/24 as the example — a host address in a standard Class C private network.
Step 1: Convert IP and Mask to Binary
A /24 prefix means the first 24 bits are the network portion and the last 8 bits are the host portion.
IP Address: 192.168.1.100
11000000 . 10101000 . 00000001 . 01100100
Subnet Mask: 255.255.255.0 (/24)
11111111 . 11111111 . 11111111 . 00000000
Wildcard Mask: 0.0.0.255 (bitwise NOT of mask)
00000000 . 00000000 . 00000000 . 11111111
Step 2: AND Operation for Network Address
The network address is the IP address with all host bits forced to 0 — achieved by bitwise AND with the subnet mask.
11000000.10101000.00000001.01100100 (192.168.1.100)
AND
11111111.11111111.11111111.00000000 (255.255.255.0)
= 11000000.10101000.00000001.00000000 = 192.168.1.0 (Network Address)
Step 3: OR with Wildcard for Broadcast
The broadcast address is the network address with all host bits forced to 1 — achieved by bitwise OR with the wildcard mask. The first usable host is network + 1, and the last usable host is broadcast - 1.
11000000.10101000.00000001.00000000 (192.168.1.0)
OR
00000000.00000000.00000000.11111111 (0.0.0.255)
= 11000000.10101000.00000001.11111111 = 192.168.1.255 (Broadcast)
First Host: 192.168.1.1 (network + 1)
Last Host: 192.168.1.254 (broadcast - 1)
Usable Hosts: 2^8 - 2 = 254
Subnetting a /24 Network: Worked Example
A common task is dividing a /24 block into smaller equal subnets. Borrowing 2 bits from the host portion creates 4 subnets of /26, each with 62 usable hosts. Here is how 192.168.10.0/24 divides into four /26 subnets:
Subnet 1: 192.168.10.0/26
Network: 192.168.10.0
Broadcast: 192.168.10.63
Hosts: 192.168.10.1 — 192.168.10.62 (62 usable)
Subnet 2: 192.168.10.64/26
Network: 192.168.10.64
Broadcast: 192.168.10.127
Hosts: 192.168.10.65 — 192.168.10.126 (62 usable)
Subnet 3: 192.168.10.128/26
Network: 192.168.10.128
Broadcast: 192.168.10.191
Hosts: 192.168.10.129 — 192.168.10.190 (62 usable)
Subnet 4: 192.168.10.192/26
Network: 192.168.10.192
Broadcast: 192.168.10.255
Hosts: 192.168.10.193 — 192.168.10.254 (62 usable)
Block size = 2^(32-26) = 64 | Each subnet starts at a multiple of 64.
Variable Length Subnet Masking (VLSM)
VLSM allows a network administrator to use different subnet mask lengths within the same address block, sizing each subnet to match its actual host count rather than forcing all subnets to the same size. This is in contrast to fixed-length subnetting (FLSM) where every subnet has identical size. VLSM requires classless routing protocols (OSPF, EIGRP, IS-IS, or BGP) that advertise the prefix length with each route. Starting from the largest subnet requirement and working down to the smallest is the standard VLSM design approach — this prevents gaps and overlaps in the address space.
VLSM Design Example — 10.0.0.0/24 divided for four departments:
Production servers (100 hosts): 10.0.0.0/25 hosts 10.0.0.1 to 10.0.0.126
Office LAN (50 hosts): 10.0.0.128/26 hosts 10.0.0.129 to 10.0.0.190
DMZ segment (12 hosts): 10.0.0.192/28 hosts 10.0.0.193 to 10.0.0.206
Management VLAN (6 hosts): 10.0.0.208/29 hosts 10.0.0.209 to 10.0.0.214
P2P router link (2 hosts): 10.0.0.216/30 hosts 10.0.0.217 to 10.0.0.218
Remaining space: 10.0.0.220/30 through 10.0.0.252/30 (future use)
Total allocated: 128 + 64 + 16 + 8 + 4 = 220 addresses | Wasted: 256 - 220 = 36
Compare to FLSM /25 (equal subnets): 4 * 128 = 512 addresses needed — impossible from /24.
Common Subnet Reference Table
| CIDR | Subnet Mask | Usable Hosts | Block Size | Common Use |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 | 16,777,216 | Large ISP / private 10.0.0.0/8 (RFC 1918) |
| /12 | 255.240.0.0 | 1,048,574 | 1,048,576 | Private 172.16.0.0/12 (RFC 1918) / Docker |
| /16 | 255.255.0.0 | 65,534 | 65,536 | Private 192.168.0.0/16 / large LAN / cloud VPC |
| /20 | 255.255.240.0 | 4,094 | 4,096 | Mid-size enterprise / cloud VPC subnet |
| /22 | 255.255.252.0 | 1,022 | 1,024 | Large office LAN / AWS /22 VPC subnet |
| /24 | 255.255.255.0 | 254 | 256 | Standard home and office LAN (most common) |
| /25 | 255.255.255.128 | 126 | 128 | Split /24 in two equal halves |
| /26 | 255.255.255.192 | 62 | 64 | Small office segment / cloud tier subnet |
| /27 | 255.255.255.224 | 30 | 32 | Small VLAN, 30-host segment |
| /28 | 255.255.255.240 | 14 | 16 | DMZ, management VLAN, bastion host tier |
| /29 | 255.255.255.248 | 6 | 8 | Very small segment (database, caching tier) |
| /30 | 255.255.255.252 | 2 | 4 | Point-to-point WAN / router interconnect |
| /31 | 255.255.255.254 | 2 | 2 | P2P link — no broadcast (RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 | Host route / loopback / BGP /32 peering |
Cloud VPC Subnetting (AWS / Azure / GCP)
Cloud providers structure network isolation through VPCs (Virtual Private Clouds) and subnets. Unlike traditional on-premises networks, cloud subnets span a single Availability Zone (AZ) in AWS and Azure, or a region in GCP. Each cloud provider reserves a few addresses per subnet for internal routing, DNS, and gateway functions — in AWS this is 5 addresses per subnet (network, VPC router at .1, DNS at .2, future use at .3, and broadcast), leaving the remainder usable. Subnet selection affects latency (cross-AZ traffic costs more), availability (multi-AZ deployment requires multiple subnets), and security group / network ACL scope.
Typical cloud VPC layout — 10.0.0.0/16 VPC:
10.0.0.0/28 — Management / bastion hosts (AZ-a) — 11 usable (AWS reserves 5)
10.0.1.0/28 — Management / bastion hosts (AZ-b) — 11 usable
10.0.16.0/24 — Application tier (AZ-a) — 251 usable
10.0.17.0/24 — Application tier (AZ-b) — 251 usable
10.0.32.0/26 — Database / RDS tier (AZ-a) — 59 usable
10.0.33.0/26 — Database / RDS tier (AZ-b) — 59 usable
10.0.48.0/24 — Cache / ElastiCache tier — 251 usable
10.0.64.0/20 — Lambda / container compute pool — 4091 usable
10.0.128.0/17 — Reserved for future expansion — 32,763 available addresses
AWS VPC subnets must be between /16 and /28. Azure Virtual Networks support /2 to /29. GCP VPCs use /8 to /29 and are global (not AZ-scoped). Always allocate subnets larger than current need — resizing a cloud subnet typically requires creating a new one and migrating resources.
Private IP Address Ranges (RFC 1918)
RFC 1918 (published 1996) defines three blocks of IPv4 address space reserved for private use — they are not routed on the public internet, and ISPs block inbound traffic destined for these ranges. Any device using a private address must use NAT (Network Address Translation) to reach public hosts. These ranges are universally deployed: home routers, enterprise intranets, data center fabrics, Kubernetes pod networks, Docker bridge networks, and cloud VPC address spaces all draw from them.
10.0.0.0/8 (Class A private — 16,777,216 addresses)
Range: 10.0.0.1 to 10.255.255.254 | Mask: 255.0.0.0
Used by: ISP internal routing, large enterprise networks, Kubernetes pod CIDRs
(e.g. GKE default pod CIDR 10.4.0.0/14, EKS node range 10.0.0.0/8)
172.16.0.0/12 (Class B range — 1,048,576 addresses)
Range: 172.16.0.1 to 172.31.255.254 | Mask: 255.240.0.0
Used by: Docker default bridge network (172.17.0.0/16), corporate VPNs
192.168.0.0/16 (Class C range — 65,536 addresses)
Range: 192.168.0.1 to 192.168.255.254 | Mask: 255.255.0.0
Used by: Home routers (192.168.0.x and 192.168.1.x), small office networks
169.254.0.0/16 (Link-local — RFC 3927, APIPA)
Auto-assigned when DHCP fails. Not routed beyond local link.
Windows: APIPA assigns 169.254.x.x | Linux: avahi/zeroconf assigns in same range
127.0.0.0/8 (Loopback — RFC 5735)
127.0.0.1 is the standard localhost address. Traffic never leaves the host network stack.
Subnet Design Best Practices
- Size for growth, not current headcount. A /26 gives 62 hosts today but a /24 gives 254 — adding hosts later is far cheaper than renumbering a full subnet. Double your expected host count, then pick the next larger power-of-2 block.
- Align subnets to their block size. A /26 block (size 64) must start at an address that is a multiple of 64: .0, .64, .128, .192. Misaligned subnets cause routing protocol issues and confuse firewall rules.
- Separate tiers into distinct subnets. Place web servers, app servers, databases, and management hosts in separate subnets so that firewall rules, security groups, and network ACLs can enforce least-privilege access between tiers.
- Reserve a /30 or /31 for every router-to-router link. Using a /24 for a point-to-point link wastes 252 addresses. /31 (RFC 3021) is preferred on modern networks for zero waste.
- Document your IP schema before deploying. Overlapping subnets across sites or VPN tunnels cause routing black holes. Keep an IPAM (IP Address Management) spreadsheet or tool, even for small networks.
- Avoid using 10.0.0.0/8 in its entirety for a single VPC or site. Reserve sub-ranges for peered networks, VPNs, and future expansion. Using the full /8 for one VPC makes peering with other VPCs or on-premises networks impossible without NAT.
- Use VLSM when subnets have different host density needs. Fixed-length subnetting wastes addresses in sparsely populated segments. VLSM lets you assign a /28 to a 10-host management VLAN and a /22 to a 1000-host production segment from the same parent block.
- Verify your subnet math before pushing to production. A one-bit error in a subnet mask can merge two security zones or make an entire segment unreachable. Use this calculator — or the CLI (ipcalc, sipcalc) — to cross-check every subnet before committing it to a routing table or cloud console.
Frequently Asked Questions
How many usable hosts are in a /24?
A /24 subnet has 2^(32-24) = 2^8 = 256 total addresses. The network address (e.g. 192.168.1.0) and broadcast address (192.168.1.255) are reserved, leaving 254 usable host addresses (192.168.1.1 through 192.168.1.254). The subnet mask is 255.255.255.0 and the wildcard mask is 0.0.0.255. The general formula is: usable hosts = 2^(32 - prefix) - 2, except for /31 (2 usable, no broadcast) and /32 (1 address, host route only).
What is the difference between a subnet mask and a wildcard mask?
A subnet mask has 1s in the network bit positions and 0s in the host bit positions. A wildcard mask is the bitwise complement (inverse) of the subnet mask — 0s where the subnet mask has 1s, and 1s where it has 0s. For a /24 subnet mask of 255.255.255.0, the wildcard is 0.0.0.255. In subnet masks, a 1-bit means 'this bit is part of the network ID.' In wildcard masks, a 0-bit means 'this bit must match' and a 1-bit means 'ignore this bit' — the opposite semantics. Wildcard masks are used in Cisco ACLs and OSPF area statements.
Why is /31 special? (RFC 3021)
Traditionally, a subnet requires at minimum a network address and a broadcast address, consuming 2 of its 4 addresses in a /30 and leaving only 2 usable hosts. RFC 3021 (published 2000) defines an exception for /31 subnets: since point-to-point links connect exactly two routers and need no broadcast, both addresses in a /31 block are treated as host addresses. A /31 subnet wastes 0 addresses compared to the 2 wasted by a /30 for the same use case. All modern router operating systems (IOS, JunOS, NX-OS) support /31 on point-to-point interfaces.
What happens when DHCP fails?
When a host cannot reach a DHCP server after repeated discovery attempts, most operating systems assign a link-local address in the 169.254.0.0/16 range (RFC 3927). On Windows this is called APIPA (Automatic Private IP Addressing) and produces addresses like 169.254.x.y. On Linux, the avahi-autoipd or NetworkManager service performs the same function. Link-local addresses are valid only on the directly connected network segment and are not routed — hosts with APIPA addresses cannot reach the internet or cross-subnet resources, but can communicate with other APIPA hosts on the same LAN.
How do I choose between /24 and /26 for my network?
A /24 provides 254 usable host addresses and a /26 provides 62. Choose based on your expected peak host count with room to grow — a rule of thumb is to provision 2-3x your current count. A /26 is appropriate for segments with under about 40 permanent hosts (workstations, servers, IoT devices). A /24 fits a standard office floor or building. Also consider broadcast domain size: larger subnets generate more broadcast traffic (ARP, DHCP), which can degrade performance on flat networks. Segmenting a large office into multiple /26s can improve both security and performance.
What is the 'host' IP vs. network address?
The network address is the first address in a subnet, formed by setting all host bits to 0. It identifies the subnet itself and cannot be assigned to any host. For 192.168.1.0/24, the network address is 192.168.1.0. A host IP is any address within the subnet with at least one host bit set — for example, 192.168.1.100. You can enter any host IP into this calculator with its subnet mask, and it will automatically derive the correct network address via bitwise AND. The host IP field in the result shows the original IP you entered, before normalization.
Why can't I use .0 and .255 as host addresses?
In a standard /24 subnet, 192.168.1.0 is the network identifier (all host bits = 0) and 192.168.1.255 is the broadcast address (all host bits = 1). Assigning the broadcast address to a host would cause every device on the subnet to receive packets destined for that host, since the IP stack treats .255 as a directed broadcast. Assigning the network address causes routing protocol confusion because routers use it to identify the subnet in routing table entries. These restrictions hold for any subnet prefix — the first and last addresses are always reserved, not just .0 and .255 specifically.
How do I split a /24 into smaller subnets?
To split a /24 into smaller subnets, borrow bits from the host portion. Each bit borrowed doubles the number of subnets and halves the size: 1 bit gives 2x/25 (126 hosts each), 2 bits gives 4x/26 (62 hosts), 3 bits gives 8x/27 (30 hosts), 4 bits gives 16x/28 (14 hosts), 5 bits gives 32x/29 (6 hosts), 6 bits gives 64x/30 (2 hosts, P2P). The starting address of each subnet is a multiple of the block size (2^host_bits). For a /26 the block size is 64, so subnets start at .0, .64, .128, .192. Enter each starting address with the new prefix into this calculator to verify network/broadcast/host ranges.
What is the difference between IPv4 CIDR and IPv6 CIDR?
Both IPv4 and IPv6 use CIDR slash-notation to express prefix length, but the address space and typical prefix sizes differ dramatically. IPv4 addresses are 32 bits, so prefixes range from /0 (entire internet) to /32 (single host). IPv6 addresses are 128 bits — a /64 prefix (the standard LAN assignment) still leaves 2^64 host addresses (18 quintillion). In IPv6, a /128 is a single host route, /64 is the standard subnet, /48 is typically assigned to a customer site, and /32 is a typical ISP allocation. IPv6 eliminates broadcast addresses entirely — link-local multicast (ff02::/16) replaces directed broadcast and ARP.
Related Tools
- Coordinate Frame Converter — Convert vectors and attitudes between NED, ENU, and Body coordinate frames. Visualize frame axes, apply roll/pitch/yaw DCM rotation, and understand frame relationships used in drone, robot, and navigation systems.
- Bit Mask Calculator — Build bitmasks visually on an 8/16/32/64-bit grid, generate C #define macros, and apply SET, CLEAR, TOGGLE, or READ operations to register values with bit layout visualization and C code output.
- UART Calculator — Calculate UART frame timing (bit period, frame duration, throughput) and baud rate error (UBRR register value, actual vs target baud) for 22 standard baud rates across 24 MCU clock presets. Supports 8×/16× oversampling modes. Runs in your browser.
- SPI Calculator — Calculate SPI clock frequency from MCU clock and divider, transfer time, throughput, and bit/word periods. Browse all 8 clock dividers in a single table with speed class indicators. Supports SPI Mode 0–3 (CPOL/CPHA), MSB/LSB first, and word sizes of 8/16/32 bits. Runs in your browser.
- PWM & Servo Calculator — Calculate PWM period, duty cycle, high/low time, servo angle-to-pulse-width mapping, and ESC throttle position. Supports standard (1000–2000 µs) and wide-range (500–2500 µs) servos. Runs in your browser.