#### Subnetting Solution

In my previous article, I described the theory behind planning and calculating IP subnets. Since this is a skill, it is imperative that every network engineer is able to put them into practice. I have received a lot of questions and participated in numerous discussions on the Internet over the years, and it seems that this area of expertise is a bit intimidating for many people. This stems from the fact that knowing the rules does not necessarily mean that one can apply them quickly.

In this article, I would like to shed some light on the different types of problems regarding subnet calculations. I hope that through detailed analysis of those issues and then applying the appropriate strategy, you will gain confidence in solving them quickly and efficiently. I assume that you can classify the addresses to the appropriate class using the so called ‘first octet rule’. For details, please read my previous article.

Before we get started, we need to be good friends with the cheat sheet we are going to use:

Pic. 1 – Binary/Decimal/Subnet Cheat Sheet.

There are two important pieces of information that the chart in Pic. 1 contains:

- The ‘exponent’ of the base 2 in each particular column shows us the number of combinations we have for a particular number of bits. For instance, 2 raised to the power of 2 is equal to 4. It provides the following unique combinations:

00

01

10

11

The number of combinations is going to tell us how many subnets or host values we can expect to have, given the number of bits available for them (the actual rules are presented below).

- The second part of the chart (byte and network mask values) is going to be helpful in converting the binary mask length into its decimal value. For instance,

11111111.11111111.11111111.**1111**0000 will be equal to 255.255.255.**240** in decimal.

Notice, that the fourth byte in the network mask has four bits set to ’1′. If you look at the chart, its value is 240 (128+64+32+16).

Below is a quick reminder of the two major rules governing the number of subnet valid host addresses available given the particular network mas length.

Pic. 2 – Number of Available Subnet Cheat Sheet

Pic. 3 – Number of Available Valid Host Addresses Cheat Sheet

Properly equipped, we can now tackle particular problems.

**Question 1
**

What are the subnet addresses of the following prefix 192.168.1.0/28? How many hosts can exist in a single subnet with this prefix?

**Analysis and Solution
**

All IPv4 addresses are 32 bits in length. Masking 28 bits (network/subnet bits) leaves only 4 bits for hosts (4 unmasked = host bits). In our cheat sheet we see that 2^{4} = 16 bit combinations. This means that the subnet addresses will be incremented every 16 values. Starting at the number of 0, here’s what we get:

Subnet 1: 192.168.1.**0**/28

Subnet 2: 192.168.1.**16**/28 (0+16=16)

Subnet 3: 192.168.1.**32**/28 (16+16=32)

Subnet 4: 192.168.1.**48**/28 (32+16=32)

etc.

You can look at this from a different angle as well. Notice that the least significant bit in the

Another way of looking at this problem is to examinethe value of the least significant bit that the network mask used. Look at the mask below. The red bit is the least significant bit of our subnet mask. Notice that the red bit is the fourth bit set if you go from the right hand side in our cheat sheet (Pic.1). Its value (weight) is **16**.

Mask /28 = 11111111.11111111.11111111.111**1**0000.

Ether way, we come to the exact same conclusion: using /28 bit, subnet addresses will be incremented by the value of 16.

This stems from the fact that address 192.168.1.0 belongs to class C addresses which originally uses 24 network bits. Our mask uses 28 bits, which means that 4 additional bits were borrowed from the host portion. Using 4 bits we have 16 combinations (2^{4} = 16), hence we can create 16 subnets.

As for the second part of the question, the number of hosts in a given subnet is 14 (take a look at the **rule 2** illustrated in Pic. 3). Since we have only 4 host bits in the subnet (bits not masked), that gives us 2^{4} – 2 = 16 – 2 = **14 hosts**.

Incidentally, there are three important facts I would like you to be aware of:

- A subnet address + 1 = 1
^{st}host address.

- The next available subnet address – 1 = the broadcast address of a given subnet.

- The next available subnet – 2 = the last host address in a given subnet (or the current subnet broadcast address – 1).

Following these observations, let’s use the 3^{rd} subnet and calculate all the addresses:

3^{rd} Subnet Addressing:

Subnet address = 192.168.1.**32**/28 (subnet address)

1^{st} host address = 192.168.1.**33**/28 (subnet address + 1)

Last host address = 192.168.1.**46**/28 (current broadcast address – 1)

