IPv4 mask convert
ipv4-mask-convert · version 1.0.0 · URLs & IP addresses · free, no key needed
Convert between an IPv4 prefix length, dotted subnet netmask, and dotted wildcard (host) mask.
Use when you need to: ipv4 mask convert · prefix to netmask · netmask to prefix.
Supported
- ipv4 mask convert
- prefix to netmask
- netmask to prefix
- wildcard mask convert
- subnet mask calculator
Not supported
- IPv6
- non-contiguous masks
Behavior
- Input is exactly one of prefix, netmask, or wildcard; unknown fields and multiple/zero of these three throw.
- prefix is a JSON integer 0-32.
- netmask must be a contiguous run of 1-bits from the most significant bit followed by 0-bits (a valid subnet mask); otherwise the tool throws.
- wildcard is the bitwise complement of a valid netmask (a contiguous run of 0-bits followed by 1-bits); otherwise the tool throws.
- Output always includes all three equivalent representations.
Input
- object
Output
prefix(integer, required): min 0; max 32netmask(string, required): max length 15wildcard(string, required): max length 15
Limits
- prefix min: 0
- prefix max: 32
Example
Request input:
{
"prefix": 24
}
Response:
{
"result": {
"prefix": 24,
"netmask": "255.255.255.0",
"wildcard": "0.0.0.255"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "ipv4-mask-convert",
"version": "1.0.0",
"input": {
"prefix": 24
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/ipv4-mask-convert/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"prefix":24}'
The machine-readable contract is at /v1/tools/ipv4-mask-convert/versions/1.0.0.
CLI
node cli.mjs run ipv4-mask-convert 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- IPv4 CIDR parse: Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.
- IPv4 prefix for hosts: Compute the smallest IPv4 CIDR block (largest prefix length) whose usable host capacity meets a required count.
- IPv4 range to cidrs: Convert an arbitrary IPv4 address range into the minimal list of CIDR blocks that exactly covers it.
- IPv4 address offset: Add a signed integer offset to an IPv4 address, throwing if the result leaves the IPv4 address space.
- 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).