BMI 计算器
将IPv4网络划分为等大小的子网,或使用VLSM按主机需求分配子网。
关于此工具
输入任意IPv4 CIDR网络(如192.168.0.0/16),指定所需子网数量或每个子网所需的主机数;计算器会确定最优前缀长度,并列出每个子网的网络地址、广播地址、可用主机范围和子网掩码。VLSM(可变长度子网掩码)模式允许您命名多个子网并指定每个子网的主机需求——子网从最大到最小依次分配,以最大程度提高效率。ASCII艺术树形图直观展示地址空间的划分方式。
使用方法
- 1 在「网络」字段中以CIDR表示法输入基础网络(如10.0.0.0/8)。
- 2 选择「等长子网」模式,输入子网数量或每个子网的主机数——另一个值会自动计算。
- 3 或切换到「VLSM」模式,按名称和所需主机数添加每个子网,然后点击「计算」。
- 4 查看子网表和ASCII树形图;点击任意值可复制它。
What this calculator does that a plain subnet lookup does not
A basic subnet tool tells you the mask, broadcast, and host range for a single network. This calculator goes a step further: it carves one base block into many subnets. You give it a starting network in CIDR form — say 192.168.0.0/16 — and it splits that space for you in one of two ways. In Equal Subnets mode every piece is the same size; in VLSM mode each piece is sized independently to fit the hosts it actually needs. Both modes produce a full table (network, first and last host, broadcast, mask, usable count) plus an ASCII allocation tree you can paste into documentation.
Equal subnets: splitting by count or by host requirement
In equal mode you choose one of two questions. "Divide into N subnets" borrows enough bits from the host portion to create at least N blocks: the tool computes bits = ceil(log2(N)) and adds them to the prefix. Asking for 4 subnets borrows 2 bits, so a /16 becomes four /18 networks. Alternatively, "Hosts per subnet" finds the smallest block whose usable count meets your figure, then reports how many such blocks fit in the base. Because subnet sizes are always powers of two, asking for 4 subnets and asking for 5 both borrow the same bits when 5 rounds up past a power-of-two boundary — the tool always rounds up so every request is satisfied.
A worked VLSM example
VLSM (Variable Length Subnet Masking) is where this tool earns its keep. Suppose you have 192.168.0.0/24 and three departments needing 50, 25, and 10 hosts. A naïve equal split into four /26 blocks (62 hosts each) wastes huge ranges on the small departments. The VLSM allocator instead sorts your requirements largest-first and packs them tightly:
| Department | Hosts needed | Allocated block | Usable |
|---|---|---|---|
| LAN A | 50 | 192.168.0.0/26 | 62 |
| LAN B | 25 | 192.168.0.64/27 | 30 |
| LAN C | 10 | 192.168.0.96/28 | 14 |
Sorting largest-first is what keeps the blocks aligned: each subnet starts on a boundary that is a multiple of its own size, which is a hard rule of CIDR. The tool advances a cursor after every allocation and rounds it up to the next valid boundary, so you can never accidentally create overlapping or misaligned ranges. After placing all three, the space from 192.168.0.112 onward stays free for future growth — something the equal split would have squandered.
How the bit math works under the hood
Every address is treated as a single 32-bit integer. The mask for a /26 is 0xFFFFFFC0 (26 leading ones); ANDing an address with it yields the network, and the host count is 2^(32 − prefix) minus the two reserved addresses (network and broadcast). The allocator's "smallest block that fits" search starts at /30 and widens the prefix until the usable count clears your requirement, which is exactly how a network engineer sizes a subnet by hand — just instant and error-free.
Use cases
- Office network design. Allocate right-sized subnets per floor, department, or VLAN without wasting a public or RFC 1918 block.
- Studying for CCNA. VLSM problems are an exam staple; checking your hand-worked answer against the allocation table builds speed and confidence.
- Cloud and lab planning. Carve a VPC CIDR into subnets for app, database, and management tiers before you provision anything.
- Documentation. Copy the ASCII tree straight into a runbook or wiki so the next engineer sees the whole hierarchy at a glance.
Tips and common mistakes
- Plan for the +2 overhead per subnet. Requesting "exactly 30 hosts" lands you in a
/27(30 usable) with zero spare. If the department might grow, ask for a few more. - Order does not matter in VLSM input — the tool sorts for you. You can list departments in any order; it always allocates largest-first to preserve alignment.
- Watch for "Network space exhausted." If your requirements add up to more than the base block holds, the tool flags the subnet that no longer fits rather than silently overlapping.
- The base can be any address in the block. Entering
192.168.0.37/24is fine; the tool ANDs it down to the true192.168.0.0network first. - Equal mode rounds up. Asking for 3 subnets gives you 4 (two borrowed bits), because subnet counts are powers of two — the extra block is yours to keep in reserve.
Privacy
All of this is integer bit-math performed in your browser. The networks you enter are never transmitted or logged, and the calculator keeps working with no internet connection once the page has loaded.