Tech

Subnet Calculator - CIDR & IP Address Calculator

Calculate subnet mask, network address, broadcast address, and usable host range from any IP address and CIDR notation.

Common subnet sizes

/24 = 256 addresses/25 = 128 addresses/26 = 64 addresses/27 = 32 addresses/28 = 16 addresses/29 = 8 addresses/30 = 4 addresses/32 = 1 address
Usable hosts
254
Network address
192.168.1.0
Broadcast address
192.168.1.255
First usable IP
192.168.1.1
Last usable IP
192.168.1.254
Total addresses
256
Usable hosts
254

Subnet details

Subnet mask255.255.255.0
Wildcard mask0.0.0.255
CIDR notation192.168.1.0/24
IP classClass C
IP typePrivate

Binary representation

IP:11000000.10101000.00000001.01100100
Mask:11111111.11111111.11111111.00000000
Network:11000000.10101000.00000001.00000000

Subnet cheat sheet

CIDRHostsMask
/24254255.255.255.0
/25126255.255.255.128
/2662255.255.255.192
/2730255.255.255.224
/2814255.255.255.240
/296255.255.255.248
/302255.255.255.252

Network and broadcast addresses are reserved and cannot be assigned to hosts. For /31 and /32 subnets, all addresses are usable per RFC 3021.

What is a subnet calculator?

A subnet calculator helps you divide IP networks into smaller, more manageable segments called subnets. It takes an IP address and CIDR prefix (like /24) and calculates essential network information including the network address, broadcast address, subnet mask, and the range of usable host IP addresses.

Whether you're setting up a home network, configuring cloud infrastructure, or studying for a networking certification, understanding subnetting is fundamental to IP networking.

How subnet calculation works

Subnetting is based on binary math applied to 32-bit IPv4 addresses. The CIDR prefix indicates how many bits represent the network portion, with remaining bits available for host addresses.

The binary foundation

An IPv4 address consists of 32 bits, typically written as four octets in decimal form:

192.168.1.100 = 11000000.10101000.00000001.01100100

The subnet mask determines which bits identify the network and which identify the host. A /24 network uses 24 bits for the network portion:

Subnet mask /24 = 11111111.11111111.11111111.00000000
                = 255.255.255.0

Key calculations

Network address: Apply a bitwise AND between the IP and subnet mask:

Network=IP AddressSubnet Mask\text{Network} = \text{IP Address} \land \text{Subnet Mask}

Broadcast address: The network address with all host bits set to 1.

Usable hosts: Total addresses minus network and broadcast:

Usable Hosts=2(32prefix)2\text{Usable Hosts} = 2^{(32 - \text{prefix})} - 2

Example calculation

For IP address 192.168.1.100/24:

Subnet mask=255.255.255.0Network address=192.168.1.0Broadcast address=192.168.1.255First usable=192.168.1.1Last usable=192.168.1.254Total addresses=256Usable hosts=254\begin{aligned} \text{Subnet mask} &= 255.255.255.0 \\ \text{Network address} &= 192.168.1.0 \\ \text{Broadcast address} &= 192.168.1.255 \\ \text{First usable} &= 192.168.1.1 \\ \text{Last usable} &= 192.168.1.254 \\ \text{Total addresses} &= 256 \\ \text{Usable hosts} &= 254 \end{aligned}

Understanding CIDR notation

Classless Inter-Domain Routing (CIDR) replaced the older classful network addressing in 1993. The IETF introduced CIDR to slow IPv4 address exhaustion and reduce routing table sizes.

CIDR format

CIDR notation combines an IP address with a prefix length:

192.168.1.0/24

The number after the slash indicates how many bits form the network prefix. More bits for the network means fewer for hosts.

Common CIDR blocks

CIDRSubnet maskTotal addressesUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/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
/32255.255.255.25511

Why CIDR replaced classful addressing

The original IP addressing scheme divided networks into classes:

  • Class A: First bit 0, /8 networks (16 million hosts each)
  • Class B: First bits 10, /16 networks (65,536 hosts each)
  • Class C: First bits 110, /24 networks (256 hosts each)

This rigid system wasted addresses. An organization needing 300 hosts would receive a Class B with 65,536 addresses—wasting 65,000+ IPs. CIDR allows variable-length subnet masks, enabling precise allocation.

Subnet mask vs wildcard mask

Two types of masks appear in networking, serving opposite purposes.

Subnet mask

The subnet mask identifies the network portion through 1 bits:

/24 = 255.255.255.0 = 11111111.11111111.11111111.00000000

Network devices use subnet masks to determine whether destination IPs are local or remote.

Wildcard mask

The wildcard mask is the inverse—0 bits represent matching and 1 bits represent "don't care":

Wildcard for /24 = 0.0.0.255 = 00000000.00000000.00000000.11111111

Wildcard masks appear in Access Control Lists (ACLs) and routing protocols like OSPF. To convert:

Wildcard Mask=255.255.255.255Subnet Mask\text{Wildcard Mask} = 255.255.255.255 - \text{Subnet Mask}

Private vs public IP addresses

Understanding IP classification helps with network design and troubleshooting.

Private IP ranges (RFC 1918)

These addresses are reserved for internal networks and cannot be routed on the public internet:

