IP Subnet Calculator

IPv4 & IPv6 subnet calculator. Free subnet calculator (CIDR, range).

Try

Rate this tool

How useful was this tool?

IP Subnet Calculator

Type an address into Address with prefix and the whole subnet is worked out: the network, the usable hosts, the masks, what kind of address it is, the bits, the subnets around it and how it splits. Any usual spelling works:

  • 192.168.1.10/24
  • 10.0.0.0 255.0.0.0, an address with a dotted mask
  • a wildcard mask such as 0.0.0.255
  • [2001:db8::1]/48, an IPv6 address in brackets, or with a zone id
  • ::ffff:192.0.2.1, an IPv4 address embedded in IPv6

You can also give the mask separately in Mask or prefix, as 24, 255.255.255.0 or 0.0.0.255. The Try examples fill in typical cases, from a home network to a link-local IPv6 address. The Range to CIDR tab does the opposite: it turns a range of addresses into the blocks that cover it.

Example: 172.16.5.4/22

The result opens with a one-line summary: 172.16.4.0/22 is a network of 1,024 addresses, 1,022 usable, from 172.16.4.1 to 172.16.7.254.

Network address 172.16.4.0
Broadcast address 172.16.7.255
First and last usable host 172.16.4.1 to 172.16.7.254
Usable hosts 1,022 of 1,024 (2^10)
Subnet mask 255.255.252.0 (hex 0xFFFFFC00)
Wildcard mask 0.0.3.255
Host bits 10

Notice that the network isn’t 172.16.5.0, even though the address starts with 172.16.5. A /22 is four /24s long, and 172.16.5.4 sits in the block that starts at 172.16.4.0. It’s address 260 of 1,024, counting from 0.

Around it gives the neighbours: the previous /22 is 172.16.0.0/22, the next is 172.16.8.0/22, and one bit shorter, the supernet, is 172.16.0.0/21. Each is clickable.

How the numbers are worked out

The prefix says how many bits, from the left, belong to the network. An IPv4 address has 32 bits, so a /22 leaves 10 host bits, and 2^10 = 1,024 addresses. The bits section shows it directly, network bits and host bits in different colours:

Address    10101100.00010000.00000101.00000100   172.16.5.4
Mask       11111111.11111111.11111100.00000000   255.255.252.0
Network    10101100.00010000.00000100.00000000   172.16.4.0
Broadcast  10101100.00010000.00000111.11111111   172.16.7.255

The network address is the address with every host bit set to 0. The broadcast address has every host bit set to 1. The subnet mask is the prefix written out as ones and zeros. The wildcard mask is its opposite, the form Cisco access lists and OSPF use.

Usable hosts, /31 and /32

In an ordinary IPv4 subnet, the network and broadcast addresses can’t be given to a device, which is why a /22 has 1,022 usable hosts and a /24 has 254. Only the first and last addresses of the whole block are reserved. In 172.16.4.0/22, the addresses 172.16.5.0 and 172.16.5.255 are ordinary, usable hosts.

Two sizes are exceptions, and the calculator handles both:

  • /31 has two addresses, and both are usable. It’s the standard for point-to-point links between two routers, where a broadcast address makes no sense. Try 203.0.113.9/31.
  • /32 is one single host: a server’s own address in a firewall rule, or a loopback.

What kind of address it is

The address card checks the address against IANA’s list of special-purpose ranges. 172.16.5.4 is private (RFC 1918): never routed on the internet, and free to use inside any network. The private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.

Others you’ll meet:

  • Carrier-grade NAT (100.64.0.0/10): used by internet providers that share one public address between customers.
  • Loopback (127.0.0.0/8) and link-local (169.254.0.0/16), the address a device gives itself when no DHCP server answers.
  • Documentation (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24): reserved for examples like the ones on this page.
  • Benchmarking (198.18.0.0/15), multicast and reserved ranges.
  • For IPv6: unique local (fc00::/7, IPv6’s private range), IPv4-mapped, NAT64, 6to4, Teredo, discard and ORCHID.

The card also shows the address as a single number (2,886,731,012, or 0xAC100504 in hex), which is how databases and firewalls often store it.

It shows the historical class too: Class B, because the first number is between 128 and 191. Classes stopped mattering in 1993, when classless routing (CIDR) replaced them. They’re shown because exams and old documentation still mention them.

