This tutorial explains the easiest and fastest method of subnetting through 100+ examples. You can use these methods to solve subnetting-related questions in less than a minute in any exam or interview.

There are three types of subnetting questions you may be asked in an exam or interview.

- Calculate the number of networks and host addresses in a given IP subnet.
- Find the network ID and broadcast ID of a given IP subnet.
- Identify the subnet mask of a given IP subnet.

## Calculating networks and host addresses

In these types of questions, we need to calculate the total number of IP subnets and host addresses we can get from a given IP subnet.

The following table lists some example IP subnets. We will calculate the total number of subnets we can get from each subnet and the total number of host addresses and valid host addresses in each created subnet.

10.0.0.0/10 | 130.0.0.0/18 | 192.168.1.0/26 |

20.12.0.0/13 | 140.50.60.0/20 | 200.0.0.0/27 |

78.59.12.0/16 | 172.168.1.0/24 | 210.200.0.0/28 |

112.15.0.0/24 | 180.10.20.0/28 | 215.0.0.0/29 |

122.14.25.0/28 | 185.0.0.0/30 | 220.220.10.0/30 |

In the first step, we determine the IP class of the given IP subnet. An IP address consists of 32 bits. These bits are divided into four sections. Sections are separated by a dot. Each section contains 8 bits. 8 bits are equal to 1 byte or 1 octet.

We use the first octet's value to determine the IP class.

Value in the First octet | Class |

0 - 127 | A |

128 - 191 | B |

192 - 223 | C |

An IP address contains network and host bits. In slash notation, we write the number of network bits with the IP address.

Class | Reserved network bits | Default subnet mask (Decimal notation) | Default subnet mask (Slash notation) |

A | 8 | 255.0.0.0 | /8 |

B | 16 | 255.255.0.0 | /16 |

C | 24 | 255.255.255.0 | /24 |

If we subtract the network bits from the total IP bits, we get the host bits.

Host bits = 32 - Network bits

Each IP class has reserved network bits in all IP addresses. We cannot use reserved network bits for subnetting. We can use only host bits for subnetting.

If we subtract the given network bits from the reserved network bits, we get the host bits used in subnetting.

Number of host bits used in subnetting = Total bits used in network portion – Reserved bits for the network portion

Given IP subnet | Network bits (Value after the slash) | IP Class | Reserved network bits | Host bits used as network bits | Available host bits 32 - network bits |

10.0.0.0/10 | 10 | A | 8 | 10 - 8 = 2 | 32 – 10 = 22 |

20.12.0.0/13 | 13 | A | 8 | 13 – 8 = 5 | 32 – 13 = 19 |

78.59.12.0/16 | 16 | A | 8 | 16 – 8 = 8 | 32 – 16 = 16 |

112.15.0.0/24 | 24 | A | 8 | 24 – 8 = 16 | 32 – 24 = 8 |

122.14.25.0/28 | 28 | A | 8 | 28 – 8 = 20 | 32 – 28 = 4 |

130.0.0.0/18 | 18 | B | 16 | 18 – 16 = 2 | 32 – 18 = 14 |

140.50.60.0/20 | 20 | B | 16 | 20 – 16 = 4 | 32 – 20 = 12 |

172.168.1.0/24 | 24 | B | 16 | 24 – 16 = 8 | 32 – 24 = 8 |

180.10.20.0/28 | 28 | B | 16 | 28 – 16 = 12 | 32 – 28 = 4 |

185.0.0.0/30 | 30 | B | 16 | 30 – 16 = 14 | 32 – 30 = 2 |

192.168.1.0/26 | 26 | C | 24 | 26 - 24 = 2 | 32 – 26 = 6 |

200.0.0.0/27 | 27 | C | 24 | 27 – 24 = 3 | 32 – 27 = 5 |

210.200.0.0/28 | 28 | C | 24 | 28 – 24 = 4 | 32 – 28 = 4 |

215.0.0.0/29 | 29 | C | 24 | 29 – 24 = 5 | 32 – 29 = 3 |

220.220.10.0/30 | 30 | C | 24 | 30 – 24 = 6 | 32 – 30 = 2 |

