IP Subnet Calculator
Enter an IPv4 or IPv6 address with its prefix length. For IPv4 you get the subnet mask, the network and broadcast address, the usable host range and the host count. For IPv6 you get the network address, the first and last address, the exact number of addresses and the full eight-group form.
Enter as CIDR (e.g. 10.0.0.1/8 or 172.16.5.0/20)
How to use the IP Subnet Calculator
- Pick IPv4 or IPv6 above the input box.
- Type the address, a slash and the prefix length, such as 192.168.1.1/24 or 2001:db8::1/64. An IPv6 address can be written in full or shortened with ::, in upper or lower case.
- Press Calculate. To try another block, change the address or the prefix and press Calculate again.
The subnet math
Network = IP AND mask · · · Last address = Network OR (NOT mask) · · · IPv4 usable hosts = 2^(32 − prefix) − 2 · · · IPv6 addresses = 2^(128 − prefix)
The prefix length counts the network bits from the left. A /24 leaves 8 host bits of a 32-bit IPv4 address, and a /64 leaves 64 host bits of a 128-bit IPv6 address. For IPv4 the calculator subtracts 2 for the network and broadcast addresses, except in /31 and /32 blocks. IPv6 has no broadcast address, so it counts every address in the block. The IPv6 math runs on exact 128-bit integers, which is why a /64 shows all 20 digits of 18,446,744,073,709,551,616.
Worked examples
192.168.1.50/24 gives network 192.168.1.0, broadcast 192.168.1.255, mask 255.255.255.0 and 254 usable hosts from 192.168.1.1 to 192.168.1.254. 2001:db8:abcd:12::1/64 gives network 2001:db8:abcd:12::, last address 2001:db8:abcd:12:ffff:ffff:ffff:ffff and 18,446,744,073,709,551,616 addresses.
Frequently asked questions
What is CIDR notation?
Classless Inter-Domain Routing notation writes an address, a slash and the number of network bits. 192.168.1.0/24 has 24 network bits, the same as the mask 255.255.255.0. IPv6 uses the same notation, such as 2001:db8::/32, and almost never writes the mask out.
How is an IPv6 address shortened?
The calculator follows RFC 5952. Leading zeros in each group go, so 0db8 becomes db8. The longest run of two or more zero groups becomes ::, and on a tie the first run is the one shortened. A single zero group stays as 0. So 2001:db8:0:0:1:0:0:1 becomes 2001:db8::1:0:0:1. The Expanded row shows all eight groups with four digits each.
How many /64 subnets fit in a /48?
A /48 has 16 bits between its prefix and /64, so it holds 2^16 = 65,536 /64 subnets. The calculator shows this count for any IPv6 prefix of /64 or shorter. A /56 holds 256 and a /60 holds 16.
What are the private IP ranges?
IPv4 has 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. IPv6 has fc00::/7, the unique local range. None of them route on the public internet. In IPv6 mode the Address Type row names the block an address sits in, such as unique local, link-local or global unicast.
Why subtract 2 from the IPv4 host count?
In an IPv4 subnet the all-zeros host address is the network address and the all-ones address is the broadcast address, so neither goes to a host. /31 point-to-point links and /32 single hosts are the exceptions, and there the calculator counts every address. IPv6 has no broadcast address, so in IPv6 mode you get the full count and the range from the first address to the last.
Can I enter an IPv4 address in IPv6 mode?
Not on its own. IPv6 mode expects an address with colons and asks you to switch to IPv4 if you type 192.168.1.1. To see an IPv4 address as IPv6, enter its IPv4-mapped form, ::ffff:192.168.1.1/128. The calculator reads the dotted part as the last 32 bits.