TToolbox
/24

Subnet Calculator

Network, broadcast and host range from CIDR

About this tool

Classless Inter-Domain Routing (CIDR, RFC 4632) and Subnet Masks govern IP addressing, network segment isolation, cloud VPC routing, and firewall switch rules across modern Internet infrastructures. System engineers must determine network boundaries, broadcast addresses, usable host ranges, and wildcard masks without calculation slips. This tool calculates IPv4 subnet metrics instantly with interactive bitwise mask visualizers.

How to Use This Tool (Step-by-Step)

1

Enter IP and CIDR Prefix

Enter any base IPv4 address (e.g., `192.168.1.1`) and select your CIDR prefix length (e.g., `/24`) or dotted-decimal mask.

2

Inspect Network Boundaries

The calculator computes Network ID, Broadcast address, usable host IP range, total addresses, and usable host quotas in parallel.

3

Review Bitwise Mask & Copy

Inspect color-coded 32-bit binary network vs host bit representations and copy parameters directly into cloud VPC configs.

Full /0 to /32 CIDR Range Support

Supports the entire CIDR spectrum from massive `/8` telecom blocks down to point-to-point `/30` links and `/32` host routes.

Visual 32-Bit Binary Map

Renders IPv4 bytes into a visual 32-bit binary stream, clearly delineating network prefix bits (1s) from host bits (0s).

100% Client-Side Air-Gapped

Subnet math runs entirely inside your browser's local sandbox memory. Internal enterprise VPC topologies are never transmitted.

Cloud VPC Planning & Subnet Best Practices

  • •Cloud VPC 5 Reserved IPs: AWS and Aliyun reserve the first 4 and last 1 IPs in every subnet for gateway and DNS. In a `/28` block, only 11 IPs are assignable (16 - 5).
  • •Use `/30` or `/31` for point-to-point router links: A `/30` subnet allocates exactly 2 usable host IPs, conserving IPv4 addresses on WAN circuits.
  • •Mental formula for host capacity: Usable hosts equal `2^(32 - prefix) - 2`. For `/27`: `32 - 27 = 5`, `2^5 - 2 = 30` available host addresses.

Code & Transformation Examples

Standard CIDR Network Calculation Benchmark

Input CIDR Address
192.168.1.100 / 24 (掩码: 255.255.255.0)
Calculated Subnet Attributes
• 网络地址 (Network)   : 192.168.1.0
• 广播地址 (Broadcast) : 192.168.1.255
• 可用主机范围         : 192.168.1.1 ~ 192.168.1.254
• 可用主机总数         : 254 台 (2^(32-24) - 2)
• 反掩码 (Wildcard)    : 0.0.0.255

* The first address identifies the network itself and the last is reserved for broadcast; neither can be assigned to a host.

JavaScript Bitwise Subnet Calculation Implementation

Bitwise AND Implementation
function ipToLong(ip) {
  return ip.split('.').reduce((acc, oct) => (acc << 8) + parseInt(oct, 10), 0) >>> 0;
}
function longToIp(long) {
  return [(long >>> 24) & 255, (long >>> 16) & 255, (long >>> 8) & 255, long & 255].join('.');
}
Calculate Network Address
function getNetwork(ip, mask) {
  return longToIp((ipToLong(ip) & ipToLong(mask)) >>> 0);
}
console.log(getNetwork("192.168.1.100", "255.255.255.0")); // "192.168.1.0"

* Unsigned right shift `>>> 0` ensures JavaScript bitwise logic treats numbers as 32-bit unsigned integers.

Frequently Asked Questions

Q: What is a Wildcard Mask used for in networking?

A: A wildcard mask inverts the subnet mask (`255.255.255.255 - Mask`). It is mandatory when configuring Cisco ACLs and OSPF routing areas.

Q: What are the standard private RFC 1918 IP blocks?

A: RFC 1918 defines: Class A `10.0.0.0/8` (enterprise corporate), Class B `172.16.0.0/12` (datacenter/Docker), and Class C `192.168.0.0/16` (home routers).

Q: Why does a `/32` prefix denote a single host route?

A: Because IPv4 has 32 bits total. A `/32` mask (`255.255.255.255`) locks all 32 bits, specifying an exact single host address without any subnet range.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/