How to Calculate an IPv4 Subnet (Without Memorizing Tables)

Subnetting looks intimidating because many explanations start with a wall of tables: one for each prefix length, one for each mask, and one for each block size. You do not need to memorize those tables to work out a subnet. If you understand a small number of ideas and one reliable method, you can calculate the network address, the broadcast address, the usable range, and the number of addresses for the subnets you meet in everyday home and office networks. This guide shows that method, step by step, and then applies it to a complete worked example.

The goal is not to turn you into a network engineer in one sitting. The goal is to give you a repeatable process you can use whenever you see an address written like 192.168.1.0/24, or whenever a router, a cloud panel, or a tutorial asks you to choose a subnet. Once you can do the calculation by hand, a calculator becomes a checking tool rather than a mystery box. You will know what the answer should look like, and you will notice when a result does not make sense.

What an IPv4 Address and a Subnet Really Are

An IPv4 address has 32 bits, written as four decimal numbers separated by dots. Each number, called an octet, can range from 0 to 255. An example is 192.168.1.10. On its own, that address does not tell you which part identifies the network and which part identifies a particular device on that network. The subnet prefix, written after a slash, supplies that missing information.

In the notation 192.168.1.0/24, the number after the slash is the prefix length. It says that the first 24 bits belong to the network portion and the remaining 8 bits belong to the host portion. Because 32 minus 24 equals 8, there are 8 host bits. That single subtraction is the key to most of the calculation. The prefix length tells you how many bits are fixed for the network, and the rest can vary for devices inside that network.

A subnet is simply a range of addresses that share the same network portion. Devices in the same subnet can normally reach each other directly, while devices in different subnets need a router to pass traffic between them. When you set up a home router, a virtual private network, a cloud virtual network, or a small office network, you are choosing a subnet even if the interface hides the details behind a dropdown menu.

The subnet mask is another way to write the same idea. For a /24 network, the mask is 255.255.255.0. The 255 values mark the network portion, and the 0 marks the host portion. You do not need to memorize every mask. If you know the prefix length, you can work out the number of host bits, and from there you can work out the size of the subnet.

How to Calculate a Subnet in Four Steps

Use the same four steps every time. The consistency matters more than speed. When you follow the same order, you are less likely to mix up the network address and the broadcast address, or to forget to remove the two reserved addresses from the usable count.

Step 1: Find the number of host bits

Subtract the prefix length from 32. For a /24 network, 32 minus 24 equals 8 host bits. For a /25 network, there are 7 host bits. For a /23 network, there are 9 host bits. Write this number down. It controls everything that follows.

Step 2: Find the total number of addresses

Raise 2 to the power of the number of host bits. For 8 host bits, 2 to the power of 8 equals 256 addresses. That is why a /24 network has 256 addresses in total. For 7 host bits, the total is 128 addresses. For 9 host bits, the total is 512 addresses. You do not need a table if you remember this one relationship: each extra host bit doubles the size of the subnet, and each fewer host bit halves it.

Step 3: Find the network and broadcast addresses

The network address is the first address in the range. It identifies the subnet itself and is not normally assigned to a device. The broadcast address is the last address in the range. It is used to send a message to every device on that subnet, and it is also not normally assigned to a device. For a simple /24 example that starts on a round boundary, the network address ends in 0 and the broadcast address ends in 255. For other prefixes, you need to find the block size and the starting boundary, which is covered in the worked example section below.

Step 4: Find the usable range

Subtract 2 from the total number of addresses to get the number of usable host addresses. The 2 accounts for the network address and the broadcast address. For a /24 network, 256 minus 2 equals 254 usable addresses. The usable range runs from one address above the network address to one address below the broadcast address. In a typical /24 network, that range is from the address ending in 1 to the address ending in 254.

A useful habit is to write your answer in one line before you move on: network, first usable, last usable, broadcast, and total addresses. That one line makes it easy to check your work and to compare your answer with a calculator. If any part of the line looks impossible, such as a first usable address that is lower than the network address, you know to repeat the steps.

Worked Example: 192.168.1.0/24

Let us apply the method to the address given in the title example: 192.168.1.0/24. This is a common home and small-office range, and it is a good starting point because the boundaries are easy to see.

First, find the host bits. The prefix length is 24, so 32 minus 24 equals 8 host bits. Next, find the total number of addresses. Two to the power of 8 equals 256 addresses. Those are the two facts that shape the whole answer.

The network address is 192.168.1.0. That is the first address in the range and the address that names the subnet. The broadcast address is 192.168.1.255. That is the last address in the range. The usable range runs from 192.168.1.1 to 192.168.1.254. That gives 254 usable addresses, which is 256 minus the network and broadcast addresses.

In practice, a router often takes the first usable address, such as 192.168.1.1, as its gateway address. Other devices then receive addresses from the rest of the range, either by manual assignment or automatically. If you ever wonder why a device cannot use 192.168.1.0 or 192.168.1.255 as its own address, this is the reason: those two addresses are reserved for the network and broadcast functions.

