If you are a network engineer, you have probably come across the usage of subnets and subnets masks. You may also need to look up required subnet mask values and understand their meaning. Whatever your subnet work entails, you’ll fly through every issue with this subnet cheat sheet.
Before we get into our subnet and netmask cheat sheet, let’s walk through the subnetting basics, how to calculate subnets, and more.
This article’s subnetting cheat sheet will help you go about your day-to-day work, or even prepare for some software or network engineer job interviews!
How Do IP Address Blocks Work?
Each IP address is assigned to a different “block,” or network. IPv4 is the internet protocol version 4, the most common protocol. It consists of four binary blocks, with each block containing 8 bits, representing numbers from 0-255.
The complete IPv4 address is 32 bits, resulting in more than 4 million addresses over the internet. An example of an IPv4 address is 172.16.254.1.
We can use the chart below to convert the IP address between the decimal and the binary form:
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
X |
X |
X |
X |
X |
X |
X |
X |
Remember that 1 is the equivalent to "on," and 0 is "off". So to convert the first block (168) into binary, you must from the beginning of the chart and place a 1 or 0 in that cell until you get a sum of 168.Let’s use the IP address 168.210.225.206 as an example. You just have to break the address into four blocks (168, 210, 225, and 206) and then convert each of these blocks into binary using the chart above. The above chart is the 8-bit octet.
For example:
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
1 |
0 |
1 |
0 |
1 |
0 |
0 |
0 |
128 + 32 + 8 = 168, which in binary is 10101000.
If you do this for the rest of the blocks, you will get 10101000.11010010.11100001.11001110.
What is Subnetting?
IPv4 has 32 bits and creates more than four million address spaces, but those spaces have been exhausted. So, more address space is necessary to cater to more devices using the internet.
An address space shortage was explored a few years back. Developers decided to split up the IP address into smaller networks to create more space, and those smaller networks are known as subnets. The process of creating those smaller networks is called subnetting.
In this process, the developers break down the host section of the IP address into subnets.
You must be aware that IP addresses consist of network and host bits, as shown below.
Subnetting allows you to do the following:
- Break up networks into subnets
- Allow devices to determine whether another device or IP address is on the same local network.
A perfect example of subnetting is your home wireless network. If you do not use subnetting, then every device on the internet will require its IP address. But now, as the wireless router is available, you will only require one IP address for your router, which is assigned by your internet service provider (ISP). Every device connected to that router will have its own private or internal IP address.
Suppose your device with internal IP address 192.168.1.101 wants to communicate with another device, and the device has to use the IP address of the other device and the subnet mask. The IP addresses and subnet mask allow the device at 192.168.1.101 to check if the other device is present on the same network (like the device at 192.168.1.103) or a different network.
Introduction to IP Addressing and Subnetting the Easy Way
How Do Subnet Masks Work?
Subnet masks work as a filter for IP addresses. With the help of the subnet mask, devices check an IP address to determine which parts are the network bits and which are the host bits, allowing the devices to communicate efficiently.
If you ever come across the network settings on your router or computer, you might have seen 255.255.255.0. Like IPv4 addresses, subnet masks are also 32 bits. Also, as you convert an IP address into binary, you can convert a subnet mask.
For example:
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
X |
X |
X |
X |
X |
X |
X |
X |
Now, we will convert the first octet, 255:
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
It is a straightforward 255.255.255.0.
11111111.11111111.11111111.00000000 in binary.
Now, we will consider both the subnet mask and IP address to calculate which parts of the IP address are the network and host bits.
Here are the two in both decimal and binary:
Type |
Decimal |
Binary |
IP Address |
192.168.0.101 |
11000000.10101000.00000000.01100101 |
Subnet Mask |
255.255.255.0 |
11111111.11111111.11111111.00000000 |
You can easily separate 192.168.0.101 into network and host bits.
If a bit in a binary subnet mask is 1, then the same bits in a binary IP address are part of the network. As the octet 255 is 11111111 in binary, that whole octet in the IP address is part of the network. So the first three octets, 192.168.0, are the IP address’s network portion, and 101 is the host portion.
If the device at 192.168.0.101 wants to communicate with another device with a subnet mask, it will know that another device with the IP address 192.168.0.xxx is on the same local network.
What Does CIDR Mean and What is CIDR Notation?
CIDR stands for Classless Inter-Domain Routing and is common in IPv4.Let’s cover a mini CIDR cheat sheet to complement our subnet cheat sheet.
CIDR came into the picture in 1993 for slowing the usage of IPv4 addresses. CIDR comes with a couple of significant concepts:
- Variable Length Submasking (VLSM), allowing the network engineers to create subnets of different sizes for unused IP addresses.
- CIDR Notation, shorthand for the subnet mask, representing the number of bits available to the IP address. For example, the /24 in 192.168.0.101/24 is equivalent to the IP address 192.168.0.101 with subnet mask 255.255.255.0.
How to Calculate CIDR Notation
To check CIDR notation for a given subnet mask, you have to convert the subnet mask into binary and count the number of ones or "on" digits.
For example:
Type |
Decimal |
Binary |
Subnet Mask |
255.255.255.0 |
11111111.11111111.11111111.00000000 |
In the above table, we have three octets of ones, and there are 24 "on" bits meaning that the CIDR notation is /24 subnet. Using /24 is much easier to write than 255.255.255.0.
Let’s consider the same subnet mask with an IP address:
Type |
Decimal |
Binary |
IP Address |
192.168.0.101 |
11000000.10101000.00000000.01100101 |
Subnet Mask |
255.255.255.0 |
11111111.11111111.11111111.00000000 |
The first three octets of the subnet mask are all "on" bits, representing the same three octets in the IP address as network bits.
Now, let’s consider the last or fourth octet in a bit more detail:
Type |
Decimal |
Binary |
IP Address |
101 |
01100101 |
Subnet Mask |
0 |
00000000 |
The CIDR notation of the IP address 192.168.0.101 with a subnet mask of 255.255.255.0 is 192.168.0.0/24. All the bits in the last octet in the subnet mask are "off", representing the same bits in the IP address as host bits. Whenever you write the CIDR notation, you must use the network ID.
Number of Hosts in a Subnet
You must consistently check how many hosts you can have in a given subnet and how many hosts a subnet can accommodate.
You can solve this problem quickly, as the number of host bits in a subnet is 32 less than network bits. Also, you need to subtract 2 to get the usable IP addresses, and it is because the first IP address represents the network itself and the last IP address represents the broadcast address.
The formula for calculating some hosts is mentioned below:
232-network_bit - 2
For example, in a /24 subnet, the number of hosts is calculated below. (how many ips in a 24)
232-24 - 2 = 28 - 2 = 256 - 2 = 254
If you have the subnet mask in dotted-decimal notation, it is even easier for /24 and more significant.
For example, to calculate how many usable IP addresses there are in 200.1.0.64 255.255.255.192, you must calculate 256 – 192 – 2, i.e., 62.
But, it will be complex if we consider subnet masks less than /24. For such problems, it’s better to convert the subnet mask to the prefix length format quickly.
For example, check how many usable IP addresses are there in 172.16.23.0 255.255.240.0. So 255.255.240.0 is /20. Therefore, the number of usable IP addresses is 4094, i.e., 2^(32-20) – 2.
Minimum Subnet Size for a Particular Number of Hosts
To find out the minimum subnet size for a particular number of hosts, here’s what you need to do.
Cover the number of hosts, which requires you to count in orders of 2:
- 1 bit: 2^1 = 2 possible IPs (including network/broadcast)
- 2 bits: 2^2 = 4 possible IPs
- 7 bits: 2^7 = 128 possible IPs
- 11 bits: 2^11 = 2048 possible IPs, etc.
You will also need to factor in the two unusable IP addresses for network and broadcast addresses.
So, the minimum number of host bits required is 5 bits (2^5 = 32). 4 bits (2^4 = 16) will be too small. Therefore, the minimum subnet size we can use is /27.
Number of Subnets in an Address Block
To find the number of subnets in an address block, you should start by finding the reference address block using the below formula.
2new_network_bits - reference_network_bits
- How many /27 subnets can you get from a /24 address block?
227-24 = 23 = 8 subnets
- How about /25 subnets from a /17 block?
225-17 = 28 = 256 subnets
- How many /20 blocks can you get from the classful address block 171.44.0.0?
In this scenario, you must know about IP addresses classes. Looking at the 171.44.0.0 block, you will discover a Class B address that uses 16 bits to represent the network portion.
Therefore, several subnets will be:
220-16 = 24 = 16 subnets
Subnet Mask Chart
Addresses |
Hosts |
Netmask |
Amount of Class C |
|
/30 |
4 |
2 |
255.255.255.252 |
1/64 |
/29 |
8 |
6 |
255.255.255.248 |
1/32 |
/28 |
16 |
14 |
255.255.255.240 |
1/16 |
/27 |
32 |
30 |
255.255.255.224 |
1/8 |
/26 |
64 |
62 |
255.255.255.192 |
1/4 |
/25 |
128 |
126 |
255.255.255.128 |
1/2 |
/24 |
256 |
254 |
255.255.255.0 |
1 |
/23 |
512 |
510 |
255.255.254.0 |
2 |
/22 |
1024 |
1022 |
255.255.252.0 |
4 |
/21 |
2048 |
2046 |
255.255.248.0 |
8 |
/20 |
4096 |
4094 |
255.255.240.0 |
16 |
/19 |
8192 |
8190 |
255.255.224.0 |
32 |
/18 |
16384 |
16382 |
255.255.192.0 |
64 |
/17 |
32768 |
32766 |
255.255.128.0 |
128 |
/16 |
65536 |
65534 |
255.255.0.0 |
256 |
- IP range /25 subnet -- 2 Subnets -- 126 Hosts/Subnet
Network # |
IP Ranges |
Broadcast |
0 |
.1-.126 |
0.127 |
0.128 |
.129-.254 |
0.255 |
- IP range /26 subnet -- 4 Subnets -- 62 Hosts/Subnet
Network # |
IP Range |
Broadcast |
0 |
.1-.62 |
0.63 |
0.64 |
.65-.126 |
0.127 |
0.128 |
.129-.190 |
0.191 |
0.192 |
.193-.254 |
0.255 |
- IP range /27 subnet -- 8 Subnets -- 30 Hosts/Subnet
Network # |
IP Range |
Broadcast |
0 |
.1-.30 |
0.31 |
0.32 |
.33-.62 |
0.63 |
0.64 |
.65-.94 |
0.95 |
0.96 |
.97-.126 |
0.127 |
0.128 |
.129-.158 |
0.159 |
0.16 |
.161-.190 |
0.191 |
0.192 |
.193-.222 |
0.223 |
0.224 |
.225-.254 |
0.255 |
- IP range /28 subnet -- 16 Subnets -- 14 Hosts/Subnet
Network # |
IP Range |
Broadcast |
0 |
.1-.14 |
0.15 |
0.16 |
.17-.30 |
0.31 |
0.32 |
.33-.46 |
0.47 |
0.48 |
.49-.62 |
0.63 |
0.64 |
.65-.78 |
0.79 |
0.8 |
.81-.94 |
0.95 |
0.96 |
.97-.110 |
0.111 |
0.112 |
.113-.126 |
0.127 |
0.128 |
.129-.142 |
0.143 |
0.144 |
.145-.158 |
0.159 |
0.16 |
.161-.174 |
0.175 |
0.176 |
.177-.190 |
0.191 |
0.192 |
.193-.206 |
0.207 |
0.208 |
.209-.222 |
0.223 |
0.224 |
.225-.238 |
0.239 |
0.24 |
.241-.254 |
0.255 |
- IP range /29 subnet -- 32 Subnets -- 6 Hosts/Subnet
Network # |
IP Range |
Broadcast |
0 |
.1-.6 |
0.7 |
0.8 |
.9-.14 |
0.15 |
0.16 |
.17-.22 |
0.23 |
0.24 |
.25-.30 |
0.31 |
0.32 |
.33-.38 |
0.39 |
0.4 |
.41-.46 |
0.47 |
0.48 |
.49-.54 |
0.55 |
0.56 |
.57-.62 |
0.63 |
0.64 |
.65-.70 |
0.71 |
0.72 |
.73-.78 |
0.79 |
0.8 |
.81-.86 |
0.87 |
0.88 |
.89-.94 |
0.95 |
0.96 |
.97-.102 |
0.103 |
0.104 |
.105-.110 |
0.111 |
0.112 |
.113-.118 |
0.119 |
0.12 |
.121-.126 |
0.127 |
0.128 |
.129-.134 |
0.135 |
0.136 |
.137-.142 |
0.143 |
0.144 |
.145-.150 |
0.151 |
0.152 |
.153-.158 |
0.159 |
0.16 |
.161-.166 |
0.167 |
0.168 |
.169-.174 |
0.175 |
0.176 |
.177-.182 |
0.183 |
0.184 |
.185-.190 |
0.191 |
0.192 |
.193-.198 |
0.199 |
0.2 |
.201-.206 |
0.207 |
0.208 |
.209-.214 |
0.215 |
0.216 |
.217-.222 |
0.223 |
0.224 |
.225-.230 |
0.231 |
0.232 |
.233-.238 |
0.239 |
0.24 |
.241-.246 |
0.247 |
0.248 |
.249-.254 |
0.255 |
- IP range /30 subnet -- 64 Subnets -- 2 Hosts/Subnet
Network # |
IP Range |
Broadcast |
0 |
.1-.2 |
0.3 |
0.4 |
.5-.6 |
0.7 |
0.8 |
.9-.10 |
0.11 |
0.12 |
.13-.14 |
0.15 |
0.16 |
.17-.18 |
0.19 |
0.2 |
.21-.22 |
0.23 |
0.24 |
.25-.26 |
0.27 |
0.28 |
.29-.30 |
0.31 |
0.32 |
.33-.34 |
0.35 |
0.36 |
.37-.38 |
0.39 |
0.4 |
.41-.42 |
0.43 |
0.44 |
.45-.46 |
0.47 |
0.48 |
.49-.50 |
0.51 |
0.52 |
.53-.54 |
0.55 |
0.56 |
.57-.58 |
0.59 |
0.6 |
.61-.62 |
0.63 |
0.64 |
.65-.66 |
0.67 |
0.68 |
.69-.70 |
0.71 |
0.72 |
.73-.74 |
0.75 |
0.76 |
.77-.78 |
0.79 |
0.8 |
.81-.82 |
0.83 |
0.84 |
.85-.86 |
0.87 |
0.88 |
.89-.90 |
0.91 |
0.92 |
.93-.94 |
0.95 |
0.96 |
.97-.98 |
0.99 |
0.1 |
.101-.102 |
0.103 |
0.104 |
.105-.106 |
0.107 |
0.108 |
.109-.110 |
0.111 |
0.112 |
.113-.114 |
0.115 |
0.116 |
.117-.118 |
0.119 |
0.12 |
.121-.122 |
0.123 |
0.124 |
.125-.126 |
0.127 |
0.128 |
.129-.130 |
0.131 |
0.132 |
.133-.134 |
0.135 |
0.136 |
.137-.138 |
0.139 |
0.14 |
.141-.142 |
0.143 |
0.144 |
.145-.146 |
0.147 |
0.148 |
.149-.150 |
0.151 |
0.152 |
.153-.154 |
0.155 |
0.156 |
.157-.158 |
0.159 |
0.16 |
.161-.162 |
0.163 |
0.164 |
.165-.166 |
0.167 |
0.168 |
.169-.170 |
0.171 |
0.172 |
.173-.174 |
0.175 |
0.176 |
.177-.178 |
0.179 |
0.18 |
.181-.182 |
0.183 |
0.184 |
.185-.186 |
0.187 |
0.188 |
.189-.190 |
0.191 |
0.192 |
.193-.194 |
0.195 |
0.196 |
.197-.198 |
0.199 |
0.2 |
.201-.202 |
0.203 |
0.204 |
.205-.206 |
0.207 |
0.208 |
.209-.210 |
0.211 |
0.212 |
.213-.214 |
0.215 |
0.216 |
.217-.218 |
0.219 |
0.22 |
.221-.222 |
0.223 |
0.224 |
.225-.226 |
0.227 |
0.228 |
.229-.230 |
0.231 |
0.232 |
.233-.234 |
0.235 |
0.236 |
.237-.238 |
0.239 |
0.24 |
.241-.242 |
0.243 |
0.244 |
.245-.246 |
0.247 |
0.248 |
.249-.250 |
0.251 |
0.252 |
.253-.254 |
0.255 |
Conclusion
Everything’s easier when you have some examples to reference, including subnetting! This subnet cheat sheet can help anyone who works daily with subnets, IP addresses, hosts, etc.
Whenever you are stuck somewhere while calculating subnets, several hosts, and IPs, you can quickly refer to this cheat sheet and solve your problems with standard formulas and examples.
Interested in collecting more cheat sheets? Check out our Java and SQL cheat sheets!
Also take a look at this relevant course by Coursera!
Frequently Asked Questions
1. How Many Subnets are in a 24?
There are 65534 subnets in 24.
2. How Do You Calculate a Subnet?
For an IP address 192.35.128.93 with six subnets, we can calculate the subnet using the following steps:
1. Check the network class of the given IP address.
2. Because the address starts with 192, the network class is Class C.
3. Calculate the number of bits to define the subnets.
Number of bits = Log2(Number of subnets + 2).
Number of Bits = Log2(Number of subnets + 2) = Log2(6+2) = 3 bits.
4. Compose the subnet mask in binary form using the default binary classification.
-
- The IP address has a binary classification of 11111111.11111111.11111111.00000000.
5. Now, substitute the subnet bits 11111111.11111111.11111111.11100000.
6. Convert the binary values to their equivalent decimal values using the following rules:
-
- For "1111111" octet, write "255."
- For "00000000" octet, write "0."
- If the octet contains both "1" and "0" use the formula: Integer number = (128 x n) + (64 x n) + (32 x n) + (16 x n) + (8 x n) + (4 x n) + (2 x n) + (1 x n), Where "n" is either 1 or 0 in the corresponding position in the octet sequence.
7. If we convert the IP 11111111.11111111.11111111.11100000 into binary using the above rules, we get:
-
- 11111111 = 255
- 11111111 = 255
- 11111111 = 255
- 11100000 - (128 x 1) + (64 x 1) + (32 x 1) + (16 x 1) + (8 x n) + (4 x 0) + (2 x 0) + (1 x 0) = 224
Hence, the IP Subnet Mask = 255.255.255.224
3. How Do You Subnet for Dummies?
Each class of IP address has its default subnet mask. The following table offers a simple subnet cheat sheet:
Class |
Network prefix |
Dotted-Decimal |
First Octet |
Second Octet |
Third Octet |
Fourth Octet |
Class A |
/8 |
255.0.0.0 |
11111111 |
0 |
0 |
0 |
Class B |
/16 |
255.255.0.0 |
11111111 |
11111111 |
0 |
0 |
Class C |
/24 |
255.255.255.0 |
11111111 |
11111111 |
11111111 |
0 |
4. How Many IPS Are in a 252 Subnet?
The .252 subnet mask permits up to 64 subnets with enough host addresses for two hosts per subnet.
People are also reading: