Free tool
Subnet calculator for IPv4 and IPv6
Type an IP address with a prefix or mask, like 192.168.1.10/24 or 2001:db8::/48, to get the network and broadcast address, the usable host range, the subnet and wildcard mask and the host count. Then split the block into subnets, plan a VLSM layout, merge a list of routes, check which IPs it contains, or paste a range to get its CIDR blocks.
Free · no sign-up · runs in your browser, nothing is uploaded
192.168.1.10 is a host inside .
Network
192.168.1.0/24
Usable hosts
254
Subnet mask
255.255.255.0
Type
Private (RFC 1918)
- Network address
- 192.168.1.0
- Broadcast address
- 192.168.1.255
- First usable host
- 192.168.1.1
- Last usable host
- 192.168.1.254
- Usable hostsTotal minus the network and broadcast addresses.
- 254
- Total addresses
- 256
- Subnet mask
- 255.255.255.0
- Wildcard mask (ACLs, OSPF)
- 0.0.0.255
- CIDR notation
- 192.168.1.0/24
- Address range
- 192.168.1.0 - 192.168.1.255
- Address type
- Private (RFC 1918)
- Class (legacy)
- C
- Integer
- 3232235786
- Hex
- 0xC0A8010A
- Mask in hex
- 0xFFFFFF00
- IPv4-mapped IPv6
- ::ffff:192.168.1.10
- Reverse DNS (PTR) name
- 10.1.168.192.in-addr.arpa
- Reverse DNS zone
- 1.168.192.in-addr.arpa
Usable IPs if this is a cloud subnet
AWS VPC
251
−5 reserved
Azure VNet
251
−5 reserved
Google Cloud
252
−4 reserved
24 network bits · 8 host bits
4 subnets of /26 (255.255.255.192), 62 usable each
| Subnet | Host range | Broadcast | Usable |
|---|---|---|---|
| 192.168.1.0/26 | 192.168.1.1 - 192.168.1.62 | 192.168.1.63 | 62 |
| 192.168.1.64/26 | 192.168.1.65 - 192.168.1.126 | 192.168.1.127 | 62 |
| 192.168.1.128/26 | 192.168.1.129 - 192.168.1.190 | 192.168.1.191 | 62 |
| 192.168.1.192/26 | 192.168.1.193 - 192.168.1.254 | 192.168.1.255 | 62 |
How to calculate a subnet by hand
An IPv4 address is 32 bits. The prefix length (the number after the slash) says how many of those bits, from the left, name the network. The rest name a host inside it. Everything else follows from that split. Take 192.168.1.77/26:
Address 192.168.1.77 11000000.10101000.00000001.01 001101
Mask /26 255.255.255.192 11111111.11111111.11111111.11 000000
network | host
Network = address AND mask -> 192.168.1.64
Broadcast = network with host bits = 1 -> 192.168.1.127
Hosts = 2^(32-26) - 2 = 64 - 2 -> 62 (192.168.1.65 to .126)
Wildcard = NOT mask -> 0.0.0.63A shortcut for masks that end inside one octet: subtract that octet from 256 to get the block size. For /26 the last octet of the mask is 192, so blocks are 64 apart (.0, .64, .128, .192), and .77 falls in the block that starts at .64. IPv6 works the same way with 128 bits, written in hex, and without a broadcast address.
CIDR to subnet mask chart (/32 to /0)
Every IPv4 prefix length with its mask, wildcard mask and size. Usable hosts are the total minus the network and broadcast addresses, except /31 and /32. The binary converter shows how each mask octet looks in bits.
| CIDR | Subnet mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33,554,432 | 33,554,430 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67,108,864 | 67,108,862 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134,217,728 | 134,217,726 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268,435,456 | 268,435,454 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536,870,912 | 536,870,910 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1,073,741,824 | 1,073,741,822 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2,147,483,648 | 2,147,483,646 |
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | 4,294,967,294 |
IPv6 prefix sizes
IPv6 subnets are almost always /64, because SLAAC (stateless address autoconfiguration) needs a 64-bit interface ID. Larger prefixes are handed out to sites and customers. There is no broadcast address; the first address of a subnet is the subnet-router anycast address.
| Prefix | /64 subnets inside | Typical use |
|---|---|---|
| /32 | 4,294,967,296 | Allocation to an ISP or large network |
| /48 | 65,536 | A site or organization |
| /56 | 256 | A home or small business from an ISP |
| /64 | 1 | One LAN or VLAN (needed for SLAAC) |
| /127 | n/a (2 addresses) | Point-to-point router links (RFC 6164) |
| /128 | n/a (1 address) | A single host or loopback |
The calculator writes IPv6 the way RFC 5952 asks: lowercase, no leading zeros, and the longest run of zero groups shortened to ::. It also shows the fully expanded form and the ip6.arpa name you need for reverse DNS.
Private and reserved IP ranges
The address type shown in the tool comes from the IANA special-purpose registries. The ranges you meet most:
| Range | What it is | Defined in |
|---|---|---|
| 10.0.0.0/8 | Private network | RFC 1918 |
| 172.16.0.0/12 | Private network (172.16.0.0 to 172.31.255.255) | RFC 1918 |
| 192.168.0.0/16 | Private network | RFC 1918 |
| 100.64.0.0/10 | Shared address space for carrier-grade NAT | RFC 6598 |
| 127.0.0.0/8 | Loopback | RFC 1122 |
| 169.254.0.0/16 | Link-local, self-assigned when DHCP fails | RFC 3927 |
| 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Documentation examples (TEST-NET-1/2/3) | RFC 5737 |
| 224.0.0.0/4 | Multicast | RFC 5771 |
| fc00::/7 | IPv6 unique local (private) | RFC 4193 |
| fe80::/10 | IPv6 link-local | RFC 4291 |
| 2001:db8::/32 | IPv6 documentation | RFC 3849 |
Cloud subnets have fewer usable IPs
Cloud providers keep a few addresses in every subnet for their own routers and DNS, so a /24 there gives you fewer than 254 hosts. The tool shows all three counts for any IPv4 subnet.
| Provider | Reserved per subnet | Usable in a /24 |
|---|---|---|
| AWS VPC | First four and the last address. Subnets must be /16 to /28. | 251 |
| Azure VNet | First four and the last address. Subnets must be /2 to /29. | 251 |
| Google Cloud VPC | Network, gateway, second-to-last and broadcast address of the primary range. Subnets must be /4 to /29. | 252 |
When you plan a VPC, size each subnet for the hosts you need plus these reserved addresses, and leave room to grow. The VLSM planner above packs subnets largest first so they never overlap. Running infrastructure as code? Browse DevOps tools on DevHunt, or turn a container command into a compose file with the docker run to compose converter.
Subnet math in code
Most languages ship this in the standard library, so you rarely need to write the bit math yourself.
# Python
import ipaddress
net = ipaddress.ip_network("192.168.1.77/26", strict=False)
net.network_address, net.broadcast_address # 192.168.1.64, 192.168.1.127
net.netmask, net.hostmask, net.num_addresses # 255.255.255.192, 0.0.0.63, 64
list(net.subnets(new_prefix=28)) # split into four /28s
ipaddress.ip_address("192.168.1.100") in net # True
list(ipaddress.summarize_address_range(
ipaddress.ip_address("10.0.0.5"), ipaddress.ip_address("10.0.0.100"))) # range to CIDR
// Go (net/netip)
p := netip.MustParsePrefix("192.168.1.77/26")
p.Masked() // 192.168.1.64/26
p.Contains(netip.MustParseAddr("192.168.1.100")) // true
-- PostgreSQL
SELECT network('192.168.1.77/26'::inet), -- 192.168.1.64/26
broadcast('192.168.1.77/26'::inet), -- 192.168.1.127/26
netmask('192.168.1.77/26'::inet), -- 255.255.255.192
'192.168.1.100'::inet << '192.168.1.64/26'::cidr; -- true
// JavaScript (no built-in, IPv4 only)
const toInt = ip => ip.split('.').reduce((n, o) => (n << 8) + +o, 0) >>> 0;
const mask = prefix => (prefix ? (~0 << (32 - prefix)) >>> 0 : 0);
const network = (toInt('192.168.1.77') & mask(26)) >>> 0;In JavaScript, remember >>> 0: bitwise operators work on signed 32-bit integers, so without it any address above 127.255.255.255 comes out negative. For IPv6, use BigInt, which is what this calculator does. To read the hex form of an address as a number, try the hex to decimal converter.
More free developer tools
FAQ
What is the subnet mask for a /24?+
255.255.255.0. A /24 has 24 network bits and 8 host bits, so it holds 256 addresses. The first (.0) is the network address and the last (.255) is the broadcast address, which leaves 254 usable hosts.
How many IP addresses are in a /20?+
A /20 has 32 - 20 = 12 host bits, so it holds 2^12 = 4,096 addresses, of which 4,094 are usable hosts. The mask is 255.255.240.0. In general an IPv4 /n holds 2^(32 - n) addresses.
How do I calculate the CIDR range of a subnet?+
Convert the address and mask to binary and AND them: that gives the network address, the start of the range. Then set every host bit to 1 to get the last address. For 10.1.5.77/22 the network is 10.1.4.0 and the last address is 10.1.7.255. The calculator above does this for any IPv4 or IPv6 prefix.
What is the difference between a subnet mask and a wildcard mask?+
A wildcard mask is the subnet mask with every bit flipped. 255.255.255.0 becomes 0.0.0.255. Cisco ACLs and OSPF network statements use wildcard masks, where a 0 bit means "must match" and a 1 bit means "any value". If you paste a wildcard mask where a subnet mask belongs, the calculator tells you and shows the subnet mask.
Why does a subnet have two fewer usable hosts?+
In IPv4 the all-zeros host address names the network itself and the all-ones host address is the broadcast address, so neither can be given to a device. Two exceptions: a /31 has no network or broadcast address and both IPs are usable on point-to-point links (RFC 3021), and a /32 is a single host. IPv6 has no broadcast at all.
What are the IP address classes?+
Before CIDR (1993), the first bits of an IPv4 address set its class. Class A is 0-127 with a default /8, class B is 128-191 with /16, class C is 192-223 with /24, class D (224-239) is multicast and class E (240-255) is reserved. Routing has been classless since RFC 1519, so the class is only a label today.
How do I summarize a list of subnets into one route?+
Sort the blocks, merge any that overlap or touch, then cover each merged range with the fewest aligned CIDR blocks. 10.0.0.0/24 and 10.0.1.0/24 become 10.0.0.0/23, but 10.0.1.0/24 and 10.0.2.0/24 cannot merge, because 10.0.1.0 is not on a /23 boundary. Paste the list into "Summarize routes" above to get the exact result.
How do I find my own subnet mask?+
On Windows run ipconfig and read the Subnet Mask line. On macOS and Linux run ip addr (or ifconfig): the address is shown with a prefix such as 192.168.1.20/24, where /24 means 255.255.255.0. Paste that into the calculator to see the full network.
Sources: RFC 4632 (CIDR) · RFC 1918 (private IPv4) · RFC 6598 (shared address space) · RFC 3021 (/31 links) · RFC 5737 (IPv4 documentation) · RFC 4291 (IPv6 addressing) · RFC 5952 (IPv6 text format) · RFC 3056 (6to4) · RFC 4193 (IPv6 unique local) · IANA IPv4 special-purpose registry · IANA IPv6 special-purpose registry · AWS: subnet CIDR blocks · Azure: virtual network FAQ · Google Cloud: subnets · Python ipaddress · Go net/netip · PostgreSQL network functions. Checked 2026-10-31.