CIDR and subnet calculator
Work out the network, netmask, host range and size of an IPv4 or IPv6 CIDR block, and split it into subnets.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/cidr-calc \
-H 'Content-Type: application/json' \
-d '{"input":{"cidr":"192.168.1.0/24","addresses":["192.168.1.77","192.168.2.1"]}}'
import json, urllib.request
body = {'input': {'cidr': '192.168.1.0/24', 'addresses': ['192.168.1.77', '192.168.2.1']}}
request = urllib.request.Request("https://setget.net/v1/tools/cidr-calc", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/cidr-calc", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"cidr":"192.168.1.0/24","addresses":["192.168.1.77","192.168.2.1"]}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "cidr-calc",
"input": {
"cidr": "192.168.1.0/24",
"addresses": [
"192.168.1.77",
"192.168.2.1"
]
}
}
{
"input": {
"cidr": "192.168.1.0/24",
"addresses": [
"192.168.1.77",
"192.168.2.1"
]
}
}
Endpoint: POST /v1/tools/cidr-calc. Over MCP: run_tool with slug: "cidr-calc".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
cidr |
string | yes | The block in CIDR form, such as 192.168.1.0/24 or 2001:db8::/48. |
addresses |
array | no | IP addresses to test for being inside the block. |
new_prefix |
integer | no | Split the block into subnets of this prefix length. The first 256 are listed. From 0 to 128. |
Examples
Input
{
"cidr": "192.168.1.0/24",
"addresses": [
"192.168.1.77",
"192.168.2.1"
]
}Result
{
"cidr": "192.168.1.0/24",
"version": 4,
"network": "192.168.1.0",
"prefix": 24,
"netmask": "255.255.255.0",
"wildcard": "0.0.0.255",
"broadcast": "192.168.1.255",
"first_host": "192.168.1.1",
"last_host": "192.168.1.254",
"total_addresses": 256,
"usable_hosts": 254,
"scope": "private",
"is_private": true,
"is_loopback": false,
"is_link_local": false,
"is_reserved": false,
"host_bits_set": false,
"contains": [
{
"address": "192.168.1.77",
"inside": true
},
{
"address": "192.168.2.1",
"inside": false
}
],
"subnets": null
}Split into /24 subnets
Input
{
"cidr": "10.0.0.0/22",
"new_prefix": 24
}Result
{
"cidr": "10.0.0.0/22",
"version": 4,
"network": "10.0.0.0",
"prefix": 22,
"netmask": "255.255.252.0",
"wildcard": "0.0.3.255",
"broadcast": "10.0.3.255",
"first_host": "10.0.0.1",
"last_host": "10.0.3.254",
"total_addresses": 1024,
"usable_hosts": 1022,
"scope": "private",
"is_private": true,
"is_loopback": false,
"is_link_local": false,
"is_reserved": false,
"host_bits_set": false,
"contains": [],
"subnets": {
"prefix": 24,
"count": 4,
"addresses_each": 256,
"truncated": false,
"listed": [
"10.0.0.0/24",
"10.0.1.0/24",
"10.0.2.0/24",
"10.0.3.0/24"
]
}
}Questions
- Why are two addresses not usable in IPv4?
- The first address names the network and the last is the broadcast address. A /31 (two hosts, point-to-point links) and a /32 (one host) are the exceptions.
- Why are some counts in quotes?
- Numbers above 2^53, common for IPv6, are returned as text so that no JSON reader rounds them.
- What does scope "mixed" mean?
- The block is partly public and partly special-purpose space, for example 0.0.0.0/0.
Related tools
- IP address inspectorClassify an IPv4 or IPv6 address (private, loopback, CGNAT and more) and show its integer, hex and reverse-DNS forms.
ip-inspect - URL parserSplit a URL into scheme, login, host, port, path, query parameters and fragment.
url-parse - .gitignore testerCheck which paths a .gitignore file ignores and which line decided each one, using real Git matching rules.
gitignore-test - Cache-Control explainerExplain a Cache-Control header directive by directive and how browsers and CDNs will treat the response.
cache-control-explain - Card number (Luhn) and IBAN validatorCheck a card number with the Luhn checksum and name its network, or check an IBAN by length and mod-97.
luhn-iban-validate - Cookie parserParse Cookie and Set-Cookie headers into JSON, with warnings about missing security attributes.
cookie-parse