IP subnetting arithmetic for IPv4 and IPv6: paste an address with a prefix length (/26, /112) and get the network address, broadcast, usable host range, host count, wildcard mask and the binary expansion that shows where the network/host boundary falls.
The IPv4 host count applies the 2^(32−n) − 2 rule and knows the /31 point-to-point and /32 host exceptions. Everything is bit arithmetic on BigInt — IPv6 works exactly, not through lossy decimal shortcuts.
Frequently asked questions
Why is the usable host count not a power of two?
The all-zeros host address identifies the subnet and the all-ones address is reserved for broadcast, so 2 are subtracted — a /26 offers 62, not 64.
Can I use this to plan a split?
Yes — compute the target subnet size first (how many host bits you need), then the prefix length follows as 32 − bits (or 128 − bits for IPv6); subnets must align to multiples of their own size.
中文说明
IPv4 与 IPv6 的子网算术:输入地址加前缀长度(/26、/112),一次得到网络地址、广播地址、可用主机范围、主机数、反掩码与展示网络/主机边界的二进制展开。
IPv4 主机数按 2^(32−n) − 2 计算,并处理 /31 点对点链路与 /32 单主机两个特例。全部基于 BigInt 位运算——IPv6 是精确计算,没有经过有损的十进制捷径。
常见问题
可用主机数为什么不是 2 的幂?
主机位全 0 的地址标识子网本身、全 1 保留作广播,所以要减 2——/26 是 62 而不是 64。
能用它规划子网切分吗?
能——先算目标子网需要多少主机位,前缀长度就是 32 − 位数(IPv6 为 128 − 位数);子网边界必须对齐自身大小的整数倍。