Once we know how many host bits are used as network bits to create additional networks, we can use the following formulas to calculate the number of networks, total hosts, and valid hosts.

Number of networks (subnet) = 2^{N}Number of total host addresses in each network = 2^{H}Number of valid host addresses in each network = 2^{H}– 2

Here, N is the number of host bits used as network bits to create additional subnets, and H is the available host bits.

Given Address | Host bits used as network bits | Available host bits | Networks (Subnets) | Total hosts | Valid hosts |

10.0.0.0/10 | 2 | 22 | 4 (2^{2}) | 4194304 (2^{22}) | 4194302 (4194304 – 2) |

20.12.0.0/13 | 5 | 19 | 32 (2^{5}) | 524288 (2^{19}) | 524286 (524288 - 2) |

78.59.12.0/16 | 8 | 16 | 256 (2^{8}) | 65536 (2^{16}) | 65534 (65536 - 2) |

112.15.0.0/24 | 16 | 8 | 65536 (2^{16}) | 256 (2^{8}) | 254 (256 - 2) |

122.14.25.0/28 | 20 | 4 | 1048576 (2^{20}) | 16 (2^{4}) | 14 (16 - 2) |

130.0.0.0/18 | 2 | 14 | 4 (2^{2}) | 16384 (2^{14}) | 16382 (16384 -2) |

140.50.60.0/20 | 4 | 12 | 16 (2^{4}) | 4096 (2^{12}) | 4094 (4096 -2) |

172.168.1.0/24 | 8 | 8 | 256 (2^{8}) | 256 (2^{8}) | 254 (256 -2) |

180.10.20.0/28 | 12 | 4 | 4096 (2^{12}) | 16 (2^{4}) | 14 (16 -2) |

185.0.0.0/30 | 14 | 2 | 16384 (2^{14}) | 4 (2^{2}) | 2 (4 -2) |

192.168.1.0/26 | 2 | 6 | 4 (2^{2}) | 64 (2^{6}) | 62 (64 -2) |

200.0.0.0/27 | 3 | 5 | 8 (2^{3}) | 32 (2^{5}) | 30 (32 -2) |

210.200.0.0/28 | 4 | 4 | 16 (2^{4}) | 16 (2^{4}) | 14 (16 - 2) |

215.0.0.0/29 | 5 | 3 | 32 (2^{5}) | 8 (2^{3}) | 6 (8 -2) |

220.220.10.0/30 | 6 | 2 | 64 (2^{6}) | 4 (2^{2}) | 2 (4 -2) |

## Finding address type, network ID, and broadcast ID

In these types of questions, we need to find out three things: address type, network ID, and broadcast ID from the given IP address.

Let us take some example IP addresses and find their address type, network ID, and broadcast ID.

10.0.0.0/8 | 50.100.255.255/20 | 150.60.180.0/19 | 192.168.1.240/25 |

10.48.0.0/12 | 1.1.8.255/23 | 160.0.39.255/21 | 200.20.10.191/26 |

20.42.255.255/13 | 100.100.100.110/25 | 172.168.8.0/24 | 210.200.20.100/27 |

30.6.1.0/16 | 110.80.20.128/27 | 180.78.0.64/28 | 215.0.0.47/28 |

40.60.240.0/17 | 120.20.30.15/30 | 185.0.0.26/29 | 220.10.10.50/29 |

In the first step, we find the interesting octet. The interesting octet is the octet in which the network address separates from the host address in the IP address.

If we know the number of network bits, we can easily find the octet in which network bits separate from the host bits. For example, if an IP address has the /15 subnet mask in the slash notation, it has 15 network bits. The number 15 comes in the second octet's range (9 - 16). Hence, the interesting octet will be the second octet.

Network bits range | Interesting octet |

0 - 8 | First |

9 - 16 | Second |

17 - 24 | Third |

25 - 32 | Fourth |

After finding the interesting octet, we take the following steps to find the type of the IP address.

- If the octet comes before the interesting octet, we write it as it is.
- If the octet comes after the interesting octet, we write 0 in the network address and 255 in the broadcast address.
- In the interesting octet, we write a placeholder character X. We will calculate its value in the next step.

