Skip to content

Subnet calculator

A subnet calculator turns an address and a CIDR prefix into the network details. Enter something like 192.168.1.0/26 to get the subnet mask, wildcard mask, network and broadcast addresses, the first and last usable host and the number of hosts. It works for IPv4 and IPv6, and shows the binary behind each answer.

Network parameters

Enter a network in CIDR notation

An address and prefix together, such as 10.0.0.0/8 or 2001:db8::/32.

Address and prefix

IPv4 or IPv6.

/24

Drag the slider to change the prefix.

Quick presets

Click a common prefix length to apply it.

Private: not routed on the internetWhat is the difference?

Subnet mask

255.255.255.0

Wildcard 0.0.0.255

Network address

192.168.1.0

Class C

Broadcast address

192.168.1.255

Last address in the block

Total addresses

256

8 host bits (2^8)

Usable host range

Addresses you can assign to hosts

First usable address

192.168.1.1

Lowest host address

Last usable address

192.168.1.254

Highest host address

Usable addresses

254

How many hosts you can assign in this block

The network and broadcast addresses are not assignable to hosts.

DHCP pool planner

DHCP hands out addresses to phones, laptops and other devices by itself. Set aside the addresses you give to devices by hand (the router, servers, printers), and see how many are left for DHCP.

Set aside:
Range 1

Left for DHCP

254 addresses

Nothing is set aside yet, so DHCP can use all 254 usable addresses.

Binary representation

The first bits of the address identify the network; the rest identify hosts.

IP address (192.168.1.20)

11000000.10101000.00000001.00010100

Subnet mask (255.255.255.0)

11111111.11111111.11111111.00000000

Network (192.168.1.0)

11000000.10101000.00000001.00000000

Bold = 24 network bitsGray = host bits

CIDR and classful analysis

Classful rules (RFC 791) compared with classless CIDR (RFC 4632)

Class

C · Classful default

Default /24

Relation to class

Exactly the class boundary

Scope

Private: not routed on the internet

Your address (192.168.1.20): Private (not routed on the internet) · RFC 1918

Classful address classes
ClassFirst octetLeading bitsDefaultMaskPurpose
Class A0 – 1270xxxxxxx/8255.0.0.0Large networks (0 and 127 are reserved)
Class B128 – 19110xxxxxx/16255.255.0.0Medium networks
Class C (this address)192 – 223110xxxxx/24255.255.255.0Small networks
Class D224 – 2391110xxxxn/aMulticastRFC 5771
Class E240 – 2551111xxxxn/aReservedRFC 1112
How it works

How to use the subnet calculator

Enter an IPv4 or IPv6 address and choose a prefix length, or paste a network in CIDR notation such as 10.0.0.0/8. The results update as you type: the subnet mask and wildcard, the network and broadcast addresses, the usable host range, a binary breakdown, the address class and what kind of range the address belongs to. The address bar always holds a link to your current calculation, so you can share it.

What a subnet mask and CIDR prefix mean

A prefix length such as /24 says that the first 24 bits of an address identify the network and the remaining bits identify hosts on it. The subnet mask 255.255.255.0 is simply those 24 one-bits written in dotted decimal; the wildcard mask is its inverse. An IPv4 block with a prefix of p contains 232 − p addresses, so a /24 holds 256. Classless Inter-Domain Routing (RFC 4632) replaced the old fixed classes with prefixes of any length.

Usable hosts, /31 and /32

In an ordinary IPv4 subnet the first address is the network address and the last is the broadcast address, so neither can be given to a host: usable hosts are the total minus two. Two prefixes are special. A /31 is a point-to-point link where both addresses are usable (RFC 3021), and a /32 is a single host.

Classful addressing, subnetting and supernetting

Before CIDR, addresses were grouped into classes A to E by their leading bits. The class is still a handy way to learn the numbers, so the calculator shows how your prefix compares with the class default: a longer prefix borrows host bits to make smaller subnets, and a shorter prefix aggregates networks into a supernet.

Public vs private IP addresses

Every device on a network needs an address. Some addresses are public: unique across the whole internet. Others are private: reserved for use inside one network, and reused by millions of networks at once. Knowing which is which explains why your home devices can share one internet connection, why you cannot reach a friend's laptop by its 192.168 address, and why planning a network takes care.

Public addresses

