Understanding IPv4 Subnetting

Internet Protocol version 4 or IPv4 was developed all the way back in 1981 and even though it's gradually being replaced by IPv6 it still plays a major role in networking worldwide. IPv4 uses a 32-bit address space which is equal to 4,294,967,296 unique addresses. Given that most people on Earth have at least one ethernet-capable device you would rightly assume that these addresses won't be enough but you have to remember that in 1981 only a couple hundred organizations had access to this technology. A solution was needed and subnetting came to the rescue.

Subnetting

Subnetting is the process of splitting a large network into multiple smaller ones. This is done in order to free up public IPs as well as improve security and reduce traffic by segmenting the network.

IPv4 addresses are 32 bits divided into four 8-bit numbers, called octets, separated by dots. Each octet ranges from 0 to 255.

The netmask follows the same pattern however instead of signifying a specific address it is used to determine the number of host bits in a given subnet.

To subnet a network effectively you will need to be able to convert the decimal numbers to binary as this will provide a clear view of the beginning and end of subnets.

This clear separation can be seen in the subnet mask which indicates what portion bits in a given address are host bits. Let's say that we want to convert the netmask of 255.255.255.224 to binary. We will divide each octet by 2 and every time there is a remainder we will write down only the whole number and the remainder as 1, if there is no remainder we write 0. As an example, I will use the last number of the octet 224:

So the binary equivalent to 224 is 11100000. We repeat this process for the rest of the octets and we get a binary netmask of 11111111.11111111.11111111.11100000. The zeros indicate the host which can be used for handing out IP addresses in a given network. If we add all the ones in this subset we will get the CIDR notation of /27 as there are 27 ones in the binary form of the netmask.

You will also need to be able to convert from binary to decimal. Let's say you want to convert the binary number 11010111 to decimal. As IP addresses are divided into 0ctets the highest possible decimal number of the most important bit will be 128. knowing this we can create the following table:

Under each of these numbers, you will place either one or a zero. The leftmost bit is the most significant the the rightmost is the least significant. We will begin placing the bits left to right

Now we will start adding all the decimal numbers with 1 underneath them and ignore the once with zeros. We get 128+64+16+4+2+1 which is 215

Practical example

We will use a practical example to help clear things up. Let's say that you have an internet cafe and a network of 7.18.128.0/25. You want to separate your client and staff networks. You need 50 client IPs and 20 staff IPs.

First, we need to make sure that this is possible. We need a total of 70 IPs. /25 means that there are 7 host bits available, 2^7 is equal to 128 however we remove 2 addresses as those are reserved for the gateway and broadcast which leaves us with 126 usable IPs.

Now to subnet the network. We will start with the largest subnet. Find the smallest range that satisfies the IP requirement. You can use this handy table:

We can see that the lowest range we can use is /26 which contains 62 hosts. The first usable IP is the gateway +1 which is 7.18.128.2. For the last usable we can, of course, just add 60 and get 7.18.128.62 but there is also a way to find this in binary. We have the subnet address in binary which in this case is 00000111.00010010.10000000.00000000 and we have the subnet's netmask which is 11111111.11111111.11111111.11000000. Now to get the last IP place the two addresses under one another

Subnet IP   | 00000111 | 00010010 | 10000000 | 00000000  |
Netmask     | 11111111 | 11111111 | 11111111 | 11000000  |

Leave all the network bits(the ones that correspond to 1 in the netmask) untouched and turn all the host bits to 1 which leaves us with an address that looks like this 00000111.00010010.10000000.00111111 which is 7.18.128.63 or the broadcast address.

Now for the smaller staff network, we can see that a /27 which contains 30 hosts will suffice. We take the last IP of our last subnet and we add one to it to get the subnet 7.18.128.64/27. The first address will be gateway +1 or 7.18.128.65 and the last 7.18.128.94

Conclusion

Subnetting remains a fundamental skill for network engineers, VPS administrators, and anyone managing multiple systems or virtual machines.
It helps divide networks efficiently, conserve IPv4 space, and improve both routing performance and security. Even as IPv6 adoption grows, understanding IPv4 subnetting is critical for modern infrastructure — especially in environments that still rely heavily on IPv4 addressing.

If you’re managing your own networks or need an environment to test real-world subnetting, routing, or BGP setups, our Dedicated Servers and High-Performance VPS plans give you full control over IP management, private networking, and custom configurations — perfect for hands-on networking and system administration work.