/api/v1/subnet
Calculate a subnet
Network and broadcast addresses, usable host range, masks, and host counts for an IPv4 address and prefix length. Accepts either ?ip=10.0.0.0&cidr=24 or the combined ?ip=10.0.0.0/24.
Parameters
| ipstring · query | requiredIPv4 address, optionally with the prefix length attached as a.b.c.d/n. |
| cidrinteger · query | optionalPrefix length, 0–32. Required unless it was supplied as part of ip. |
$ curl https://subnet.im/api/v1/subnet?ip=10.0.0.0&cidr=24{
"input": {
"ip": "10.0.0.0",
"cidr": 24
},
"network": {
"networkAddress": "10.0.0.0",
"broadcastAddress": "10.0.0.255",
"firstUsableHost": "10.0.0.1",
"lastUsableHost": "10.0.0.254",
"subnetMask": "255.255.255.0",
"wildcardMask": "0.0.0.255",
"cidrNotation": "10.0.0.0/24"
},
"counts": {
"totalHosts": 256,
"usableHosts": 254,
"networkBits": 24,
"hostBits": 8
},
"classification": {
"private": true,
"special": {
"cidr": "10.0.0.0/8",
"label": "Private use"
}
}
}Errors
- 400invalid_request
ipis missing or not a valid IPv4 address, orcidris outside 0–32.
Caching · Immutable — the answer for a given input never changes.