Subnetting: what is it, how to calculate it and what are its benefits?

Subnetting: what is it, how to calculate it and what are its benefits?

Franco Brutti

Sep 4, 2023

Sep 4, 2023

Sep 4, 2023

Subnetting: what is it, how to calculate it and what are its benefits?
Subnetting: what is it, how to calculate it and what are its benefits?
Subnetting: what is it, how to calculate it and what are its benefits?

Subnetting is one of those essential Internet methods. A system that often goes unnoticed by the user, but a system responsible for the functioning of the web as we know it.

If you want to specialize in networking systems, subnetting is a method you have to know about. And here we will not only tell you its definition, but also how it works and its role on the Internet, as well as its advantages and disadvantages.

In addition, we will give you the formulas for calculating subnets with simple examples for you to put them into practice.

Subnetting and IP addresses

Before we get into subnetting, we need to know how IP addresses and their respective notations work.

And here we’re going to get more technical, but in the most simplified language possible.

Broadly speaking, IP addresses hide the Net ID and Host ID so that systems can route data packets through these addresses. 

IP addresses are composed of binary numbers. IPv4, which is the IP addressing model we have used for decades, has 32 bits. In other words, 32 zeros and ones. 

Now, systems follow the dot-decimal notation format to simplify the binary code in the IP addresses we already know. 

For example:

IP: 203.128.52.7

In this case:

Subnetting and IP addresses

As you will see, each number is represented by an 8-digit binary number. These numbers are known as octets. 

The IP address consists of four octets. As you will see, each IP corresponds to 32 bits in total.

But what is subnetting?

Subnetting consists of dividing IP networks into smaller, much more focused and easier to manage subnets. All to improve the efficiency of IP addressing and data routing, as well as the performance of the network system.

At the same time, through subnetting, you can assign your system's IP addresses to specific devices. And thus, you can improve the online performance of each one separately. 

And how does subnetting work?

When subnetting, you take an existing IP address and assign a "slice" of that address to create smaller subnets. In this way, you can increase the performance of the network and make it more efficient and organized.

Subnetting is based on the subnet mask, a second 32-bit number that works as a key to identify:

  • Which part of the IP address corresponds to the network.

  • Which part corresponds to the host.

Now, each subnet created by subnetting has its own network address and its own range of IP addresses available to hosts. Both elements, the IP address and the subnet mask, are essential to identify the host and the network uniquely.

It’s all done through the modification of the subnet mask and the use of additional bits. And this allows for greater control and security of the network, and much more efficiency in managing IP addresses.

As you can imagine, this is an essential skill when building networks, both for network administration and system optimization. 

Types of subnetting: how many types are there?

Subnetting has 3 types or 3 main classes. Each class can be identified by the numbers of its first octet:

  • Class A: 0 - 126

  • Class B: 128 - 191

  • Class C: 192 - 233

Note: 127 is not part of any class because it works as a loopback, that is, a routing system, independent of the network, inside the device. That is, as an internal server of the device.

There are also 2 additional classes:

  • Class D: 224 - 239

  • Class E: 240 - 255

However, these classes are used for experiments and research. For example, Class D can be used to test new routing methods or multicast applications, among other purposes.

Class E, on the other hand, is seen by many as the IP of the future. However, its use is not yet defined, so it’s seen as an undefined and even illegal class - except for IP 255.255.255.255.255, which can be used as a Class D IP.

These 2 classes do not exist in network systems for the common user. 

That said, let's look at the 3 main classes and their respective subnet masks. 

1. Class A: 

Used for large networks and allows a large number of hosts. 

Going back to the subnetting mask, the first octet of a Class A IP address is used to identify the network, while the remaining three octets are used to identify the hosts in the network (and so on with the rest of the classes).

Thanks to its wide IP address range and its ability to host a large number of hosts, Class A is perfect for large-scale organizations, such as large enterprises, universities or Internet service providers.

The Class A notation is 255.0.0.0.0 or /8 in prefix notation. In other words, the first 8 bits correspond to the Class A IP address, while the other 24 bits correspond to the hosts.

Note: although Class A is perfect for large-scale systems, it’s also the class with the most residual IP addresses.

2. Class B: 

It’s for medium-sized networks and allows a moderate number of hosts. The first two octets of a Class B IP address are used to identify the network.

This class is perfect for companies and organizations that require a good number of hosts without reaching massive scale. 

And since it offers fewer IP addresses, it allows better management of the respective subnets, wasting fewer addresses than Class A.

In this case, the default subnet mask is 255.255.0.0 or /16. That is, half corresponds to the IP address and half to the hosts.

3. Class C:

Used for small networks and allows a limited number of hosts.

