Skip to content
SubnettingCalculator
IPv4 Detecting…
IPv6 Detecting…

Subnet Calculator – Free Online IPv4 & CIDR Calculator

Use this free subnet calculator to find the network address, broadcast address, first and last usable IP, number of hosts, subnet mask and wildcard mask for any IPv4 address and CIDR prefix. It is made for network engineers, system admins and students preparing for CCNA, and everything runs in your browser.

IPv4 Subnet Calculator

Enter an IPv4 address and a subnet mask, or drag the CIDR slider. The details update as you type.

/24

Subnet Details

What is a subnet calculator?

A subnet calculator does the binary side of subnetting for you. Give it an IPv4 address and a mask, or a prefix such as /24, and it works out the subnet that address belongs to: where it starts, where it ends and how many devices fit inside.

For every address you get the network and broadcast addresses, the first and last host you can really assign, the host count, the subnet and wildcard masks, the mask in binary, and what kind of address it is (private, public, loopback and so on).

People use it when they're splitting up an office or lab network, writing a firewall or ACL rule, checking whether two machines can talk without a router, or practising for an exam like CCNA. Working one out by hand is great practice. Working out twenty in a row is where a calculator pays off.

How to use this calculator

It takes about ten seconds once you've done it once. There are only a few steps.

1Enter the IP address

Type the address in the first box, for example 192.168.0.1. That's four numbers between 0 and 255, separated by dots. The box only takes digits and dots (a comma is turned into a dot, which helps on phone keyboards). If something's off, like 256 or a leading zero such as 01, the field turns red and tells you what's wrong. IPv6 addresses aren't supported.

2Set the subnet size

Either type a mask such as 255.255.255.0, or drag the CIDR slider anywhere from 0 to 32. The two are linked, so changing one updates the other. A bigger CIDR number means a smaller subnet.

Shortcut: if you already have the address in slash form, like 10.0.5.17/22, paste it into the address box. The calculator splits it into address, CIDR and mask for you.
3Read the results

The table refreshes with every keystroke. Network Address is the first address in the subnet and Broadcast Address is the last. Neither can go to a normal device, so the range you can actually hand out runs from First Usable IP to Last Usable IP.

Total Usable Hosts is how many devices you can place in the subnet. Total Available Hosts is the raw count of addresses, network and broadcast included.

Subnet Mask and Wildcard Mask are opposites. Routers and firewalls tend to want the wildcard form in ACLs and OSPF statements. Binary Subnet Mask shows the same mask as 1s and 0s, which is handy for checking your own working. IP Type says whether the address is private, public, loopback, multicast and so on, along with its old class.

4Copy or download

Copy puts the whole table on your clipboard as plain text. Download saves it as a CSV file that opens in Excel or Google Sheets. Both buttons stay greyed out while the address or mask has an error.

Common slip-ups

  • The mask is rejected. A valid mask is a block of 1s followed by a block of 0s. 255.255.255.0 works, 255.0.255.0 doesn't.
  • The host count looks two short. That's on purpose. A /24 has 256 addresses but only 254 can go to devices.
  • The table is empty. Look for a red message under the address or mask box.

How the subnet maths works

An IPv4 address is just a 32-bit number. The mask splits it in two: the 1s mark the network part and the 0s mark the host part. Every result on this page comes from a handful of operations on those bits.

Network address = IP address AND subnet mask Wildcard mask = NOT subnet mask (flip every bit) Broadcast address = Network address OR wildcard mask = Network address + Total addresses - 1 First usable IP = Network address + 1 Last usable IP = Broadcast address - 1 Total addresses = 2 ^ (32 - CIDR) Usable hosts = Total addresses - 2

There are two ways to reach the broadcast address, and they always agree. The bitwise way sets every host bit to 1, which is what the OR with the wildcard mask does. The shortcut adds the address count minus one to the network address: 192.168.0.0 + 255 = 192.168.0.255.

Worked example: 192.168.0.1/24

A /24 means the first 24 bits of the mask are 1s. Start by writing the address and the mask in binary:

IP address 192.168.0.1 = 11000000.10101000.00000000.00000001 Subnet mask 255.255.255.0 = 11111111.11111111.11111111.00000000

AND the two lines together, keeping a 1 only where both lines have a 1. That gives the network address:

11000000.10101000.00000000.00000000 = 192.168.0.0

Flip every bit of the mask to get the wildcard mask:

00000000.00000000.00000000.11111111 = 0.0.0.255

OR the network address with the wildcard mask. Every host bit becomes a 1, and that's the broadcast address:

11000000.10101000.00000000.11111111 = 192.168.0.255

Last, count the hosts. 32 minus 24 leaves 8 host bits, so the block holds 28 = 256 addresses. Take away the network and broadcast addresses and 254 are left, running from 192.168.0.1 to 192.168.0.254.

Here's the same example in the calculator's own result table. It's built by the same code as the calculator above, so the two always match.

Why subtract 2?

The first address names the subnet and the last one is the broadcast address, so neither can go to a host. That's the whole reason for the minus 2. Two prefixes break the rule. A /31 is meant for point-to-point links between two routers (RFC 3021), so both addresses are usable and there's no broadcast. A /32 is one single host address.

IPv4 CIDR chart (/0 to /32)

Every prefix length from /0 to /32 with its subnet mask, wildcard mask and address counts. Usable hosts are the total minus 2, apart from /31 (2) and /32 (1).

CIDRSubnet maskWildcardTotal addressesUsable hosts

Standard IPv4 classes

