IP Subnet Calculator (IPv4 & IPv6)
Enter an IP address with a CIDR prefix or a subnet mask. You get the network and broadcast address, the usable host range, the number of hosts, the masks and the address type. You can also split a network into smaller subnets and turn any IP range into CIDR blocks. Everything runs in your browser.
Accepts 10.1.2.3/8, 10.1.2.3 255.0.0.0, 10.1.2.3/255.0.0.0, a wildcard mask such as 0.0.0.255, and IPv6 such as 2001:db8::1/64.
Turns any first–last IP range into the smallest list of CIDR blocks that covers exactly that range, for firewall rules, allow lists and routing tables.
| # | CIDR block | Last IP | Size |
|---|
How to use this subnet calculator
- Type an IP address with its prefix, such as
192.168.1.130/26, or with a subnet mask, such as192.168.1.130 255.255.255.192. If you type only the address, choose the prefix from the list next to it. The result updates as you type. - Read the result: the network address, the broadcast address, the first and last usable host, how many hosts fit, the subnet mask, the wildcard mask (used in Cisco ACLs and OSPF), the IP class and whether the address is private, public or special.
- Binary view: the green bits are the network part, the grey bits are the host part. This is the easiest way to see why a subnet starts and ends where it does.
- Check an IP to see if it belongs to the subnet, for example before you add a firewall rule.
- Split the network into equal smaller subnets, for example a
/24into four/26networks for different VLANs. - IP range to CIDR converts a range like
10.0.0.5 – 10.0.0.20into the CIDR blocks you can paste into a firewall or a cloud security group.
IPv6 works the same way: type an address such as 2001:db8::1/64. Use Copy link to share a result; the address is kept in the link. Nothing you type is sent to a server.
How subnetting works
An IPv4 address has 32 bits, written as four numbers from 0 to 255. The prefix length (the number after the slash) says how many of the first bits name the network. The rest of the bits number the hosts inside that network. In 192.168.1.130/26, the first 26 bits are the network and the last 6 bits are for hosts, so the subnet has 26 = 64 addresses.
The subnet mask is the same information written as an address: 26 ones followed by 6 zeros, which is 255.255.255.192. The wildcard mask is the opposite (zeros for the network, ones for the hosts): 0.0.0.63.
Example: 192.168.1.130/26 by hand
- Block size = 256 − 192 = 64. The /26 subnets in the last number start at 0, 64, 128 and 192.
- 130 is between 128 and 191, so the network address is
192.168.1.128. - The broadcast address is the last address of the block: 128 + 64 − 1 =
192.168.1.191. - The usable hosts are everything in between:
192.168.1.129to192.168.1.190, which is 64 − 2 = 62 hosts.
The rule behind it: the network address is the IP AND the mask, and the broadcast address is the network address OR the wildcard mask. Two addresses are always reserved (network and broadcast), so a subnet has 2(32 − prefix) − 2 usable hosts. The exceptions are /31, which has 2 usable addresses for point-to-point links (RFC 3021), and /32, which is a single host.
IPv4 CIDR cheat sheet
Every prefix from /8 to /32 with its subnet mask, wildcard mask and size. The most common ones in home and office networks are /24 (254 hosts), /16 and, for links between two routers, /30 and /31.
| Prefix | Subnet mask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
/8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
/9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
/10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
/11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
/12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
/13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
/14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
/15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
/16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
/17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
/18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
/19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
/20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
/21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
/22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
/23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
/24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
/25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
/26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
/27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
/28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
/29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
/30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
/31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (point-to-point) |
/32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (single host) |
Private and special IP address ranges
These ranges are reserved and are not routed on the public internet. The calculator shows the matching type for any address you enter.
| Range (CIDR) | Addresses | Use |
|---|---|---|
10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | Private network (RFC 1918), large companies and clouds |
172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | Private network (RFC 1918), Docker uses 172.17.0.0/16 |
192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | Private network (RFC 1918), most home routers |
100.64.0.0/10 | 100.64.0.0 – 100.127.255.255 | Carrier-grade NAT (CGNAT, RFC 6598), also Tailscale |
127.0.0.0/8 | 127.0.0.0 – 127.255.255.255 | Loopback (localhost is 127.0.0.1) |
169.254.0.0/16 | 169.254.0.0 – 169.254.255.255 | Link-local: a device picks one when DHCP fails; 169.254.169.254 is the cloud metadata service |
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | 3 × 256 | Documentation and examples (RFC 5737) |
224.0.0.0/4 | 224.0.0.0 – 239.255.255.255 | Multicast (class D) |
240.0.0.0/4 | 240.0.0.0 – 255.255.255.254 | Reserved (class E); 255.255.255.255 is the limited broadcast |
IPv6 subnets in short
An IPv6 address has 128 bits, written as eight groups of four hex digits, such as 2001:0db8:0000:0000:0000:0000:0000:0001. Leading zeros in a group can be left out, and one run of zero groups can be replaced by ::, so the same address is 2001:db8::1.
The usual sizes are different from IPv4: a single LAN is almost always a /64 (the last 64 bits are the interface ID, needed for SLAAC). A home or small site usually gets a /56 or /48 from the provider, which is 256 or 65,536 /64 networks. IPv6 has no broadcast address, so every address in the range can be used. Common prefixes: fe80::/10 link-local, fc00::/7 unique local (the IPv6 version of private addresses), 2000::/3 global unicast, ff00::/8 multicast and 2001:db8::/32 for documentation.
Frequently asked questions
How many hosts are in a /24 subnet?
A /24 has 256 addresses (2 to the power of 8). Two of them are reserved: the network address (x.x.x.0) and the broadcast address (x.x.x.255), so 254 can be given to devices. The subnet mask of a /24 is 255.255.255.0.
What is the subnet mask for /27, /28, /29 and /30?
/27 = 255.255.255.224 (32 addresses, 30 usable hosts), /28 = 255.255.255.240 (16 addresses, 14 hosts), /29 = 255.255.255.248 (8 addresses, 6 hosts) and /30 = 255.255.255.252 (4 addresses, 2 hosts). The cheat sheet above lists every prefix from /8 to /32.
How do I calculate the network and broadcast address?
The network address is the IP address AND the subnet mask, bit by bit: all host bits become 0. The broadcast address is the network address with all host bits set to 1. For 192.168.1.130/26 the block size is 64, so the network is 192.168.1.128 and the broadcast is 192.168.1.191.
What does CIDR notation like /24 mean?
CIDR (Classless Inter-Domain Routing) writes a network as an address plus the number of network bits after a slash. 10.0.0.0/8 means the first 8 bits are fixed and the other 24 bits are free, so the network covers 10.0.0.0 to 10.255.255.255. A bigger number after the slash means a smaller network.
Why do you subtract 2 from the number of addresses?
In an IPv4 subnet the first address names the network itself and the last address is the broadcast address that reaches every host. Neither can be given to a device, so usable hosts = 2^(32 − prefix) − 2. A /31 is the exception: RFC 3021 lets both addresses be used on a point-to-point link. IPv6 has no broadcast, so nothing is subtracted.
What is a wildcard mask?
A wildcard mask is the inverse of the subnet mask: 0 bits must match and 1 bits can be anything. The wildcard for 255.255.255.0 is 0.0.0.255. Cisco access lists (ACLs) and OSPF network statements use wildcard masks. You can type a wildcard mask in the calculator and it is recognised.
How do I convert an IP range to CIDR?
Start at the first address and take the largest block that starts there (its size must be a power of 2 and the address must be a multiple of that size) and does not go past the last address. Repeat from the next address. The range 192.168.0.10 – 192.168.0.200 needs 8 blocks, from 192.168.0.10/31 to 192.168.0.200/32. The "IP range to CIDR" card does this for you.
Which IP addresses are private?
The private IPv4 ranges from RFC 1918 are 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. They are free to use inside any network but are not routed on the internet. In IPv6 the matching range is fc00::/7 (unique local addresses, in practice fd00::/8).