This class has a much more limited number of hosts. However, it offers much more control than the previous classes. 

Because of its capabilities, this class is best suited for small networks and systems, such as home and office networks.

In this case, the default subnet mask is 255.255.255.0 or /24. 

Classless subnetting

There is also a category of classless subnetting, also known as VLSM (Variable Length Subnet Masking). This method is much more flexible and does not depend on classes A, B, C, or their limitations. 

With this method, you can assign variable length subnet masks. In other words, you can increase or decrease the size of your subnets according to your needs. 

The result? Better resource management and better IP address management. However, this type of subnetting is more ambitious, challenging and difficult to implement. 

So why not use classless subnetting in all cases?

For one thing, subnetting requires fairly sophisticated routers and network devices to handle variable-length masks. 

On the other hand, there may be compatibility issues between devices, especially with older devices.

In addition, smaller subnets do not need variable-length masks in most cases. This method is much more suitable for highly complex systems.

The formula for calculating subnets

For well-structured, high-performance systems; scalable systems with well-allocated IP addresses, you have to know how to calculate subnets. 

The formula is quite simple:

Number of subnets = 2^n 

In this case, "n" corresponds to the number of borrowed bits.

The "borrowed bits" represent the number of bits used by the network portion of each mask. According to this formula, each subnet can have two possible values (the binary values 0 and 1); that is, two possibilities for each bit. 

But let's look at an example.

If you lend 3 bits for the network portion:

Number of subnets = 2^3 = 8 possible subnets. 

Seen another way 2 x 2 x 2 x 2 = 8 subnets. 

Formula for calculating hosts

The formula is:

Number of hosts = 2^n - 2

In this case, " n " corresponds to the number of hosts. Since the network address and broadcast address cannot be used for individual hosts, they are subtracted from the equation (hence the " - 2 ").

To calculate the host, you have to check the last octet of each subnet. Let's see the last octets of each possible subnet and their respective binary code:

  • 0 = 00000000

  • 32 = 00100000

  • 64 = 01000000

  • 96 = 01100000

  • 128 = 10000000

  • 160 = 10100000

  • 192 = 11000000

  • 224 = 11100000

In practice:

  • 2^5 - 2 = 30 hosts per subnet.

  • 2^7 - 2 = 126 hosts per subnet.

What are the benefits of subnetting?

Now that you know the technical definitions and mathematical formulas, let's take a look at the benefits of subnetting in practice.

1. Security and control

Subnetting will allow you to segment each network into smaller subnets. All in an efficient and controlled manner.

By segmenting, you can create an individual configuration for each specific subnet, a configuration better adapted to the network system and its different devices.

In addition, you can define different protocols, policies and security standards for each network segment as a whole.

As a result, each subnet will have its own security system. 

In addition, security problems in one subnetwork will not directly affect the system as a whole, thanks to the different standards and protocols. 

2. Increased performance

The separation and segmentation of networks will help you create seamless, more efficient and better structured systems.

In these systems, each subnet will have its own IP assignment, and even different network services. This translates into fewer shared resources, less overhead in the network system, less congestion and much faster speeds across the different subnets.

3. More efficient traffic routing

Subnetting will also help you reduce broadcast traffic. That is, ARP (Address Resolution Protocol) requests traffic, which can saturate the entire network.

Through this technique, the traffic will be destined to a single specific subnet, which will prevent this same traffic from consuming the bandwidth of the network system and overloading the other subnets.

In addition, as with security protocols, you can define different data routing policies for each subnet. This will help you optimize data flow and ensure the best possible performance of your overall network.

Disadvantages

Although subnetting is one of the most widely used techniques, it also has certain limitations and considerations, such as:

1. Network complexity

This method can be challenging when configuring your system, especially if you are not experienced in networking.

Managing complex systems and their respective subnets is not an easy task. Structuring a network system and its subnets requires solid and well-established knowledge.

Moreover, the larger the number of subnets, the more difficult it is to manage, even for the most experienced specialists. 

2. IP address consumption

Subnetting can consume more IP addresses than necessary. Each subnet requires a certain number of addresses for the network address, broadcast address and other reserved addresses. 

In fact, there are always wasted IP addresses, even in small networks. And this can be a problem if you have limited IP address space.

Advantages and disadvantages of subnetting


Ready to put subnetting into practice?

Subnetting is a key part of networking, and an invaluable skill among specialists.

At first glance, this technique may seem intimidating. But once you master it, you will have an invaluable tool when it comes to building all types of networks at all scales, regardless of whether we are talking about a local network or a telecommunications system.

Now tell us, did you already know about subnetting? Can you think of other benefits of this method? Share all your questions, opinions and tips in the comments section. We look forward to hearing your insights.