Subnet Calculator

Calculate IP subnet information online. Quickly determine network address, broadcast address, subnet mask, and available host addresses.

IP Address
CIDR Prefix

About Subnet Calculator

Subnet Calculator is a tool for calculating various properties of IP networks, including network address, broadcast address, subnet mask, usable host addresses, etc. This tool supports IPv4 subnet calculation using CIDR (Classless Inter-Domain Routing) notation.

Subnetting is a fundamental skill in network management. For network engineers, system administrators, and IT professionals, understanding subnetting is crucial for designing, configuring, and troubleshooting networks.


Core Concepts

  • IP Address: Unique identifier for devices on the internet. IPv4 addresses consist of 32-bit binary numbers, typically expressed in dotted decimal notation (like 192.168.1.1)
  • CIDR Notation: Classless Inter-Domain Routing, uses slash+number to represent subnet mask bits (like /24 means first 24 bits are network part, last 8 bits are host part)
  • Subnet Mask: Defines which bits of IP address are network part and which are host part. Bits set to 1 indicate network, bits set to 0 indicate host
  • Network Address: First address in subnet, host part all zeros, used to identify entire network
  • Broadcast Address: Last address in subnet, host part all ones, used to send data to all hosts in subnet
  • Usable Hosts: Total hosts minus network address and broadcast address, number of addresses that can be assigned to actual devices

IPv4 Address Classes (Classful Networking)

Before CIDR appeared, IP addresses were divided into five classes:

  • Class A: 1.0.0.0 - 126.255.255.255, default subnet mask 255.0.0.0 (/8), suitable for large networks, supports about 16.77 million hosts
  • Class B: 128.0.0.0 - 191.255.255.255, default subnet mask 255.255.0.0 (/16), suitable for medium networks, supports about 65,000 hosts
  • Class C: 192.0.0.0 - 223.255.255.255, default subnet mask 255.255.255.0 (/24), suitable for small networks, supports 254 hosts
  • Class D: 224.0.0.0 - 239.255.255.255, used for multicast
  • Class E: 240.0.0.0 - 255.255.255.255, reserved for future use

Common CIDR Prefixes

  • /8 (Class A): 16,777,214 hosts, suitable for large networks or ISP backbones
  • /16 (Class B): 65,534 hosts, suitable for medium enterprise networks
  • /24 (Class C): 254 hosts, most common subnet size, suitable for small offices or home networks
  • /30: 2 hosts, used for point-to-point links (like connections between routers)
  • /31: 2 hosts, point-to-point links, no broadcast address (RFC 3021)
  • /32: 1 host, single host address, commonly used in routing entries
  • /28: 14 hosts, suitable for small subnets
  • /29: 6 hosts, suitable for very small subnets

Purposes of Subnetting

  • Network Isolation: Divide large networks into multiple small networks to improve security and management efficiency
  • Traffic Control: Subnets communicate through routers, reducing unnecessary broadcast traffic
  • IP Address Conservation: Reasonable subnetting avoids IP address waste
  • Performance Optimization: Limit broadcast domains to improve network performance
  • Security Management: Implement security policies and access controls based on subnets
  • Fault Isolation: Narrow down fault scope, facilitating network troubleshooting

Calculation Principles

Subnet calculation is based on binary operations:

  1. Convert IP address to 32-bit binary
  2. Convert subnet mask to 32-bit binary
  3. Network Address: IP address AND subnet mask
  4. Broadcast Address: Network address + (2^host bits - 1)
  5. First Usable Host: Network address + 1
  6. Last Usable Host: Broadcast address - 1
  7. Total Hosts: 2^host bits
  8. Usable Hosts: Total hosts - 2 (subtract network address and broadcast address)

Practical Use Cases

  • Home Networks: Use 192.168.1.0/24 subnet, supporting 254 devices
  • Enterprise Networks: Use 10.0.0.0/8 private network, divided into multiple /24 subnets
  • Server Racks: Use /28 or /29 subnets, one small subnet per rack
  • VLAN Configuration: Each VLAN corresponds to one subnet for easier management
  • VPN Networks: Assign specific subnets for remote users
  • Cloud Services: VPC subnet division on cloud platforms like AWS, Azure

Frequently Asked Questions

Q: Why do /31 subnets have 2 usable hosts?
A: Traditionally, /30 is the smallest subnet (2 usable hosts) because network and broadcast addresses need to be reserved. However, RFC 3021 allows /31 subnets for point-to-point links, where both addresses can be assigned to hosts (since point-to-point links don't need broadcasts).

Q: What are private IP addresses?
A: Private IP addresses are reserved for internal networks and not routed on the public internet. They include: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. These addresses can be used for free but require NAT to access the internet.

Q: How to choose subnet size?
A: Choose based on required number of hosts, with some margin. For example: need 50 hosts, choose /26 (62 usable hosts); need 200 hosts, choose /24 (254 usable hosts).

Q: What's the relationship between subnet mask and CIDR prefix?
A: Subnet mask and CIDR prefix represent the same thing. /24 corresponds to subnet mask 255.255.255.0, /26 corresponds to 255.255.255.192. CIDR is a more concise notation.

Q: What is supernetting?
A: Supernetting is the reverse operation of subnetting, combining multiple consecutive small networks into one large network. For example: combining 192.168.0.0/24 and 192.168.1.0/24 into 192.168.0.0/23.


Subnetting Tips

  • Large to Small: First satisfy largest subnet requirements, then smaller ones to avoid waste
  • Reserve Margin: Consider future expansion, reserve enough IP address space
  • Documentation: Document subnetting plan in detail for easier maintenance and troubleshooting
  • Follow Standards: Follow RFC standards to ensure compatibility
  • Test and Verify: Use subnet calculator to verify configuration correctness before deployment