Given IP address | Value after slash | Interesting octet | Network address | Broadcast Address |

10.0.0.0/8 | /8 | First (1-8) | X.0.0.0 | X.255.255.255 |

10.48.0.0/12 | /12 | Second (9-16) | 10.X.0.0 | 10.X.255.255 |

20.42.255.255/13 | /13 | Second (9-16) | 20.X.0.0 | 20.X.255.255 |

30.6.1.0/16 | /16 | Second (9-16) | 30.X.0.0 | 30.X.255.255 |

40.60.240.0/17 | /17 | Third (17-24) | 40.60.X.0 | 40.60.X.255 |

50.100.255.255/20 | /20 | Third (17 -24) | 50.100.X.0 | 50.100.X.255 |

1.1.8.255/23 | /23 | Third (17-24) | 1.1.X.0 | 1.1.X.255 |

100.100.100.110/25 | /25 | Fourth (25 -32) | 100.100.100.X | 100.100.100.X |

110.80.20.128/27 | /27 | Fourth (25-32) | 110.80.20.X | 110.80.20.X |

120.20.30.15/30 | /30 | Fourth (25-32) | 120.20.30.X | 120.20.30.X |

150.60.180.0/19 | /19 | Third (17-24) | 150.60.X.0 | 150.60.X.255 |

160.0.39.255/21 | /21 | Third (17-24) | 160.0.X.0 | 160.0.X.255 |

172.168.8.0/24 | /24 | Third (17-24) | 172.168.X.0 | 172.168.X.255 |

180.78.0.64/28 | /28 | Fourth (25-32) | 180.78.0.X | 180.78.0.X |

185.0.0.26/29 | /29 | Fourth (25-32) | 185.0.0.X | 185.0.0.X |

192.168.1.240/25 | /25 | Fourth (25-32) | 192.168.1.X | 192.168.1.X |

200.20.10.191/26 | /26 | Fourth (25-32) | 200.20.10.X | 200.20.10.X |

210.200.20.100/27 | /27 | Fourth (25-32) | 210.200.20.X | 210.200.20.X |

215.0.0.47/28 | /28 | Fourth (25-32) | 215.0.0.X | 215.0.0.X |

220.10.10.50/29 | /29 | Fourth (25-32) | 220.10.10.X | 220.10.10.X |

Subtract the number of network bits (value after slash) from the ending number of the interesting octet's range.

- Subtract it from 8 if the interesting octet is the first octet.
- Subtract it from 16 if the interesting octet is the second octet.
- Subtract it from 24 if the interesting octet is the third octet.
- Subtract it from 32 if the interesting octet is the fourth octet.

Given IP address | Value after slash | Interesting octet | Ending value of range | Subtraction |

10.0.0.0/8 | /8 | First(1-8) | 8 | 8 – 8 = 0 |

10.48.0.0/12 | /12 | Second (9-16) | 16 | 16 – 12 = 4 |

20.42.255.255/13 | /13 | Second (9-16) | 16 | 16 – 13 = 3 |

30.6.1.0/16 | /16 | Second (9-16) | 16 | 16 – 16 = 0 |

40.60.240.0/17 | /17 | Third (17-24) | 24 | 24 – 17 = 7 |

50.100.255.255/20 | /20 | Third (17 -24) | 24 | 24 - 20 = 4 |

1.1.8.255/23 | /23 | Third (17-24) | 24 | 24 – 23 = 1 |

100.100.100.110/25 | /25 | Fourth (25 -32) | 32 | 32 – 25 = 7 |

110.80.20.128/27 | /27 | Fourth (25-32) | 32 | 32 – 27= 5 |

120.20.30.15/30 | /30 | Fourth (25-32) | 32 | 32 – 30 = 2 |

150.60.180.0/19 | /19 | Third (17-24) | 24 | 24 – 19 = 5 |

160.0.39.255/21 | /21 | Third (17-24) | 24 | 24 – 21 = 3 |

172.168.8.0/24 | /24 | Third (17-24) | 24 | 24 – 24 = 0 |

