An IP address is a logical identification number of a computer on the network, or of a network or subnet. IPv4 addresses are 32 bits in dotted decimal format, not to be confused with the MAC address that is represented in hexadecimal notation separated by colons or hyphens. IP addresses can change dynamically, both at the public and private IP addressing level, although it could also be the case that it is fixed. Subnetting is the technique of dividing a large network into smaller networks (subnets), to calculate which subnet mask we will need to use in the new network, we will have to calculate different parameters. Today in this article we are going to show you how we can do subnetting easily and quickly, both “manually” and also using IP calculators that will make our lives easier.

What is subnetting, types and classes of addresses
Subnetting consists of dividing a large network into several smaller subnets, this must be done with great care and planning so as not to waste IPv4 addresses. Generally, subnetting is done locally, using the private IP addressing range that we have available for our use without limitations, however, subnetting can also be done for public IP addressing, as long as you work or have your own operator and your own range of public IP addresses to use. In this tutorial we are going to work specifically with private IP addressing in all the examples.
There are many reasons for wanting to divide a large network into several smaller networks, such as:
- Expand or reduce the range of IP addresses on the local network . If we have a very large network, we may want to reduce the number of available IP addresses, in order to manage them more easily.
- Network optimization : a very large network could have a lot of broadcast traffic, this makes the network much slower.
- Improve the organization of the entire network : we can divide a very large network into smaller subnets, to use each subnet for a specific audience. For example, we could create a subnet for management, administration, sales teams, a subnet for guests, etc.
- Greater security and traffic control : by dividing into small subnets, we can adequately segment our network into VLANs (level 2) and use different IP addressing (level 3) to allow or deny traffic between the different computers. Thanks to subnetting or subnetting, network administrators can more easily manage all incoming and outgoing traffic.
Once we have seen what subnetting is and all its advantages, we are going to talk about the different types of IPv4 addresses that exist.
Types of IPv4 addresses
In IPv4 networks there are a total of three types of IP addresses, each type of IP address is oriented to a certain task, these IP addresses are:
- Network address : is the IP address that the network or subnet refers to. To calculate the network address, it is necessary to perform the AND operation between an IP address oriented to the hosts (computers, servers) and the configured subnet mask. The network address is the one that your routers include in their routing tables, to know how to get to a certain destination, and to know what is the origin of a certain packet.
- Host address : these are the IP addresses assigned to the end computers on the network. A computer, printer, or smartphone will have a host IP address.
- Broadcast address : it is a special address, it is used to send data to all hosts within a network. The broadcast address within a subnet is always the last IP address. There is also a special broadcast address when we have not yet obtained IP addressing from the DHCP server, or from the network administrator manually, this special address is 255.255.255.255.
Most of us in our homes have a router that has the IP address 192.168.1.1, and the computers that connect to the network have addresses 192.168.1.2 through 192.168.1.254 usually. A 255.255.255.0 subnet mask is being used on all of these hosts. All these IP addresses are host addresses, the network address can be calculated by doing the operation (192.168.1.1 AND 255.255.255.0), which results in 192.168.1.0, therefore, the network address is 192.168.1.0. As for the broadcast address, it is the last address on the network, therefore, in this case the broadcast address is 192.168.1.255.
The subnet mask plays a fundamental role when subnetting, because it will tell us which bits belong to the network part and which one belongs to the hosts part. The subnet mask determines the network IP address, the range of IP addresses for the hosts, and also the broadcast IP address. The subnet mask can be expressed in binary, in dotted decimal as an IP address, and also in CIDR notation. The CIDR notation is basically the number of 1 that we have from left to right in the subnet mask in binary notation. In the following table you can see all the subnet masks in binary, decimal and CIDR notation, in addition, you can also see the maximum number of hosts depending on the subnet mask.
| Binary | Decimal | CIDR notation |
|---|---|---|
| 11111111.11111111.11111111.11111111 | 255.255.255.255 | / 32 |
| 11111111.11111111.11111111.11111110 | 255.255.255.254 | / 31 |
| 11111111.11111111.11111111.11111100 | 255.255.255.252 | / 30 |
| 11111111.11111111.11111111.11111000 | 255,255,255,248 | / 29 |
| 11111111.11111111.11111111.11110000 | 255,255,255,240 | / 28 |
| 11111111.11111111.11111111.11100000 | 255,255,255,224 | / 27 |
| 11111111.11111111.11111111.11000000 | 255,255,255,192 | / 26 |
| 11111111.11111111.11111111.10000000 | 255 255 255 128 | / 25 |
| 11111111.11111111.11111111.00000000 | 255.255.255.0 | / 24 |
| 11111111.11111111.11111110.00000000 | 255.255.254.0 | /2. 3 |
| 11111111.11111111.11111100.00000000 | 255.255.252.0 | / 22 |
| 11111111.11111111.11111000.00000000 | 255.255.248.0 | /twenty-one |
| 11111111.11111111.11110000.00000000 | 255.255.240.0 | /twenty |
| 11111111.11111111.11100000.00000000 | 255.255.224.0 | / 19 |
| 11111111.11111111.11000000.00000000 | 255.255.192.0 | / 18 |
| 11111111.11111111.10000000.00000000 | 255.255.128.0 | / 17 |
| 11111111.11111111.00000000.00000000 | 255.255.0.0 | / 16 |
| 11111111.11111110.00000000.00000000 | 255.254.0.0 | /fifteen |
| 11111111.11111100.00000000.00000000 | 255.252.0.0 | / 14 |
| 11111111.11111000.00000000.00000000 | 255.248.0.0 | / 13 |
| 11111111.11110000.00000000.00000000 | 255.240.0.0 | / 12 |
| 11111111.11100000.00000000.00000000 | 255.224.0.0 | /eleven |
| 11111111.11000000.00000000.00000000 | 255.192.0.0 | / 10 |
| 11111111.10000000.00000000.00000000 | 255.128.0.0 | / 9 |
| 11111111.00000000.00000000.00000000 | 255.0.0.0 | / 8 |
| 11111110.00000000.00000000.00000000 | 254.0.0.0 | / 7 |
| 11111100.00000000.00000000.00000000 | 252.0.0.0 | / 6 |
| 11111000.00000000.00000000.00000000 | 248.0.0.0 | /5 |
| 11110000.00000000.00000000.00000000 | 240.0.0.0 | /4 |
| 11100000.00000000.00000000.00000000 | 224.0.0.0 | /3 |
| 11000000.00000000.00000000.00000000 | 192.0.0.0 | /2 |
| 10000000.00000000.00000000.00000000 | 128.0.0.0 | /1 |
| 00000000.00000000.00000000.00000000 | 0. | / 0 |
There are certain IPv4 addresses that cannot be assigned to the hosts, such as the network IP address or the broadcast IP address, the operating system would directly give us an error. We also find IPv4 that can be assigned to hosts but with restrictions on the interaction of said hosts within the network.
IPv4 address classes
In addressing with IPv4 there are different types of networks, these were created with the aim of creating networks of large, medium and small size. Currently all Internet routers make use of internal gateway dynamic routing protocols (IGP) and also EGP protocols that are classless, therefore, we will be making use of VLSM (Variable Size Subnet Masks) in order to save many addresses IP and not waste them.
There are class A, B, C addresses that are the most used, we also have classes E that are Multicast addresses, and class E that are for experimental or test use. In the following table you can see a summary of the different classes that we have:
| Class | TO | B | C | D | AND |
|---|---|---|---|---|---|
| Class IP address range | A 0.0.0.0 to 127.255.255.255 | B 128.0.0.0 to 191.255.255.255 | C 192.0.0.0 to 223.255.255.255 | D 224.0.0.0 to 239.255.255.255 | E 240.0.0.0 to 254.255.255.255 |
| Subnet mask class | A 255.0.0.0 | B 255.255.0.0 | C 255.255.255.0 | D Not defined | E Undefined |
| CIDR Subnet Mask Class | To 8 | B 16 | C 24 | D Not defined | E Undefined |
| Private Addressing class | A 10.0.0.0 to 10.255.255.255 | B 172.16.0.0 to 172.31.255.255 | C 192.168.0.0 to 192.168.255.255 | D | AND |
As you can see, both in class A, B and C addresses we have a private IP addressing range that we can use in our home or business without problems, but always locally. This private IP addressing is not routable over the Internet. There are also other reserved IP addresses, such as 0.0.0.0 to indicate that it is a default route, loopback IP addresses that are 127.0.0.0/8, or APIPA IP addresses that are in the range 169.254.0.0/16.
When calculating subnets, we must consider what we want to calculate: how many subnets can fit within a larger network? Calculate the subnet based on the maximum number of hosts to introduce within a network?
Calculate maximum number of subnets within a larger network
In this example we are going to calculate how many subnets can fit within a larger network. Let’s imagine that we want to put a total of 40 networks in the 192.168.1.0/24 network , what subnet mask should the different hosts use? What IP range do we have available for the hosts? What would be the network IP address and the broadcast IP address? The first thing we must know is that, in order to do this exercise, it is absolutely necessary to reserve a total of 2 bits for the hosts, therefore, in a class A network with / 8 mask we will have a total of 22 bits available, in a network of class B with mask / 16 we will have available a total of 14 bits, and in a network of class C with mask / 24 we will have available a total of 6 bits.
The steps to perform the calculation is as follows:
- Convert the 40 networks to binary: The first thing we have to do is convert the 40 to binary, which is 101000, this means that we have a total of 6 bits to later calculate the final subnet mask.
- The default subnet mask is / 24 or 255.255.255.0, if we change this mask to binary we have: 11111111.11111111.11111111.00000000.
- We reserve the 6 calculated bits (40 networks) from left to right, starting with the first 0 that appears, therefore, we will be working on the fourth octet.
- The new subnet mask would be as follows: 11111111.11111111.11111111.11111100; therefore, we are dealing with a / 30 or 255.255.255.252 subnet mask. If the last part of the mask (11111100) is converted to decimal, it gives us the number 252.
With this information, to calculate the different subnets that we can create within the 192.168.1.0/24 network, we have to do 2 raised to the number of zeros of the subnet mask that we have calculated, if we look, we have the final part of the mask is «11111100», we have two zeros, therefore, 2 ^ 2 which is equal to 4. This 4 is the increment that we must use to calculate the different network addresses of the different subnets.
The IP addressing range of the calculated subnets would be the following, logically in all of them the subnet mask / 30 or 255.255.255.252 that we have calculated will be used.
- 192.168.1.0 – 192.168.1.3; the first IP address is the network address, and the last one is the broadcast address. The addresses 192.168.1.1 and 192.168.1.2 that are “in the middle” are facing the hosts.
- 192.168.1.4 – 192.168.1.7
- 192.168.1.8 – 192.168.1.11
- 192.168.1.12 – 192.168.1.15
- ….
- 192.168.1. 252 – 192.168.1.255
The last network address, in its last octet, always corresponds to the subnet mask calculated in this example (255.255.255. 252 )
Calculate subnets based on maximum number of hosts per subnet
In this example we are going to calculate how many hosts can fit within a subnet that is within a larger network. In a 192.168.1.0/24 network, a total of 254 hosts can fit as we have seen before, although there are 256 addresses, the first address is the network address and the last is the broadcast address, therefore, they cannot be used for the hosts. .
Suppose we want to put a total of 40 hosts in a subnet, based on the top network 192.168.1.0/24 , what subnet mask should the different hosts use? What IP range do we have available for the hosts? What would be the network IP address and the broadcast IP address? The first thing we should know is that, in order to do this exercise, there will always be “excess” IP addresses of the hosts, in this case, not only will there be 40 hosts in each subnet, but a total of (2 ^ 8) -2.
The steps to perform the calculation are very similar to the previous one, but with a very important change in step number three .
- Convert the 40 hosts to binary: The first thing we have to do is convert the 40 to binary, which is 101000, this means that we have a total of 6 bits to later calculate the final subnet mask.
- The default subnet mask is / 24 or 255.255.255.0, if we change this mask to binary we have: 11111111.11111111.11111111.00000000.
- We reserve the calculated 6 bits (40 hosts) from right to left by putting zeros, and we will fill it in with 1 all the way to the left.
- The new subnet mask would be as follows: 11111111.11111111.11111111. 11000000 ; therefore, we are dealing with a / 26 subnet mask (we have a total of 26 ones) or 255.255.255.192. If the last part of the mask (11000000) is converted to decimal, it gives us the number 192.
With this information, to calculate the different subnets that we can create within the 192.168.1.0/24 network, we have to do 2 raised to the number of zeros of the subnet mask that we have calculated, if we look, we have the final part of the mask is «11000000», we have six zeros, therefore, 2 ^ 6 which is equal to 64. This 64 is the increment that we must use to calculate the different network addresses of the different subnets.
The IP addressing range of the calculated subnets would be the following, logically in all of them the subnet mask / 26 or 255.255.255.192 that we have calculated will be used.
- 192.168.1.0 – 192.168.1.63; the first IP address is the network address, and the last one is the broadcast address. The IP addresses that are “in the middle” are facing the hosts.
- 192.168.1.64 – 192.168.1.127
- 192.168.1.128 – 192.168.1.191
- 192.168.1.192 – 192.168.1.255
If we want to put 40 hosts per network, we can only create a total of four subnets within the 192.168.1.0/24 network as we have seen.
We hope that this tutorial will help you to calculate your subnets based on the number of networks and the number of hosts that we want to put within a subnet.