Broadcast address = 192.168.1.**47**/28 (broadcast address = the next subnet address – 1)

Make sure that you fully understand the above facts. They will speed up your exam calculations tenfold.

**Question 2
**

Given the prefix 172.16.0.0/18, how many subnets can you create?

**Analysis and Solution
**

Although this type of question is very easy to answer, it confuses a lot of people. The problem is that many people do not interpret this question properly, and as a result they use the wrong approach to solve it.

First thing we should do is define what the keyword ‘subnet’ means. If we can define it, the rule 1 (Pic. 2) holds our answer.

**Subnet** is the prefix (address/mask) which borrows bits from the host portion in order to create more network addresses and has all the host bits set to ’0′. In other words, if you have the address 172.16.0.0, it belongs to class B. This class uses 16 bits to identify the network address. In our question, the prefix uses 18 bits. This means that 2 bits have been borrowed from the host portion (16+**2**=18).

The answer is then very easy if we look at rule 1 (pic. 2):

2^{2} = **4. **172.16.0.0/18 allows us to create 4 subnets.

**Question 3
**

The host has an IP address of 172.16.179.237/19. What are the subnet and broadcast addresses in the subnet where this host resides?

**Analysis and Solution
**

There are many ways of solving this problem. However, during the exam, time is of the essence. In addition to this, you are not allowed to use a calculator, which slows things down a bit. Here’s one quick approach you can use to quickly find the solution.

Step 1

Determine which byte of IP address creates the boundary between the network and host portion. Using 19 bits as the network mask length, that boundary is on the third bit of the third byte:

**11111111.11111111.11100000.00000000
**

The value (weight) of this bit is **32** which becomes the subnet increment.

Step 2

Next, find what is the closest value to 179 (our 3^{rd} byte of the address which separates network from hosts) that does not exceed it. You can use two methods here. Use the fastest to get you there in a given exam question.

Method 1

Start at 0 and add 32 (our subsequent subnet increment) to each subsequent number until you find the closest to 179 but does not exceed it: 0, 32, 64, 96, 128, **160**, 196.

This is your subnet address: **172.16.160.0/19.**

Method 2

Divide 179 by 32 and, ignoring the remainder, multiply 32 by the number you have received.

179 : 32 = 5 remainder 5 (ignore the remainder)

32 x 5 = **160**

This is your subnet address: **172.16.160.0/19.**

Remember: all host bits set to ’0′ form the subnet (wire) address.

Step 3

Determine the broadcast address by using the next available subnet address and take away 1 on the boundary byte (network/host). If there are more bytes available on the right hand side, set all bits to 1 in binary.

Then next available subnet address (current subnet: .160.0 + increment 32) is: **172.16.192.0/19 **(160+32=192).

Step 4

Set all host bits to 1 (in binary) to achieve the broadcast address. Notice that our third byte already has the hosts bit set to 1 (next subnet address – 1). Only the last byte must be set to 1 in binary (11111111 = 255).

The broadcast address is: **172.16.191.255/19**.

**Question 4
**

The network consists of 525 hosts. What should be the network mask length used to accommodate them?

You can re-phrase this question like this:

“How many host bits do you need to get the number 525?”

We may feel a bit confused here since we typically operate within the byte boundary. However, if you look at pic. 1 (our cheat sheet), you will notice that each column’s number is the previous column * 2. Since 2^{8} = 256, then 2^{9} = 512 (still not enough). If we use ten bits: 2^{10} = 1024, we have 1024 – 2 = 1022 valid host addresses. This is as close as we can get to 525 hosts.

We need 10 host bits to accommodate 525 hosts which is **22 bit mask length** or **/22** (32 – 10 = 22).

In binary it looks like this: 11111111.11111111.11111**1**00.00000000. If we help ourselves using the cheat sheet in pic. 1, we know that in decimal /22 = 255.255.**252**.0 (pic.1).

**Question 5
**

Use 192.168.1.0/24 to address the following five subnets. Maximize the network mask length to accommodate the number of hosts specified below:

Subnet 1 = 76 hosts

Subnet 2 = 40 hosts

Subnet 3 = 16 hosts

Subnet 4 = 2 hosts (point-to-point network)

Subnet 5 = 2 hosts (point-to-point network)

**Analysis and solution
**

In order to solve the problem, you can use the following recipe:

Step 1

