If you’ve been following our blog for a while, you know IT can be a very daunting and complex domain. However, it goes without saying that there’s more than meets the eye, just like we are about to see soon. To know basic stuff about IPs is sometimes just not enough, and eventually you will end up searching for subnet masks and everything related.
Fun fact, this is today’s topic. We are going to cover everything you need to know about subnet masks, the process of subnetting and why they are important in the grand scheme of networking.
You might already know by now that an IP address is an identifier for a computer or a device on a network. It is a unique identifier each device that wants to connect to the Internet must have. It’s like the address, the street where you live. So remember this last part, put it in your pocket, because it will make it easier for you to understand the concepts of subnet mask and subnetting.
1. What is a subnet mask?
Let’s try a more practical approach. Open the command prompt on your Windows operating machine and type ipconfig. Just like on a Windows computer, you can use ipconfig on Mac with Terminal to find your local IP address. If you’re connected to the internet through a wireless network: Hit ⌘ + Space to search and open Terminal. Now, since IPv4 addresses make up 99% of the total networks used, with the remaining 1% being used by IPv6 addresses, chances are your device is connected to the Internet via the first category.
You will see the IP your device has, and underneath it you might spot something called a subnet mask. Roughly speaking, a subnet mask defines the range of IP addresses that can be used within a network or a subnet. More on that later. What you need to know is that a subnet mask also separates an IP address into two parts: network bits and host bits.
Now, suppose your IP is something like this: 18.104.22.168. What a subnet mask does is divide this address into a network part and a host part. In this case, the first three numbers (the actual name for these numbers is octets) represent the network, while the last number, 1, represents the host. The network portion represents the overall network, while the host portion outlines the respective device and if that device is connected to the same network.
Remember the street where you live? No, not your actual street. We are talking about that street in the example above. Your house is not the only one on that street, just like a device might not be the only one with that network we talked about. So basically, the address your devices share will always be the same, provided they are on the same network. How do we know that? Well, because of the subnet mask.
Now take a look at that. It’s highly likely the subnet mask will be 255.255.255.0. In fact, this is one of the most common types of subnet masks, part of a certain class. We will discuss this later, but for you to get a rough idea, it’s interesting to know that such a subnet mask allows the use of 256 IP addresses on the same network. More specifically, up to 256 devices can connect to your network/router and access the Internet.
Before we move on to more intricate concepts, let’s talk about subnet masks and why they are important for IP addresses and IP classes. You should know that IPv4 addresses are, in fact, 32-bit addresses, interpreted by computers in binary code. Each group of numbers that precedes the dot is actually represented by eight numbers, or bits. Hence the name octets. Four dots, meaning four divisions, multiplied by those eight bits, equals 32 bits.
So, for the IP address mentioned before:
22.214.171.124 is actually translated in binary as: 11000110.10101000.01100100.00000001
Working in binary format is mostly inefficient and unnecessarily complicated. Unless you know binary by heart, you will spend most of your time copying and pasting IP addresses from online converters. This is why your daily IP address is written and worked with in decimals.
Do you remember what a subnet mask does and how it divides the IP address into network and host bits? For our example, the subnet mask for 126.96.36.199 is 255.255.255.0. Therefore, if you were to specify these two parts, you would get to write something like this:
Network address – 188.8.131.52
Host address – 000.000.000.1
Now that we covered how IPs work and what a subnet mask is, we have to talk a bit about IP classes and ranges before moving on to the actual process of subnetting.
If you or your company plan for IP addressing, the first step is to determine which network class is suitable for you. IPv4 addresses are usually divided into several classes, most commonly A,B and C classes. There are also D and E classes, but the latter two are generally not used by end users. In order to understand what constitutes an IP class, let’s have a look at these classes overall and indicate their particular use.
You can identify the class of an IP address by looking at its first octet (the first numbers before the first dot). The classes themselves mainly describe the IP range, based on intervals. Below you will find a small infographic which indicates the first three classes and their respective range. Take your time to familiarize yourself with these basics, then we can exemplify.
Let’s give a quick example. Let’s say we have the following IP address: 184.108.40.206. If you were thinking about putting it in the Class A, you were right. The first octet of this address, 118, is included in the Class A interval of octets – between 0 and 127. So this is how it goes for all the other IP classes.
You might have noticed that we did not specify the default subnet masks for the last two IP classes. It is generally believed that Class D is not available for use in normal networking operations. They don’t have subnet potential because there are no host bits within the Class D address space. Class E is believed to be an experimental class, reserved for study and future development. This is why you might see it labeled as undefined on some websites.
2. The importance of subnet masks
Subnet masks do more than just separating the network part from the host part. They come as a hint that helps us determine how many IP addresses can exist based on that class and respective subnet mask. They also help in the process of subnetting. In order to keep it clean and organized, IPs use something called slash notation, with the official name being CIDR (Classless Inter-Domain Routing).
Slash notation is a compact way to show or write an IPv4 subnet mask. When you use slash notation, you write the IP address, a forward slash (/), and the subnet mask number. For example, the subnet mask 255.255.255.0 has the slash equivalent /24, which implies that 256 IP addresses can connect on a single host. Here it might get a bit more complex. To find the slash equivalent of the desired subnet mask, you need to do some calculations which eventually lead to converting the decimals back to binary. Here’s how you can do it the (more of less) easy way:
Take, for example, 255.255.255.0. How do we get to /24 from here?
- Convert the submask to binary. It would be easier if you used an online converter. For this subnet mask, the binary equivalent is 11111111.11111111.11111111.00000000
- Count each “1” in the resulting subnet mask. The total is the subnet mask number. Here, we get a total of 24, so the result is /24.
- The final display including the IPv4 address (220.127.116.11, as shown in the previous examples) and the subnet mask number looks like this: 18.104.22.168/24.
Like we said before, subnet masks are important because they show the number of possible usable IP addresses. The formula to calculate such intricate numbers might look intimidating and it might take some time. Alternatively, you can use an online calculator for that. It would be better if we somehow had just the needed information at our fingertips, right?
Below you can check a complete IPv4 subnet mask cheat sheet. It contains everything you need to know about IP ranges, subnet masks and the overall available IPv4 addresses for each slash.
In the IPv4 subnet mask cheat sheet, you might observe that the total number of IP addresses in each subnet differs from the total number of actual usable IP addresses by two. In IPv4, there are two IPs that cannot be assigned to any devices. These are the Network ID and the Broadcast IP address. Therefore, you need to subtract two addresses from the total IP formula. It appears that the sole exception is /31.
With over 4 billion IPv4 addresses across the globe, one might think the resources are infinite. One couldn’t be more wrong. The modern world has developed so significantly that IPv4 addresses started getting scarcer and scarcer. To tackle this shortage, developers have come up with the idea of splitting an IP address into smaller networks. This brings us to the next part of this article – the process of subnetting.
3. What is subnetting?
Subnetting is the process of dividing a network into smaller networks, called subnets. While subnet masks divide the address into network bit and host bit, a subnet describes the specific part of a network that shares the network’s IP address but has a unique subnet address. Mind the difference.
Networks are capable of connecting hundreds, if not thousands of devices. While this is an accomplishment on its own, it also has an issue.
Because of this extended connectivity, it could take some time for the data to find the right device. Subnetting narrows down the IP address to usage within a range of devices. Due to this, data can travel more directly to its destination IP address.
Because an IP address is limited to indicating the network and the device address, IP addresses cannot be used to indicate which subnet an IP packet should go to. This is why routers within a network use subnet masks to sort data into subnetworks. Data is not bound to interacting with all parts of the network.
But in order to identify the specific device data is going to, IP addresses must be arranged in a logical way. The objective is to easily identify the network address and the host address for a more efficient routing of data. In order to do this, the network needs to be matched with a corresponding subnet mask, hence their co-dependence.
Subnetting is important and advantageous for many businesses and uses, ranging from small companies to large enterprises. Thus, administrators have more control over their networks and can improve their network’s performance while tackling the inefficiency of broadcast traffic.
4. Why is subnetting so important?
First of all, it makes sure the distance that data packets need to travel in the network is as small as possible. It allows for devices to communicate more efficiently with smaller networks, rather than cluttering the same network at once. You can think of that as a Zoom call with many people. Everyone keeps talking, there’s too much background noise and you cannot really understand anything, nor can the participants understand one another. If you were to create a couple of breakout rooms and split the participants among those, communication would be more efficient.
Subnet masks make sure the traffic stays contained within its designated subnet. In turn, subnets reduce the heavy load on the same network and route data in a nice, clean and efficient manner. The final result is the increase of speed and overall performance of the network.
Subnetting is notably important in consolidating your network’s security if your company is working with many connected devices and a high volume of network traffic. Running multiple subnets rather than a single large network does a better job at protecting your data. If a subnet is compromised by an attack, only that segment of the network will be damaged instead of the whole network. Therefore, instead of all the devices on the same network being visible by attackers, only devices sharing the same subnet will or could be targeted.
Subnetting preserves the lifespan of IPv4. Technology and telecommunications have evolved so quickly that those 4 billion IPv4 addresses we talked about have simply become not enough for our modern needs. With billions of devices connected across the world, it’s safe to assume 4 billion no longer sounds like a lot. This is why people have come up with this great idea of dividing a single network into smaller subnetworks, in order to increase the utility of that particular IPv4 address.
Instead of each device having a unique IP address, a network can have a number of private IP addresses on that same IP network. The logical follow up is that each device connected to an IP network now has an IP address comprising the part which defines the overall, main network and the part which indicates its subnet.
Subnet masks and subnetting are the reason why IPv4 addresses have been staying around for quite some time. IPv4 is still a relevant and important element in the industry, thanks to the ability to be divided into subnets. The whole perspective can be confusing even after having studied the basics of networking, but nowadays it’s easier for companies to make the most out of the process of subnetting.
If a company plans on utilizing subnetting in its network, it will need to use subnet masks and make sure the inbound traffic is routed to and from the correct host devices. For this, you can refer to the cheatsheet in this article and determine which class, range and subnet mask is right for you.
No matter how big and small an enterprise is, subnetting is the key for maintaining a stable, smooth and fast networking system. Subnetting is key for reliability and security, part of a successful business.