180.78.0.64/28 | /28 | Fourth (25-32) | 32 | 32 – 28 = 4 |

185.0.0.26/29 | /29 | Fourth (25-32) | 32 | 32 – 29 = 3 |

192.168.1.240/25 | /25 | Fourth (25-32) | 32 | 32 – 25 = 7 |

200.20.10.191/26 | /26 | Fourth (25-32) | 32 | 32 – 26 = 6 |

210.200.20.100/27 | /27 | Fourth (25-32) | 32 | 32 – 27 = 5 |

215.0.0.47/28 | /28 | Fourth (25-32) | 32 | 32 – 28 = 4 |

220.10.10.50/29 | /29 | Fourth (25-32) | 32 | 32 – 29 = 3 |

In the next step, we calculate the block size. We use the remainder of the previous subtraction to calculate the block size.

Block size = 2^{Remainder of the subtraction}

Given IP address | Interesting octet | Remainder of the subtraction | Block Size |

10.0.0.0/8 | First | 0 | (2^{0}) = 1 |

10.48.0.0/12 | Second | 4 | (2^{4}) = 16 |

20.42.255.255/13 | Second | 3 | (2^{3}) = 8 |

30.6.1.0/16 | Second | 0 | (2^{0}) = 1 |

40.60.240.0/17 | Third | 7 | (2^{7}) = 128 |

50.100.255.255/20 | Third | 6 | (2^{4}) = 16 |

1.1.8.255/23 | Third | 1 | (2^{1}) = 2 |

100.100.100.110/25 | Fourth | 7 | (2^{7}) = 128 |

110.80.20.128/27 | Fourth | 5 | (2^{5}) = 32 |

120.20.30.15/30 | Fourth | 2 | (2^{2}) = 4 |

150.60.180.0/19 | Third | 5 | (2^{5}) = 32 |

160.0.39.255/21 | Third | 3 | (2^{3}) = 8 |

172.168.8.0/24 | Third | 0 | (2^{0}) = 1 |

180.78.0.64/28 | Fourth | 4 | (2^{4} ) = 16 |

185.0.0.26/29 | Fourth | 3 | (2^{3}) = 8 |

192.168.1.240/25 | Fourth | 7 | (2^{7}) = 128 |

200.20.10.191/26 | Fourth | 6 | (2^{6}) = 64 |

210.200.20.100/27 | Fourth | 5 | (2^{5}) = 32 |

215.0.0.47/28 | Fourth | 4 | (2^{4}) = 16 |

220.10.10.50/29 | Fourth | 3 | (2^{3}) = 8 |

In the next step, we count in block size until the interesting octet's value comes in the block size's range. Each block size has a range of numbers. The interesting octet's value must be in this range. For example, if the interesting octet's value is 27 and the block size is 8, the range will be 24-31 (0-7, 8-15, 16-23, **24-31**).

The block size range starts from 0 and increases in multiple of the block size. For example, if the block size is 4, the numbers in the first range will be 0, 1, 2, and 3.

Given IP address | Interesting octet | Interesting octet's value | Block size | Range in block size which cover the value of the interesting octet |

10.0.0.0/8 | First | 10 | 1 | 0-0, 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 |

10.48.0.0/12 | Second | 48 | 16 | 0-15, 16-31, 32-47, 48-63 |

20.42.255.255/13 | Second | 42 | 8 | 0-7, 8-15, 16-23, 24-31, 32-39, 40-47 |

30.6.1.0/16 | Second | 6 | 1 | 0-0, 1-1, 2-2, 3-3, 4-4, 5-5, 6-6 |

40.60.240.0/17 | Third | 240 | 128 | 0-127, 128-255 |

50.100.255.255/20 | Third | 255 | 16 | 0-15, 16-31, 32-47,..... 224-239, 240-255 |

1.1.8.255/23 | Third | 8 | 2 | 0-1, 2-3, 4-5, 6-7, 8-9 |

100.100.100.110/25 | Fourth | 110 | 128 | 0-127,128-255 |

110.80.20.128/27 | Fourth | 128 | 32 | 0-31, 32-63, 64-95, 96 -127, 128-159 |