Splitting a network

Split into smaller subnets divides the network into equal parts. Choose a size under Into, and you get the count and a table. Splitting 172.16.4.0/22 into /24 gives 4 subnets of 254 usable hosts each, 172.16.4.0/24 to 172.16.7.0/24.

Subnet sizes always come in powers of two. Each bit longer halves the size, and each bit shorter doubles it. When planning, leave room to grow: a subnet for 100 devices is a /25 (126 usable), and a /24 gives you headroom.

Is an address inside? tests any address against the network. It’s handy for a firewall rule or an allowlist, when you need to know whether 172.16.7.200 falls inside 172.16.4.0/22. It does.

Reverse DNS names and zones

Every address has a reverse DNS name, used to look up the name behind it. For 172.16.5.4 it’s 4.5.16.172.in-addr.arpa: the numbers reversed, with .in-addr.arpa added.

Reverse DNS is delegated in whole numbers of the address. A /24 is exactly one reverse zone (5.16.172.in-addr.arpa), so a /22 is covered by four of them. Blocks smaller than a /24, such as a /27 from a hosting provider, don’t fill a zone of their own. They’re delegated “classless”, by the method in RFC 2317, which is why customers with small blocks usually ask their provider to set reverse DNS. IP to Hostname shows who runs the reverse zone for any address.

IPv6 subnets

IPv6 works on the same principle with 128 bits. 2001:db8:abcd:12::1/64 gives:

2001:db8:abcd:12::/64 holds 18,446,744,073,709,551,616 addresses (2^64), from 2001:db8:abcd:12:: to 2001:db8:abcd:12:ffff:ffff:ffff:ffff.

A few things differ from IPv4:

  • No broadcast address and no reserved first and last address. Every address in the prefix can be used.
  • A /64 is the normal size for one network. It’s the smallest one that devices can configure themselves in (SLAAC), so there’s no point in going smaller for ordinary networks.
  • Larger blocks are counted in /64s. A /48, a typical allocation for a site, holds 65,536 /64 networks, or 256 /56s, the size many providers give each home customer. The calculator shows these counts.
  • Compressed and expanded forms. 2001:db8:abcd:12::1 is short for 2001:0db8:abcd:0012:0000:0000:0000:0001. Both are shown, each copyable.

The address card also splits the address into its parts. The subnet field (0012, bits 48 to 63) numbers the networks inside a /48. The interface identifier (0000:0000:0000:0001) is the part chosen for the device.

Some interface identifiers give away more than expected. On fe80::1a2b:3cff:fe4d:5e6f, the ff:fe in the middle shows the identifier was built from the network card’s hardware address, and the calculator recovers it: 18:2b:3c:4d:5e:6f. That’s why modern systems use random identifiers instead.

Transition addresses carry an IPv4 address inside them. For IPv4-mapped, NAT64, 6to4 and Teredo addresses, the calculator shows that IPv4 address, along with the server and client for Teredo. For multicast addresses, it shows their scope.

Range to CIDR

The second tab answers a question that comes up with firewalls and cloud allowlists: a list of addresses runs from one address to another, so which CIDR blocks cover exactly that range? For example, 192.168.1.10 to 192.168.1.20 needs four blocks:

192.168.1.10/31
192.168.1.12/30
192.168.1.16/30
192.168.1.20/32

It works for IPv4 and IPv6, and the whole list copies in one click.

FAQ

What is CIDR notation?

An address followed by a slash and the number of network bits, such as 192.168.1.0/24. It replaced the old class system in 1993 and lets networks be any power-of-two size.

How many usable hosts are in a /24?

254: 256 addresses minus the network and broadcast addresses. A /25 has 126, a /26 62, a /27 30, a /28 14, a /29 6 and a /30 2.

What’s the difference between a subnet mask and a wildcard mask?

They’re the same information inverted. The mask 255.255.255.0 marks the network bits with ones, and the wildcard 0.0.0.255 marks the host bits. Wildcards are used in Cisco access lists and routing configurations.

Which private range should I use for a new network?

Any of the three works. To avoid conflicts when connecting over a VPN, steer clear of the most common home ranges, 192.168.0.0/24 and 192.168.1.0/24, and pick something less likely to overlap, such as a block inside 10.0.0.0/8.

Note: All processing is done client-side. We do not store or see your data.

Related Tools

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us