IP subnet calculator
Type an IPv4 address with a prefix, such as 192.168.1.10/24, or with a mask after a space, such as 192.168.1.10 255.255.255.0. The calculator doesn't handle IPv6. It runs in your browser; nothing you enter is uploaded.
| Network in CIDR notation | ||
|---|---|---|
| Network address | ||
| Broadcast address | ||
| Subnet mask | ||
| Wildcard mask | ||
| First usable host | ||
| Last usable host |
How the calculator works it out
The prefix length says how many bits, counted from the left, belong to the network. The remaining bits number the hosts inside it. A /24 mask is 24 one bits followed by 8 zero bits, which you'd write as 255.255.255.0.
Set every host bit to 0 and you get the network address; set them all to 1 and you get the broadcast address. For 192.168.1.10/24 the host part is the last 8 bits, so the network is 192.168.1.0 and the broadcast address is 192.168.1.255. You can't give either of those to a device, which leaves 28 − 2 = 254 hosts, 192.168.1.1 to 192.168.1.254.
Smaller subnets work the same way. In 10.0.0.6/30, the last number, 6, is 00000110 in binary, and only its last 2 bits are host bits. Clearing them gives
00000100, so the network is 10.0.0.4, the broadcast address is 10.0.0.7, and the two usable hosts are 10.0.0.5 and 10.0.0.6.
What the results mean
- Network address: the subnet itself, used in routing tables and firewall rules. It isn't given to a device.
- Broadcast address: a packet sent here goes to every host on the subnet.
- Wildcard mask: the mask with every bit flipped, 0.0.0.255 for a /24. Cisco access lists and OSPF network statements take it instead of the subnet mask.
- Usable hosts: the addresses you can give to devices, including the one the router or gateway uses.
/31 and /32 subnets
A /31 has only two addresses, and the usual rule would reserve both, leaving none for devices. RFC 3021 lets a point-to-point link between two routers use both, with no network or broadcast address, and the calculator shows a /31 that way. A /32 is a single address. You'll see it naming one host in a route or a firewall rule, or as a router's loopback address.
Private and reserved ranges
RFC 1918 sets aside 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 for private networks. Those addresses aren't routed on the public internet, and home routers hand them out behind NAT. Internet providers use 100.64.0.0/10 for carrier-grade NAT. The calculator's Address type row also recognizes many of the ranges in the IANA special-purpose address registry, such as loopback 127.0.0.0/8, link-local 169.254.0.0/16, and documentation ranges like 192.0.2.0/24.
The address class comes from the scheme used before 1993, where the first number fixed the network size. CIDR replaced classes in 1993 with RFC 1519, so the class is only a label now and tells you nothing about the subnet's real size. Cloud networks also reserve more addresses than the rules above: AWS keeps the first four and the last address of every VPC subnet for itself.
Common prefix sizes
| Prefix | Subnet mask | Usable hosts |
|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 |
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 |
| /32 | 255.255.255.255 | 1 |
In code
Python's standard ipaddress module does the same arithmetic:
import ipaddress
net = ipaddress.ip_interface("192.168.1.10/24").network
print(net, net.broadcast_address, net.netmask, net.num_addresses)
# 192.168.1.0/24 192.168.1.255 255.255.255.0 256