RangeCIDRPurpose
10.0.0.0 – 10.255.255.25510.0.0.0/8Large networks
172.16.0.0 – 172.31.255.255172.16.0.0/12Medium networks
192.168.0.0 – 192.168.255.255192.168.0.0/16Home/small office

Other reserved ranges

RangePurpose
127.0.0.0/8Loopback (localhost)
169.254.0.0/16Link-local (APIPA)
224.0.0.0/4Multicast
240.0.0.0/4Reserved/experimental

NAT and private addresses

Network Address Translation (NAT) allows multiple devices with private IPs to share a single public IP. Your router performs NAT, translating between your internal 192.168.x.x addresses and your ISP-assigned public IP.

Subnetting for different scenarios

Home networks

Most home routers use 192.168.1.0/24 or 192.168.0.0/24, providing 254 usable addresses—plenty for typical households. Some routers use 10.0.0.0/24 for variety.

Small business

A /23 network (512 addresses) or multiple /24 subnets separated by department provides room for growth while maintaining organizational boundaries.

Cloud infrastructure

Cloud providers like AWS, Azure, and GCP reserve additional addresses per subnet:

ProviderReserved per subnet
AWS5 addresses
Azure5 addresses
GCP4 addresses

For a /24 in AWS, usable hosts = 256 - 5 = 251 (not 254).

Point-to-point links

/30 subnets provide exactly 2 usable addresses—perfect for router-to-router connections. /31 subnets (RFC 3021) are also valid for point-to-point links, providing 2 addresses with no waste.

Variable Length Subnet Masking (VLSM)

VLSM allows creating subnets of different sizes from a single network, optimizing address utilization.

VLSM example

Starting with 192.168.1.0/24, create subnets for:

  • Department A: 100 hosts needed
  • Department B: 50 hosts needed
  • Department C: 25 hosts needed
  • Point-to-point links: 2 hosts each (3 links)

Solution:

  1. Dept A: 192.168.1.0/25 (126 hosts)
  2. Dept B: 192.168.1.128/26 (62 hosts)
  3. Dept C: 192.168.1.192/27 (30 hosts)
  4. Links: 192.168.1.224/30, 192.168.1.228/30, 192.168.1.232/30 (2 hosts each)

Always allocate largest subnets first to avoid fragmentation.

Supernetting and route aggregation

Supernetting combines multiple smaller networks into a larger block for routing efficiency.

Example

Four /24 networks can combine into one /22:

  • 192.168.0.0/24
  • 192.168.1.0/24
  • 192.168.2.0/24
  • 192.168.3.0/24

Becomes: 192.168.0.0/22

This reduces routing table entries from 4 to 1, improving router performance.

Subnet planning best practices

Reserve addresses for infrastructure

Allocate specific IPs for:

  • Default gateway (often .1 or .254)
  • DNS servers
  • DHCP servers
  • Management interfaces

Plan for growth

Reserve 20-30% more addresses than current requirements. Reconfiguring subnets later is disruptive.

Document everything

Maintain an IP address management (IPAM) spreadsheet or tool documenting:

  • Subnet assignments
  • Reserved ranges
  • Device allocations
  • VLAN mappings

Use consistent conventions

Establish patterns like:

  • Gateways always end in .1
  • Servers in .10-.50 range
  • Printers in .200-.220 range
  • DHCP pool in remaining space

Troubleshooting subnet issues

Common problems

Cannot reach local devices: Check that devices are on the same subnet. Different subnets require routing.

Duplicate IP addresses: Ensure DHCP pools don't overlap with static assignments.

Subnet mask mismatch: All devices on a subnet must use the same mask. A device with /23 on a /24 network will have connectivity issues.

Wrong default gateway: The gateway must be on the same subnet as the host.

Diagnostic commands

# Windows
ipconfig /all
route print

# Linux/Mac
ip addr show
ip route show

IPv6 considerations

While this calculator focuses on IPv4, IPv6 uses similar concepts with 128-bit addresses:

  • /64 is the standard subnet size (recommended minimum)
  • No broadcast addresses in IPv6
  • /48 typically assigned to organizations
  • /128 for individual host addresses

IPv6 addresses are written in hexadecimal: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Frequently asked questions

Why subtract 2 from total addresses for usable hosts?

The network address (all host bits 0) identifies the network itself. The broadcast address (all host bits 1) reaches all hosts on the subnet. Neither can be assigned to individual hosts.

What's the smallest usable subnet?

A /30 subnet provides 2 usable addresses, ideal for point-to-point links. /31 and /32 subnets are special cases for point-to-point and single hosts.

Can I change my subnet mask without changing IPs?

Expanding the mask (e.g., /24 to /23) generally works if the adjacent block is available. Shrinking requires ensuring no devices fall outside the new range.

How do I know if an IP is in a subnet?

Apply the subnet mask to both the IP in question and the network address. If the results match, the IP belongs to that subnet.

What's the difference between /24 and 255.255.255.0?

They're identical—just different notations. /24 is CIDR notation (24 network bits). 255.255.255.0 is dotted decimal notation for the same mask.

How many subnets can I create?

From a /16 network, you could create 256 /24 subnets, 512 /25 subnets, or any combination totaling the original address space.