# IPv4 CIDR subnets

`ipv4-cidr-subnets` · version 1.0.0 · URLs & IP addresses · free, no key needed

Split an IPv4 CIDR block into the full ordered list of equal-size subnets at a given longer prefix.

**Use when you need to: ipv4 cidr subnets · split ipv4 cidr into subnets · ipv4 subnetting.**

## Supported

- ipv4 cidr subnets
- split ipv4 cidr into subnets
- ipv4 subnetting

## Not supported

- IPv6
- unequal (VLSM) splits
- splitting into a target subnet count instead of a prefix

## Behavior

- cidr is dotted-decimal/prefix with host bits zero; new_prefix is a JSON integer strictly greater than cidr's prefix and at most 32.
- subnets is the ordered list of all 2^(new_prefix - prefix) equal-size /new_prefix blocks that exactly partition cidr, network-address first.
- Throws if 2^(new_prefix - prefix) would exceed 4096.

## Input

- `cidr` (string, required): max length 18
- `new_prefix` (integer, required): min 0; max 32

## Output

- `subnets` (array of string, required): max items 4096; each max length 18
- `count` (integer, required): min 1; max 4096

## Limits

- max cidr length: 18
- prefix max: 32
- max output subnets: 4096

## Example

Request input:

```json
{
  "cidr": "192.168.1.0/24",
  "new_prefix": 26
}
```

Response:

```json
{
  "result": {
    "subnets": [
      "192.168.1.0/26",
      "192.168.1.64/26",
      "192.168.1.128/26",
      "192.168.1.192/26"
    ],
    "count": 4
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "ipv4-cidr-subnets",
  "version": "1.0.0",
  "input": {
    "cidr": "192.168.1.0/24",
    "new_prefix": 26
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ipv4-cidr-subnets/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"cidr":"192.168.1.0/24","new_prefix":26}'
```

The machine-readable contract is at [/v1/tools/ipv4-cidr-subnets/versions/1.0.0](/v1/tools/ipv4-cidr-subnets/versions/1.0.0).

### CLI

```sh
node cli.mjs run ipv4-cidr-subnets 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [IPv6 CIDR subnets](/tools/ipv6-cidr-subnets): Split an IPv6 CIDR block into the full ordered list of equal-size subnets at a given longer prefix.
- [IPv4 CIDR aggregate](/tools/ipv4-cidr-aggregate): Merge a list of IPv4 CIDR blocks into the minimal equivalent list of non-overlapping CIDR blocks.
- [IPv4 CIDR contains](/tools/ipv4-cidr-contains): Test whether one IPv4 CIDR block fully contains another IPv4 CIDR block.
- [IPv4 CIDR overlap](/tools/ipv4-cidr-overlap): Test whether two IPv4 CIDR blocks overlap (share at least one address).
- [IPv4 CIDR parse](/tools/ipv4-cidr-parse): Parse an IPv4 CIDR block into its network, broadcast, netmask, wildcard mask, usable host range and address counts.
- [IPv4 in CIDR](/tools/ipv4-in-cidr): Test whether a canonical IPv4 address lies in a CIDR prefix whose host bits are zero.