120.20.30.15/30 | Fourth | 15 | 4 | 0-3, 4-7, 8-11, 12-15 |

150.60.180.0/19 | Third | 180 | 32 | 0-31, 32-63, 64-95, 96 -127, 128-159, 160 - 191 |

160.0.39.255/21 | Third | 39 | 8 | 0-7, 8-15, 16-23, 24-31, 32-39 |

172.168.8.0/24 | Third | 8 | 1 | 0-0, 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8 |

180.78.0.64/28 | Fourth | 64 | 16 | 0-15, 16-31, 32-47, 48-63, 64-79 |

185.0.0.26/29 | Fourth | 26 | 8 | 0-7, 8-15, 16-23, 24-31 |

192.168.1.240/25 | Fourth | 240 | 128 | 0-127, 128-255 |

200.20.10.191/26 | Fourth | 191 | 64 | 0-63, 64-127, 128- 191 |

210.200.20.100/27 | Fourth | 100 | 32 | 0-31, 32-63, 64-95, 96 -127 |

215.0.0.47/28 | Fourth | 47 | 16 | 0-15, 16-31, 32-47 |

220.10.10.50/29 | Fourth | 50 | 8 | 0-7, 8-15, 16-23, 24-31, 32-39, 40-47, 48- 55 |

In the next step, we update the placeholder value. Update the placeholder value as the following.

- In the network address, replace the placeholder value with the starting value of the range.
- In the broadcast address, replace the placeholder value with the ending value of the range.

After updating the placeholder value, you can easily determine the address type of the given address.

- If the given address exactly matches the network address, it is a network address.
- If the given address exactly matches the broadcast address, it is a broadcast address.
- If the given address is neither a network address nor a broadcast address, it is a valid host address.

Given IP address | Interesting octet | Interesting octet value | Block range | Network address | Broadcast address | Type |

10.0.0.0/8 | First | 10 | 10-10 | 10.0.0.0 | 10.255.255.255 | Network |

10.48.0.0/12 | Second | 48 | 48-63 | 10.48.0.0 | 10.63.255.255 | Network |

20.42.255.255/13 | Second | 42 | 40-47 | 20.40.0.0 | 20.47.255.255 | Valid host |

30.6.1.0/16 | Second | 6 | 6-6 | 30.6.0.0 | 30.6.255.255 | Valid host |

40.60.240.0/17 | Third | 240 | 128-255 | 40.60.128.0 | 40.60.255.255 | Valid Host |

50.100.255.255/20 | Third | 255 | 240-255 | 50.100.240.0 | 50.100.255.255 | Broadcast |

1.1.8.255/23 | Third | 8 | 8-9 | 1.1.8.0 | 1.1.9.255 | Valid host |

100.100.100.110/25 | Fourth | 110 | 0-127 | 100.100.100.0 | 100.100.100.127 | Valid Host |

110.80.20.128/27 | Fourth | 128 | 128-159 | 110.80.20.128 | 110.80.20.159 | Network |

120.20.30.15/30 | Fourth | 15 | 12-15 | 120.20.30.12 | 120.20.30.15 | Broadcast |

150.60.180.0/19 | Third | 180 | 160 - 191 | 150.60.160.0 | 150.60.191.255 | Valid host |

160.0.39.255/21 | Third | 39 | 32-39 | 160.0.32.0 | 160.0.39.255 | Broadcast |

172.168.8.0/24 | Third | 8 | 8-8 | 172.168.8.0 | 172.168.8.255 | Network |

180.78.0.64/28 | Fourth | 64 | 64-79 | 180.78.0.64 | 180.78.0.79 | Network |

185.0.0.26/29 | Fourth | 26 | 24-31 | 185.0.0.24 | 185.0.0.31 | Valid host |

192.168.1.240/25 | Fourth | 240 | 128-255 | 192.168.1.128 | 192.168.1.255 | Valid host |

200.20.10.191/26 | Fourth | 191 | 128- 191 | 200.20.10.128 | 200.20.10.191 | Broadcast |

210.200.20.100/27 | Fourth | 100 | 96 -127 | 210.200.20.96 | 210.200.20.127 | Valid host |

