子网计算器(IPv4 CDR)
IPv4子网分解完整:网络、广播、掩码、通配符、主机范围、计数。
输入结果时更新 。
关于此计算器
This subnet calculator turns an IPv4 address and a CIDR prefix into the full structure of a subnet. An IPv4 address is 32 bits, usually written as four dot-separated octets like 192.168.1.10, and a CIDR prefix such as /24 splits those 32 bits into a network part (the leading bits, fixed for every host in the subnet) and a host part (the remaining bits, unique to each device). This calculator takes an address and a prefix length and derives the network address, broadcast address, subnet mask, wildcard mask and the range of usable host addresses, along with the IP class and total address count.
The size of a subnet is set by the prefix: a /n block holds 2^(32−n) addresses, of which two are reserved — the network address (all host bits 0, naming the subnet) and the broadcast address (all host bits 1, reaching every host). So a /24 has 2^8 = 256 addresses and 254 usable hosts, a /25 has 128 addresses and 126 usable hosts, and each extra prefix bit halves the block. As a worked example, 192.168.1.10/24 gives a network of 192.168.1.0, a broadcast of 192.168.1.255, a 255.255.255.0 mask, a 0.0.0.255 wildcard mask, and a usable host range of 192.168.1.1 to 192.168.1.254.
Subnetting is how networks are carved into manageable, secure segments — separating departments, sizing VLANs, planning address allocation and writing firewall and routing rules. The wildcard mask (the bitwise inverse of the subnet mask) is what Cisco access-control lists and OSPF use to match ranges of addresses. The /31 and /32 prefixes are special cases: /31 is used for point-to-point links with two usable addresses and no broadcast, and /32 describes a single host.
经常问到的问题
子网里有多少接待员?
A /n subnet has 2^(32−n) addresses, minus two reserved for the network and broadcast. A /24 has 256 addresses and 254 usable hosts.
什么是通配符面具?
A wildcard mask is the bitwise inverse of the subnet mask (255.255.255.0 → 0.0.0.255). Access-control lists and OSPF use it to match ranges of addresses.
网络和广播地址有什么区别?
网络地址( 所有主机位数 0) 命名子网; 广播地址( 所有主机位数 1) 覆盖到每个主机 。 设备也不能被指定 。
What does the CIDR prefix (/24, /16) mean?
形成地址网络部分的就是领先位数。更大的前缀意味着更多的网络位数和更少的主机位数,因此一个较小的子网: 24 给254个主机, 25 给126, 每一个额外的位数会把区块的面积减半。
我如何将网络分成小的子网?
通过增加前缀来借款主机比特 。 将 24 分解为 2 / 25 表示 2 个区块 126 个主机; 26 表示 26 表示 4 个区块 62 。 每个添加的前缀比特会翻倍子网数, 并缩小其大小 。
IP地址类是什么?
古老的典型计划用第一个奥克特语分割地址:单人A类(1-126 ) 、 B类(128-191 ) 和 C类(192-223 ), 加上多播和E类保留 D类。 CDR取代了分配类别,但计算器仍然报告地址在哪个类。
用于什么的31和32次网?
31 只有一个地址,没有广播,用于路由器之间的点对点连接。 32 是一个主机地址,回回路和主机线路都常见。 计算器处理两种特殊情况。
API - 使用代码中的计算器
将此计算器称为自由 JSON 端点 。 不需要按键 。 将字段值发送到下面作为查询参数或 JSON 。 任何您省略的, 都会使用相同的默认值, 此页面预填的默认值是预填的; 未知参数是 400, 而不是静音零 。 读取 API 全部文件 →
终点
GET https://calculator.free/api/v1/subnet/
curl
curl "https://calculator.free/api/v1/subnet/?ip=192.168.1.10&cidr=24"
JavaScript fetch()
const r = await fetch(
"https://calculator.free/api/v1/subnet/?" + new URLSearchParams({
"ip": "192.168.1.10",
"cidr": "24"
}));
const data = await r.json();
console.log(data.results);
成果仅是一般指导的估计数,而不是财务、医疗或税务咨询。