Early IPv4 sorted addresses into classes by their first number, and each class came with a fixed mask. CIDR replaced that scheme in the 1990s, so you can use any prefix length today. Class names still turn up in textbooks, exams and some vendor docs, which is why they're listed here.

ClassFirst numberIP rangeDefault maskCIDRNetworksHosts per networkUsed for
A1 – 1261.0.0.0 – 126.255.255.255255.0.0.0/812616,777,214Very large networks
–127127.0.0.0 – 127.255.255.255Not used–––Loopback (reserved)
B128 – 191128.0.0.0 – 191.255.255.255255.255.0.0/1616,38465,534Medium networks
C192 – 223192.0.0.0 – 223.255.255.255255.255.255.0/242,097,152254Small networks
D224 – 239224.0.0.0 – 239.255.255.255Not used–––Multicast
E240 – 255240.0.0.0 – 255.255.255.255Not used–––Reserved for research

Class A stops at 126 because 0.0.0.0/8 means "this network" and 127.0.0.0/8 is loopback. Neither counts as a normal Class A network.

Private and special IPv4 ranges

These blocks are reserved for particular jobs. The second column shows the first and last address in each one.

RangeIP rangeTotal addressesPurpose
10.0.0.0/810.0.0.0 – 10.255.255.25516,777,216Private (RFC 1918)
172.16.0.0/12172.16.0.0 – 172.31.255.2551,048,576Private (RFC 1918)
192.168.0.0/16192.168.0.0 – 192.168.255.25565,536Private (RFC 1918)
100.64.0.0/10100.64.0.0 – 100.127.255.2554,194,304Shared address space (carrier-grade NAT)
127.0.0.0/8127.0.0.0 – 127.255.255.25516,777,216Loopback
169.254.0.0/16169.254.0.0 – 169.254.255.25565,536Link-local (APIPA)
224.0.0.0/4224.0.0.0 – 239.255.255.255268,435,456Multicast

Frequently asked questions

What is CIDR notation?

CIDR is a shorthand for a subnet mask. You write a slash and a number after the address, and the number says how many bits at the start are the network part. So /24 is the same thing as 255.255.255.0, and /16 is 255.255.0.0.

What is a subnet mask?

It tells a device which part of an IP address identifies the network and which part identifies the host. Bits set to 1 belong to the network, bits set to 0 belong to the host. With 255.255.255.0, the first three numbers are the network and the last one is the device.

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

A wildcard mask is the subnet mask turned inside out: every 1 becomes a 0 and every 0 becomes a 1. The mask 255.255.255.0 turns into 0.0.0.255. You'll run into wildcard masks in Cisco access lists and OSPF network commands.

How do I find the broadcast address?

Set every host bit in the network address to 1. The quick way is to add the block size minus one to the network address. 192.168.0.0/24 holds 256 addresses, so 192.168.0.0 + 255 gives 192.168.0.255. OR-ing the network address with the wildcard mask gives the same answer.

Why do we subtract 2 from the number of hosts?

One address in every subnet is used to name it (the network address) and one is used to talk to everybody on it (the broadcast address). Neither can go to a normal device, so usable hosts = total addresses minus 2.

How many usable hosts are in a /24, /25, /26, /27, /28, /29 and /30?

A /24 has 254 usable hosts, a /25 has 126, a /26 has 62, a /27 has 30, a /28 has 14, a /29 has 6 and a /30 has 2. The CIDR chart on this page lists every prefix.

What are /31 and /32 subnets?

A /31 is for a link between exactly two devices, usually two routers (RFC 3021). Both addresses can be used and there's no broadcast address. A /32 is a single address, often used for a loopback interface or a host route.

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

Write down that many 1s, pad with 0s up to 32 bits, split the result into four groups of eight and convert each group to decimal. For /26 you get 11111111.11111111.11111111.11000000, which is 255.255.255.192. Or drag the slider and read the mask off the screen.

How do I convert a subnet mask to a CIDR number?

Count the 1 bits. 255.255.255.192 has 26 of them, so it's /26. If you type the mask into the calculator, the slider jumps to the matching number.

How can I tell if two IP addresses are in the same subnet?

Apply the same mask to both addresses and compare the network addresses you get. If they match, the two hosts share a subnet. With /24, both 192.168.1.10 and 192.168.1.200 land in 192.168.1.0, so they do.

Which IPv4 ranges are private?

Three blocks are private under RFC 1918: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Homes, offices and data centres use them internally, and they aren't routed on the public internet.

What do IP class and IP type mean in the results?

The class depends on the first number: A for 1 to 126, B for 128 to 191, C for 192 to 223, D (multicast) for 224 to 239 and E (reserved) for 240 to 255. The numbers 0 and 127 are set aside for "this network" and loopback, so they get no class. Classes are mostly history now that CIDR has taken over. The type tells you whether the address is private, public, loopback, link-local, multicast or reserved.

Can I paste an address with its CIDR, like 10.0.5.17/22?

Yes. Paste something like 10.0.5.17/22 into the IP address box and the calculator fills in the address, the CIDR number and the mask for you.

Why does the calculator reject my subnet mask?

A valid mask is a run of 1s followed by a run of 0s, with nothing mixed in. 255.0.255.0 looks believable but breaks that rule. Try 255.255.255.0, or use the slider so you can't get it wrong.

Does this calculator support IPv6?

Not yet. The calculator only handles IPv4. The strip at the top of the page can still show your own IPv6 address if your connection has one.

Are my inputs sent anywhere?

No. The subnet maths runs in your browser and what you type isn't sent anywhere. The only outside requests come from the strip at the top of the page, which asks a few public services for your own IP address and rough location.