IPv4 prefix for hosts
ipv4-prefix-for-hosts · version 1.0.0 · URLs & IP addresses · free, no key needed
Compute the smallest IPv4 CIDR block (largest prefix length) whose usable host capacity meets a required count.
Use when you need to: ipv4 prefix for hosts · subnet size for host count · minimal ipv4 prefix for hosts.
Supported
- ipv4 prefix for hosts
- subnet size for host count
- minimal ipv4 prefix for hosts
Not supported
- IPv6
- VLSM planning across multiple subnets
Behavior
- usable_hosts is a JSON integer from 0 to 4294967294.
- Usable capacity follows RFC 3021: /32 has 1 usable host, /31 has 2, /0-/30 reserve network+broadcast so usable = 2^(32-prefix) - 2.
- prefix is the largest prefix length (smallest block) whose usable capacity is >= usable_hosts.
Input
usable_hosts(integer, required): min 0; max 4294967294
Output
prefix(integer, required): min 0; max 32netmask(string, required): max length 15usable_host_count(string, required): pattern^(0|[1-9][0-9]*)$total_count(string, required): pattern^(0|[1-9][0-9]*)$
Limits
- usable hosts min: 0
- usable hosts max: 4294967294
Example
Request input:
{
"usable_hosts": 60
}
Response:
{
"result": {
"prefix": 26,
"netmask": "255.255.255.192",
"usable_host_count": "62",
"total_count": "64"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "ipv4-prefix-for-hosts",
"version": "1.0.0",
"input": {
"usable_hosts": 60
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/ipv4-prefix-for-hosts/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"usable_hosts":60}'
The machine-readable contract is at /v1/tools/ipv4-prefix-for-hosts/versions/1.0.0.
CLI
node cli.mjs run ipv4-prefix-for-hosts 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- IPv4 mask convert: Convert between an IPv4 prefix length, dotted subnet netmask, and dotted wildcard (host) mask.
- IPv4 CIDR contains: Test whether one IPv4 CIDR block fully contains another IPv4 CIDR block.
- IPv4 CIDR overlap: Test whether two IPv4 CIDR blocks overlap (share at least one address).
- IPv4 CIDR parse: Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.
- IPv4 in CIDR: Test whether a canonical IPv4 address lies in a CIDR prefix whose host bits are zero.
- IPv4 address classify: Classify an IPv4 address against the static IANA IPv4 special-purpose address registry.