215.0.0.47/28 | Fourth | 47 | 32-47 | 215.0.0.32 | 215.0.0.47 | Broadcast |

220.10.10.50/29 | Fourth | 50 | 48- 55 | 220.10.10.48 | 220.10.10.55 | valid host |

## Calculating the subnet mask of a given IP address

In these types of questions, we calculate the subnet mask of a given IP address.

Let us take some example IP addresses and calculate their subnet masks.

20.10.30.0/8, 111.187.45.34/14, 162.160.46.24/20, 202.100.20.50/27

In the first step, we find the interesting octet.

Given IP address | Value after slash | Interesting octet |

20.10.30.0/8 | 8 | First |

111.187.45.34/14 | 14 | Second |

162.160.46.24/20 | 20 | Third |

202.100.20.50/27 | 27 | Fourth |

In the second step, we build a temporary subnet mask based on the interesting octet.

- If the octet comes before the interesting octet, we write 255.
- If the octet comes after the interesting octet, we write 0.
- In the interesting octet, we write a placeholder character X.

Given IP address | Value after slash | Interesting octet | Temporary mask |

20.10.30.0/8 | 8 | First | X.0.0.0 |

111.187.45.34/14 | 14 | Second | 255.X.0.0 |

162.160.46.24/20 | 20 | Third | 255.255.X.0 |

202.100.20.50/27 | 27 | Fourth | 255.255.255.X |

Subtract the given network number (value after slash) from the interesting octet's range's ending number.

Given IP address | Value after slash | Interesting octet | Interesting octet range | Subtraction |

20.10.30.0/8 | 8 | First | 1 – 8 | 8 – 8 = 0 |

111.187.45.34/14 | 14 | Second | 9 – 16 | 16 – 14 = 2 |

162.160.46.24/20 | 20 | Third | 17 – 24 | 24 -20 = 4 |

202.100.20.50/27 | 27 | Fourth | 25 – 32 | 32 – 27 = 5 |

Use the following formula to calculate the interesting octet's value.

Interesting octet's value = 256 - 2^{Remainder of the subtraction}

Given IP address | Value after slash | Remainder of the subtraction | Calculation Step 1 | Calculation step 2 |

20.10.30.0/8 | 8 | 0 | 2^{0} = 1 | 256 – 1 = 255 |

111.187.45.34/14 | 14 | 2 | 2^{2} = 4 | 256 – 4 = 252 |

162.160.46.24/20 | 20 | 4 | 2^{4} = 16 | 256 – 16 = 240 |

202.100.20.50/27 | 27 | 5 | 2^{5} = 32 | 256 – 32 = 224 |

Replace the placeholder value with the interesting octet's value. It gives us the subnet mask of the given IP address.

Given IP addressk | Value after slash | Temporary mask | Octet value | Subnet mask |

20.10.30.0/8 | 8 | X.0.0.0 | 255 | 255.0.0.0 |

111.187.45.34/14 | 14 | 255.X.0.0 | 252 | 255.252.0.0 |

162.160.46.24/20 | 20 | 255.255.X.0 | 240 | 255.255.240.0 |

202.100.20.50/27 | 27 | 255.255.255.X | 224 | 255.255.255.224 |

This tutorial is the seventh chapter of the tutorial series. Other chapters of this series are the following.

**Chapter 01** Introduction to Subnetting
**Chapter 02** Network Address Basic Concepts Explained with Examples
**Chapter 03** The Subnet Mask and Slash Notation
**Chapter 04** Convert Decimal IP address in Binary and Binary in Decimal
**Chapter 05** Basic Subnetting in Computer Networks Explained
**Chapter 06** Subnetting Tutorial - Subnetting Explained with Examples
**Chapter 08** FLSM Subnetting and VLSM Subnetting
**Chapter 09** VLSM Subnetting Explained with Examples
**Chapter 10** VLSM Subnetting Examples and Calculation Explained
**Chapter 11** Route Summarization Advantages and Disadvantages
**Chapter 12** Supernetting Tutorial: - Supernetting Explained with Examples

That's all for this tutorial. In this tutorial, we learned the easiest and fastest methods of subnetting through various examples.