Gate46
  1. All tools
  2. Address line

Subnet calculator

Turn an address and a prefix into its network, host range and masks. Works for IPv4 and IPv6, and the maths runs in your browser.

Type 192.0.2.130/26, an address and mask such as 192.0.2.130 255.255.255.192, or an IPv6 prefix such as 2001:db8:abcd::/48. An IPv4 address on its own is read as a /24.
Or pick a common prefix
Enter a network to see its range.

For IPv4 you get the network and broadcast addresses, the usable host range, both masks, the address in binary, and ways to split the block into smaller subnets. For IPv6 you get the first and last address, the size of the block, and how many /64 networks fit inside. Try one of these:

What a subnet is

A subnet is a block of IP addresses that share the same leading bits. Devices inside the block talk to each other directly. Traffic for anywhere else goes through a router.

Every IP address has two parts. The network part names the block, and the host part names one device inside it. The prefix length says where the split falls. This calculator takes an address and a prefix and shows the block it belongs to: where it starts, where it ends, and how many devices it can hold. Nothing you type is sent anywhere.

Reading CIDR notation

CIDR notation writes an address, a slash, then the number of network bits. In 192.0.2.130/26 the first 26 bits are the network and the last 6 belong to hosts. Six host bits give 26, or 64, addresses. They run from 192.0.2.128 to 192.0.2.191.

The first address of a block is the network address. The last is the broadcast address, which reaches every host at once. Neither can be given to a device, so a /26 holds 62 hosts. A subnet mask says the same thing as the prefix in dotted form: /26 is 255.255.255.192. Each step longer in the prefix halves the block. Each step shorter doubles it.

Two sizes break the pattern. A /31 has two addresses and both are usable, which suits a link between two routers (RFC 3021). A /32 is a single address, used in routing tables and firewall rules.

Common IPv4 prefixes

PrefixSubnet maskUsable hostsWhere you see it
/8255.0.0.016,777,214The largest private range, 10.0.0.0/8
/12255.240.0.01,048,574The private range 172.16.0.0/12
/16255.255.0.065,534The private range 192.168.0.0/16
/20255.255.240.04,094A large site, or sixteen /24 networks under one route
/22255.255.252.01,022A busy office or guest Wi-Fi network
/23255.255.254.0510Two /24 networks joined together
/24255.255.255.0254Most home and small office networks
/25255.255.255.128126Half of a /24
/26255.255.255.19262A quarter of a /24
/27255.255.255.22430A small department or server group
/28255.255.255.24014A small server or management network
/29255.255.255.2486A small block of public addresses from a provider
/30255.255.255.2522A link between two routers
/31255.255.255.2542A point-to-point link with no broadcast address
/32255.255.255.2551One host, in routes and firewall rules

Private ranges

RFC 1918 sets aside three IPv4 blocks for private networks. They are never routed on the public internet, so anyone may use them at home or at work behind a router that translates addresses.

  • 10.0.0.0/8 runs from 10.0.0.0 to 10.255.255.255, about 16.7 million addresses.
  • 172.16.0.0/12 runs from 172.16.0.0 to 172.31.255.255, about 1 million addresses.
  • 192.168.0.0/16 runs from 192.168.0.0 to 192.168.255.255, which is 65,536 addresses. Most home routers hand out a /24 from this block.

Two more ranges look private but are not yours to assign. Providers use 100.64.0.0/10 for carrier-grade NAT, and a device gives itself an address in 169.254.0.0/16 when no DHCP server answers. In IPv6 the private equivalent is the unique local range fc00::/7.

Why IPv6 subnets are /64

An IPv6 address is 128 bits long. By convention the first 64 bits are the network and the last 64 identify the interface. Stateless address autoconfiguration (SLAAC), which is how most devices get an IPv6 address, depends on that split. Put a longer prefix on a LAN and devices that rely on it can no longer configure themselves.

Running out of host addresses is never the concern. One /64 holds 264 addresses, about 18 quintillion. Planning in IPv6 means counting networks instead. A provider often delegates a /56 or a /48 to a customer, which is 256 or 65,536 separate /64 networks. The exceptions are a /127 on a link between two routers (RFC 6164) and a /128 for a single address. IPv6 also has no broadcast address. Multicast does that job. The IPv4 vs IPv6 guide covers the other differences.

Common questions

Why can I not use two of the addresses in a subnet?

The first address names the network itself and the last is the broadcast address, so neither can go on a device. That is why a /24 has 256 addresses but 254 usable hosts. A /31 and a /32 are the exceptions: they have no network or broadcast address to give up.

What is the difference between a subnet mask and a wildcard mask?

They are inverses. A subnet mask has 1 bits over the network part, such as 255.255.255.192. A wildcard mask has 1 bits over the host part, such as 0.0.0.63. Router access lists and some routing protocol settings ask for the wildcard form. You can type either one after the address here.

How do I choose a prefix for a given number of devices?

Add two to the number of devices for the network and broadcast addresses, then find the smallest block that fits. Fifty devices need 52 addresses, and the next size up is 64, which is a /26 with 62 usable hosts. Leave room to grow, because renumbering a network later is slow work.

Do address classes still matter?

Not for routing. Classes A, B and C fixed the prefix at /8, /16 or /24 according to the first bits of the address. CIDR replaced that scheme in 1993, and any prefix length can now go with any address. The names survive as shorthand, so "a class C" usually just means a /24.