A public address is assigned to an internet provider or organization by a regional registry, so no one else uses it. Anyone on the internet can try to reach it (a firewall decides whether they succeed). When you visit a website, it sees your public address, which usually belongs to your internet provider and is shared by every device in your home. You can see yours on the home page.

Private addresses

Three blocks were set aside in RFC 1918 for private use. Routers on the public internet do not forward traffic to or from them, so the same private address can exist in many networks without conflict.

The three private IPv4 blocks
BlockCoversAddressesOften used for
10.0.0.0/810.0.0.0 to 10.255.255.25516,777,216Companies and cloud networks
172.16.0.0/12172.16.0.0 to 172.31.255.2551,048,576Mid-sized networks and Docker's defaults
192.168.0.0/16192.168.0.0 to 192.168.255.25565,536Home and small-office routers

Notice the middle block: it is 172.16 to 172.31 only. 172.15.x.x and 172.32.x.x are public. That narrow range is the most common source of mix-ups.

How private devices reach the internet

A private address cannot talk to the internet directly. Your router uses network address translation (NAT): it swaps each device's private address for the router's one public address on the way out, and swaps it back on the way in. That is why a whole household appears online as a single address, and why outside machines cannot start a conversation with a device behind the router unless you set up port forwarding.

Other reserved ranges

Some addresses are neither public nor the private ranges you choose yourself:

  • 100.64.0.0/10: shared address space that internet providers use between their customers and their own equipment (carrier-grade NAT).
  • 169.254.0.0/16: link-local. A device gives itself one of these when it cannot get an address, and it only works on that one link.
  • 127.0.0.0/8: loopback, meaning “this device”. 127.0.0.1 is localhost.
  • 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24: reserved for examples in documentation, never for real use.
  • 224.0.0.0/4 and 240.0.0.0/4: multicast (one sender, many receivers) and addresses held in reserve.

IPv6

IPv6 has so many addresses that it does not need NAT. The nearest thing to a private range is fc00::/7 (unique local addresses, in practice starting fd), meant for use inside one organization. Link-local addresses start fe80::/10, and public addresses are in 2000::/3. Private does not mean protected: what blocks outside traffic is a firewall, not the address.

Why a subnet can be “partly private”

A subnet is a whole range of addresses, not just the one you type. The calculator checks every address in the range. Take 172.20.1.1/8: the address itself is private, but a /8 starts at 172.0.0.0 and ends at 172.255.255.255, and only 172.16 to 172.31 of that is private. About 94% of it is public. Compare 172.20.1.1/16, which stays inside the private block and is entirely private. The same happens with 192.168.1.1/8 and 10.5.5.5/7.

To stay private, start from an address inside the block and use a prefix at least as long as the block: /8 or longer inside 10.x, /12 or longer for 172.16 to 172.31, and /16 or longer inside 192.168.

Mistakes this prevents

  • Using a public range inside a private network. Devices then cannot reach the real owner of those addresses.
  • Two networks that use the same private range cannot be joined over a VPN without renumbering one of them.
  • Assuming a subnet is safe to expose, or safe to ignore, because its first address looks private.

IPv6 subnets

IPv6 addresses are 128 bits long, so the numbers get very large; the calculator uses exact arithmetic and shows the full count. IPv6 has no broadcast address. A /64 is the standard size for a single LAN, a /127 is used for links between two routers (RFC 6164), and a /128 is a single address. The first and last address of the block are shown, along with the fully expanded form.

Common questions

How do I find the subnet mask from a CIDR prefix?

A prefix is the number of leading 1 bits in the mask. A /24 has 24 ones, so its mask is 255.255.255.0, and a /26 is 255.255.255.192. Enter an address with its prefix, such as 192.168.1.0/26, and the calculator shows the mask, the wildcard, the network and broadcast addresses and the usable range.

How many usable hosts does a subnet have?

An IPv4 subnet holds 2 to the power of (32 minus the prefix) addresses. Two are reserved, the network address and the broadcast address, so a /24 has 254 usable hosts. A /31 and a /32 are special cases that the calculator labels.

Does the calculator work for IPv6?

Yes. Enter an IPv6 address with a prefix such as 2001:db8::/48 to see the network, the first and last address and how many addresses the prefix holds. IPv6 has no broadcast address.

Related guides

All guides