What is a Subnet Mask?
By Nick Anderson 5 minutes
The subnet is one of the fundamental concepts of networking. The internet is a huge collection of networks that spans various geographical locations in the abstract. The networks are internet-connected and facilitate data transfer from one network to another. Think of the internet as a universe that has various galaxies. If you wanted to travel from one galaxy to another, you would need a point of origin and destination to chart a course.
Subnetting is a concept of logically grouping networks to allow data to know the destination. More specifically, it provides the data information about the receiver’s location in the ocean of networks.
Thanks to subnetting, client A can understand that client B resides on the same subnet instead of scouring through all networks on the internet. It’s a faster way of network communication.
So, let us take a look at what is subnet and why it is so important for networks.
Brief Overview of IP Address
We have touched upon IP addresses in detail previously in our blog. However, learning about what is IP address is a prerequisite for understanding what is a subnet.
An IP address is an alphanumerical string that represents you on the internet. It is unique for every network on the internet and unique for every device connected to the router. Without an IP address, data will not know where to go.
It is represented by digits in four octets. For example, 192.168.1.0 is a 32-bit address (IPv4) that represents a complete IP address.
Now that we have that out of the way let’s see where the subnet comes in.
What Is a Subnet?
The internet has only grown in size since its inception. The massive number of networks has increased tenfold in just the last decade. Subnetting provides efficient routing information for data to reach its destination faster.
Let’s break down an IP address for a second here.
An IP address consists of two parts: a network address and a host address.
Computers don’t communicate and process data in our common languages; they only understand 0s and 1s. So, for any letter or number, a computer can only understand a binary string.
Take, for example, an IP address 192.168.1.0. As a Class, A network, the first three octets 192.168.1 represent the network address part of an IP address, and the last octet .0 is the host address part. When you break it down from decimal into binary – which is essential to understand how subnetting works – 192.168.1.0 converts to 11000000.10101000.00000001.00000000.
Each octet in an IP address has a range of 0 to 255 because it converts to 000000 and 11111111 in binary, respectively.
Types of Networks
The IP address also denotes what type of network it belongs to. Internet protocol addresses are managed according to classes.
- Class A
- Class B
- Class C
The IP address 192.168.1.0 is a Class C network because the network range 192-223 is in the first octet. Class A and Class B networks have a range of 0-127 and 128-191, respectively.
How Does A Subnet Work?
Subnetting is important because it allows a network to be broken down into smaller networks. The easiest example is that a router connected through another router is different from the primary network. It’s why disabling double NAT works in favor of inbound traffic.
Wide Area Network (WAN) does not cater to the information regarding the host address. It only knows which network the host is a part of and forwards data to the correct network, directed to the correct host on the subnet.
So, how does it work?
As we explained, computers only understand data in binary form. If user A with IP address 192.168.1.1 wants to connect with user B with an IP address 192.168.1.4, the router can see that the destination address belongs to a local subnet.
It’s because when we convert 192.168.1.4 into binary, it becomes 11000000.10101000.00000001.00000100.
Now, comparing 192.168.1.1 and 192.168.1.4 in binary form.
We can see that the first three octets are identical – this is how the router knows the host belongs to the same subnet.
What Is My Subnet Mask?
A subnet mask just identifies what part of an IP address is the network address and the host address.
Class C networks are smaller networks that don’t need to accommodate a very large number of hosts. Similarly, Class B and Class A are higher up. In a Class C network, the first three octets are reserved for the network address, which means 24 bits are reserved, and the host address takes up 8 bits.
The default subnet mask for Class A networks is 22.214.171.124, Class B is 126.96.36.199, and Class C is 255.255.255.0 or just /24.
You might now have a good understanding of what a subnet is and why it’s important for networking. Subnets also help slow down the exhaustion of IPv4 addresses. Like IPv4 networks have subnets, IPv6 have prefixes. Learn more about the differences between IPv4 and IPv6 in our blog here.