免费工具

CIDR / 子网计算器

从IPv4 CIDR块计算网络、广播、子网掩码、通配符、主机范围和可用主机数量。

What the CIDR / Subnet Calculator does

This tool takes a single IPv4 CIDR block written as a.b.c.d/nn — for example 192.168.1.0/24 or 10.0.0.0/8 — and instantly breaks it down into everything you need to describe that network: the network (base) address, the broadcast address, the subnet mask in dotted-decimal, the inverse or wildcard mask, the first and last usable host, the total number of addresses and the count of usable hosts. It is the tool you reach for whenever you have to reason about a range of IP addresses rather than a single one: planning a VLAN or a cloud VPC, writing a firewall rule, filling in the AllowedIPs line of a WireGuard peer, splitting an allocation into smaller subnets, or simply sanity-checking whether one host actually falls inside a given block. Instead of doing binary arithmetic in your head you type the block, and the answer appears the moment you finish typing.

How it works technically

Under the hood the calculator converts the address into a single unsigned 32-bit integer, because an IPv4 address is really just 32 bits grouped into four 8-bit octets. The prefix length /nn tells it how many leading bits are fixed as the network portion, leaving 32 − nn bits for hosts. From the prefix it builds the netmask (the top nn bits set to 1), then derives everything with bitwise operations: the network address is ip AND mask, the broadcast is network OR (NOT mask), and the wildcard mask is simply NOT mask. The total number of addresses in the block is 2^(32 − nn), which is why a /24 contains exactly 256 addresses (254 usable, once you subtract the network and broadcast addresses), a /25 holds 128, a /26 holds 64, and each extra bit of prefix halves the block. The two classic edge cases are handled honestly: a /31 has only two addresses and, per RFC 3021, both are usable for point-to-point links, while a /32 describes a single host with no network or broadcast to subtract.

Concrete examples and use cases

  • 10.0.0.0/8 — the largest private range, 16,777,216 addresses, host range 10.0.0.1 to 10.255.255.254.
  • 172.16.0.0/12 and 192.168.0.0/16 — the other two RFC 1918 private blocks people routinely mislabel; the calculator shows their real boundaries.
  • 203.0.113.64/26 — a 64-address slice with hosts .65 to .126 and broadcast .127, exactly the kind of allocation an ISP hands out.
  • 198.51.100.0/30 — four addresses, two usable, the traditional layout for a router-to-router link.

Practical tips and gotchas

A few things trip people up. The number after the slash counts bits, not addresses, and it moves in the opposite direction from size: a bigger prefix means a smaller network. Any host bit set inside the address is discarded when the network is computed, so 192.168.1.50/24 and 192.168.1.0/24 describe the same subnet — useful for checking which block an address belongs to. Remember that the network and broadcast addresses are not assignable to hosts in ordinary subnets, which is why usable count is two fewer than the total for /30 and larger. When you carve one block into several, keep the child prefixes longer than the parent and make sure they do not overlap; the calculator makes it easy to verify each slice before you commit it to a firewall or routing table.

Privacy: this calculator runs 100% locally in your browser. The CIDR block you enter is processed entirely by JavaScript on your own device — nothing is uploaded, nothing is logged, and no request leaves your machine, so it is perfectly safe to paste internal or production network plans. If you would rather look up a live, public address instead of computing a range on paper, try our IP check tool.

人们通过搜索找到此页面

此页面回答的真实搜索短语 — 链接的短语打开详细覆盖它们的页面。