Determine the length of the network mask given the number of host required. Start with the largest number of hosts and work your way down to the lowest number.

Subnet 1 = 76 hosts (look at the cheat sheet in pic. 1)

2^{6} = 64 (62 valid host addresses is not enough; we must take away 2 values: one for broadcast and one for subnet/wire as illustrated in pic. 3)

2^{7} = 128 (126 valid host addresses is the closest number)

Result:

Subnet 1 mask is **/25 or 255.255.255.128 **(32 – 7 = 25)**.**

Subnet 2 = 40 hosts

2^{6} = 64 (62 valid host addresses)

Result:

Subnet 2 mask is **/26 or 255.255.255.192** (32 – 6 = 26).

Subnet 3 = 16 hosts

2^{5} = 32 (30 valid host addresses)

Notice that 4 host bits is not enough since 24 > 16, but we must take away 2 addresses which only gives us 14 valid host addresses.

Result:

Subnet 3 mask is **/27 or 255.255.255.224** (32 – 5 = 27).

Subnet 4 = 2 hosts

2^{2} = 4 (2 valid host addresses)

Result:

Subnet 3 mask is **/30 or 255.255.255.252** (32 – 2 = 30).

Subnet 5 = 2 hosts

2^{2} = 4 (2 valid host addresses)

Result:

Subnet 3 mask is **/30 or 255.255.255.252** (32 – 2 = 30).

Summarizing our calculations, we get the following:

Subnet 1

Mask length: /25

Mask in decimal: 255.255.255.128

Subnet Increment: 128

Subnet 2

Mask length: /26

Mask in decimal: 255.255.255.192

Subnet Increment: 64

Subnet 3

Mask length: /27

Mask in decimal: 255.255.255.224

Subnet Increment: 32

Subnet 4

Mask length: /30

Mask in decimal: 255.255.255.252

Subnet Increment: 4

Subnet 5

Mask length: /30

Mask in decimal: 255.255.255.252

Subnet Increment: 4

Step 2

Determine the Subnet addresses based on the results found in step 1.

Subnet 1

192.168.1.**0**/25

Subnet 2

192.168.1.**128**/26

Subnet 1 address + its increment: 0 + 128 = 128

Subnet 3

192.168.1.**192**/27

Subnet 2 address+ its increment: 128 + 64 = 192

Subnet 4

192.168.1.**224**/30

Subnet 3 address+ its increment: 192 + 32 = 224

Subnet 5

192.168.1.**228**/30

Subnet 4 address+ its increment: 224 + 4 = 228

Step 3

Create addressing for all subnets. Again, let me remind you about a few facts which speed up the process:

- Current subnet number + 1 = 1^{st} host address

- Next subnet number – 1 = current broadcast address

- Current broadcast – 1 = last host address

If you use these rules, the result looks like the one below:

Subnet 1

Address: 192.168.1.0/25

1^{st} host: 192.168.1.1/25

Last host: 192.168.1.126/25

Broadcast: 192.168.1.127/25

Subnet 2

Address: 192.168.1.128/26

1^{st} host: 192.168.1.129/26

Last host: 192.168.1.190/26

Broadcast: 192.168.1.191/26

Subnet 3

Address: 192.168.1.192/27

1^{st} host: 192.168.1.193/27

Last host: 192.168.1.122/27

Broadcast: 192.168.1.223/27

Subnet 4

Address: 192.168.1.224/30

1^{st} host: 192.168.1.225/30

Last host: 192.168.1.226/30

Broadcast: 192.168.1.227/30

Subnet 5

Address: 192.168.1.228/30

1^{st} host: 192.168.1.229/30

Last host: 192.168.1.230/30

Broadcast: 192.168.1.231/30

I hope that you have found this article useful. If you fully understand the examples I have shown here, all you need to do is to practice them a bit. Use Google to find interesting problems and try to solve them. Remember that true skill is having the knowledge and one thousand repetitions.

#### Jarek Rek

#### Latest posts by Jarek Rek (see all)

- IOS Speed Tips Part 5 - January 27, 2014
- IOS Speed Tips Part 4 (#16-20) - October 7, 2013
- IOS Speed Tips Part 3 - June 20, 2013

I am trying to study for my Network+ cert and am really struggling. Could you make your documents either .pdf or .doc/docx with a downloadable link? It would be really helpful.

Thanks a lot

Bud