Now consider a slightly less round case, so the method does not depend on a /24 example. Take 192.168.1.0/25. Here there are 7 host bits, so the total is 128 addresses. The first /25 block runs from 192.168.1.0 to 192.168.1.127, with a broadcast address of 192.168.1.127 and usable addresses from 192.168.1.1 to 192.168.1.126. The second /25 block runs from 192.168.1.128 to 192.168.1.255, with a broadcast address of 192.168.1.255 and usable addresses from 192.168.1.129 to 192.168.1.254. Notice how the block size, 128, tells you where each block starts. The same idea works for other prefixes: the block size is the total number of addresses in the subnet, and blocks start at multiples of that size in the octet where the boundary falls.

For a /23 example, there are 9 host bits, so the total is 512 addresses. A /23 block covers two adjacent /24 ranges, such as 192.168.0.0 to 192.168.1.255. Its network address is 192.168.0.0, its broadcast address is 192.168.1.255, and its usable range is 192.168.0.1 to 192.168.1.254. That is 510 usable addresses. This example shows why you should not assume that a subnet always ends at 255 in the last octet in the way a /24 does. The range can span more than one value in the third octet when the prefix is shorter than 24.

Checking Your Work With a Calculator

After you calculate by hand, check your answer with a subnet calculator. Enter the same address and prefix, then compare the network address, broadcast address, usable range, total addresses, and subnet mask. If the calculator agrees, your method is working. If it disagrees, slow down and check each step: the host-bit subtraction, the power of two, and the starting boundary. Most errors come from using the wrong prefix length, starting a block at the wrong boundary, or forgetting to subtract the two reserved addresses.

A calculator is also useful when the boundary falls in an earlier octet, such as a /16 network, where the arithmetic is still the same but the ranges are larger. The method does not change. Only the numbers get bigger. For a /16 network, there are 16 host bits, so there are 65,536 total addresses and 65,534 usable addresses. That is a useful reminder that a short prefix can describe a very large range, and that you should choose a prefix that fits the number of devices you actually need.

Common Mistakes to Avoid

One common mistake is treating the network address as a usable device address. Another is treating the broadcast address as a usable device address. A third is assuming that every subnet has 254 usable addresses. That is only true for a /24 network. A /25 network has 126 usable addresses, a /26 network has 62, and a /23 network has 510. The usable count always follows from the host bits.

Another mistake is mixing up the subnet mask and the wildcard mask, or copying a mask from an example without checking that it matches the prefix in your own network. If you are given a mask such as 255.255.255.192, convert it to a prefix by counting the network bits, or check it with a calculator, rather than guessing. A related mistake is applying a /24 habit to a network that is not a /24. Always read the prefix in the address you are working with, not the prefix from a similar example.

Limitations

This hand method works well for the common IPv4 cases, but it has limits. First, it describes address ranges, not routing, firewalls, or performance. Knowing that two devices are in the same subnet does not guarantee that they can communicate. A firewall rule, a virtual local area network setting, or a device that is switched off can still block traffic.

Second, do not use subnet math for IPv6. IPv6 addresses are 128 bits long, use hexadecimal notation, and use a different set of conventions for allocation and interface addressing. The idea of a prefix still exists, but the arithmetic, the address format, and the practical guidance are different. If you apply IPv4 habits to IPv6, you are likely to get the wrong answer. Use an IPv6-specific guide or calculator for IPv6 ranges.

Third, special cases exist. Very small subnets, such as /31 and /32, have different rules for usable addresses, and they are used for specific purposes such as point-to-point links and single-host routes. This guide focuses on the ordinary subnets you meet in home and office networks. If you are working with /31 or /32, follow the documentation for that specific use case and test the configuration before relying on it.

Finally, a subnet calculation does not tell you whether an address range is public or private, or whether it is already in use. Private ranges such as 192.168.0.0/16, 10.0.0.0/8, and 172.16.0.0/12 are commonly used inside local networks, while public addresses are assigned by other means. Before you choose a range for a real network, check that it does not conflict with a range already in use in that environment.

Frequently Asked Questions

How many addresses are in a /24 subnet?

A /24 subnet has 256 addresses in total. Two of those are reserved for the network and broadcast addresses, so there are 254 usable host addresses. For the example 192.168.1.0/24, the usable range is 192.168.1.1 to 192.168.1.254.

What is the broadcast address for 192.168.1.0/24?

The broadcast address is 192.168.1.255. It is the last address in the range. It is not normally assigned to a single device, because it is used for messages intended for every device on that subnet.

Can I use the network address for a device?

No, not in an ordinary subnet. The network address, such as 192.168.1.0 in a /24 network, identifies the subnet itself. Assigning it to a device can cause confusion and connectivity problems. Use an address inside the usable range instead.

Does this method work for IPv6?

No. Do not use IPv4 subnet math for IPv6. IPv6 uses 128-bit addresses and different conventions. Use an IPv6-specific calculator or guide when you work with IPv6 ranges, and keep the two systems separate in your notes.

With a little practice, subnetting becomes a short checklist rather than a memorization test: subtract to find the host bits, raise 2 to that power, find the network and broadcast addresses, and subtract 2 for the usable count. Write the answer in one line, check it with a calculator, and you will have a result you can trust.