Subnetting Tutorial

Welcome to the subnetting tutorial. This training session will teach you everything you need to know to pass any exam that requires TCP/IP knowledge. In addition, the methods you will learn here will allow you to not only solve subnetting questions, it will help you increase your speed and master TCP/IP concepts.

For many entry-level to intermediate computer networking exams, the need to quickly solve subnet based questions is apparent. In addition, the mastery of these concepts will give you a major advantage when you sit for the exam. For example, some have estimated that the CCNA exam has around 40% subnetting questions. When you are done with this tutorial, these questions will be no harder than simple addition or subtraction. To put this is real life terms, suppose the CCNA exam has 50 questions and you are given around 20 subnetting questions. When you learn to subnet, you should expect to ace these 20 questions. In other words, you would get 100% on 40% of the exam. This makes the remainder of your study time much more productive.

TCP/IP Subnetting Very Basic

The first thing we need to look at is - What is an IP address? How does it work?

Here is kind of a loose analogy that should make this very clear. Think of an IP address as your postal address. Let's take for example. In our analogy, each set of numbers may represent a geographic area. As we move from the left to the right, the geographic area continuously becomes more and more specific.

191 = Your State
54 = Your Town
38 = Your Apartment building
15 = Your Apartment Number

To have TCP/IP, at some point, you must have a router. It doesn't make much difference if you have a router in your house, or a router in your business. They basically provide the same functionality. To further this analogy, think of a router as a post office. If you were going to send a letter (or in this case email) to another IP address, your router will decide what to do with that message.

If you put the outgoing letter by your mail box, a few things would happen based on the destination postal address (IP Address). If the letter was being mailed to someone in your own building, the router or postal carrier would know that it does not have to leave the building (your subnet) and would send it directly.

Intra-Subnet = The postal carrier (router), would know that the destination address is local and would send it directly to the recipient. For example, if you were on IP and you mailed your letter to, the letter would never leave your building. The concept of a subnet mask, is what tells the mail carrier which addresses are within a given network. As our analogy stands right now, we don't know how many apartments are in your building. We will get into the subnet masks later, for now let's assume there are 30 apartments in your building and the building next-door also has 30 apartments.

Okay, easy enough. What happens if you want to send it to the building next-door?

Your mail carrier would take the letter to the post office in your town, and the post office would route the letter to the building next-door. This is what is called a "hop". So if your address was and you wanted to send your letter to, your local router would simply forward your request to the Post Office that knows how to get to

Now, suppose your letter was addressed to a different town in your state, let's say The process is basically the same, but it will include more "hops". In this scenario, your mail carrier would take the letter to your local post office, it would then be sent to a hub within your state, then the destination town's post office, then finally to the end recipient.

The communication process would look something like this:

  • Your Town Post Office (ISP): I don't know anything about 191.55.x.x, I only know 191.54.x.x. Therefore, I'm going to send it to the "hub" post office (in IP terms this is basically what a default route does).
  • Hub Post Office: This letter is addressed to 191.54.x.x, those addresses are serviced by the post office in the destination town.
  • Destination Town: Ok, this letter is addressed to 191.54.x.x, I know where that is so I'm going to send this letter directly to the end recipient.
Of course, this is only a loose analogy and the IP addresses used to describe the process could have been anything. The takeaway from this first lesson is the router in your home or business, simply does not know where every possible destination IP address is located.

TCP/IP Address Construct

A TCP/IP address is a 32 bit, binary number that has been converted to decimal. Whenever the word binary comes up, many people immediately become concerned. No worries, this is going to be very easy. Here are a few simple definitions to help the process:

Octet = An octet is simply a group of 8 numbers. The IP address has four octets: 191, 168, 1, and 1. I know I said there are 8 numbers and I only showed you four, but keep in mind that IP is in binary, not decimal. Each set of numbers represent 8 binary digits (zeroes or ones).

Bits = A bit is simply a single character. In other words, 32 bits equals 32 zeroes or ones.

Binary = A number system that is based on two characters - 0 & 1.

Okay, now let's convert our decimal IP address of into binary:

Remember that each octet represents eight binary digits - Each placement of those binary digits represents a decimal number. To start, let's look at a simple three digit binary number:

---- ---- ----
4 2 1

Our decimal numbers on the bottom always start with 1 and double for each placement going from right-to-left. To convert to a decimal number, we will add a 1 above every decimal number we want to add together to get to our decimal number and a zero for every number we are not going to add.

Decimal Number 3
0 1 1
---- ---- ----
4 2 1

Now we simply add each decimal number (on the bottom) each time we see a binary 1. Thus, decimal 3 = 011

Decimal 4 = Binary 100
1 0 0
---- ---- ----
4 2 1

Decimal 5 = Binary 101
1 0 1
---- ---- ----
4 2 1

Decimal 191 = Binary 10111111
1 0 1 1 1 1 1 1
---- ---- ---- ---- ---- ---- ---- ----
128 64 32 16 8 4 2 1

Decimal 54 = Binary 00110110
0 0 1 1 0 1 1 0
---- ---- ---- ---- ---- ---- ---- ----
128 64 32 16 8 4 2 1

Decimal 38 = Binary 00100110
0 0 1 0 0 1 1 0
---- ---- ---- ---- ---- ---- ---- ----
128 64 32 16 8 4 2 1

Decimal 15 = Binary 00001111
0 0 0 0 1 1 1 1
---- ---- ---- ---- ---- ---- ---- ----
128 64 32 16 8 4 2 1

191 54 38 15
10111111 00110110 00100110 00001111 = 10111111.00110110.00100110.00001111

Subnet Mask

A subnet mask is used to determine where the network ends and the hosts begin. We get this information by converting the decimal numbers within the subnet mask to binary. The 1's in our binary subnet mask represents the network portion of our IP address, and the 0's represent the hosts. Here's an example:

IP Address:

Subnet Mask:

The first thing we do is convert our first octet to binary:

1 1 1 1 1 1 1 1
---- ---- ---- ---- ---- ---- ---- ----
128 64 32 16 8 4 2 1

When we add up all the decimal numbers underneath our binary 1's, we get 255 (128+64+32+16+8+4+2+1). In this example, the next two octets are also all 1's. And as you probably have guessed the fourth and final octet in our example is all 0's or all hosts.

So in binary, is equal to:


Wherever our 1's stop and our zeros begin is called our network boundary:


In this example, the first three octets are our network and the last one represents our hosts:

Subnet =

Hosts* = - (E.g.,,, etc...)

*The number of hosts on any network is determined by taking 2 to the power of the number of binary zero's. In this example, 8 0's = 2^8 = 256. However, we have to remove the first and last address from the pool of usable addresses. We will discuss this later, for now suffice it to say that the actual formula to determine how many hosts is (2^n)-2, where n = the number of binary zero's.

In our example n=8, so we have 2^8-2=256-2=254. We have a single network with 254 usable IP addresses for hosts (PC's, printers, etc...).

Now, let's take a look at what happens if we change our subnet mask:

IP Address:

Subnet Mask:

Just like the previous example, the first thing we need to do is to determine our network boundary by converting our decimal subnet mask to binary:


Subnet =

Hosts =
Note that we can't use as a host because it is the network address and also can't be used because it is reserved for the broadcast address. However, all addresses in between the network address and the broadcast address can be assigned to hosts. Although it may look strange, addresses such as,, and are all valid host addresses in the network.

So now we can use the same formula to determine the number of assignable hosts - 16 zeros = 2^16-2 = 65,534 hosts.

IP Address Classes and Private Address Ranges

There are five classes of IP addresses:

Class Purpose First Octet Range Maximum Hosts Total Networks
Class A Very Large Networks 1-126* 16,777,216 (2^24) 128 (2^7)
Class B Large Enterprise 128-191 65,536 (2^16) 16,384 (2^14)
Class C Small Business 192-223 256 (2^8) 2,097,152 (2^21)
Class D Multicast 224-239 N/A N/A
Class E Experimental 240-255 N/A N/A

*IP addresses that begin with 127 are reserved for various functions.

Some find it easier to remember these addresses via the first binary bits of each network type:

0 = Class A
10 = Class B
110 = Class C
1110 - Class D
1111 - Class E

Private Network Ranges

Class A =
Class B =
Class C =

Subnet Mask Short-Hand

Now that we have basic subnetting figured out and know how to convert to binary, this will be a very brief section on subnet mask shorthand.

Instead of writing out a full subnet mask such as, we can shorten this to /24. To come to this number, we simply add the number of subnet bits (1's) in our subnet mask.

Subnet Mask Chart

Decimal Shorthand Binary /8 11111111.00000000.00000000.00000000 /9 11111111.10000000.00000000.00000000 /10 11111111.11000000.00000000.00000000 /11 11111111.11100000.00000000.00000000 /12 11111111.11110000.00000000.00000000 /13 11111111.11111000.00000000.00000000 /14 11111111.11111100.00000000.00000000 /15 11111111.11111110.00000000.00000000 /16 11111111.11111111.00000000.00000000 /17 11111111.11111111.10000000.00000000 /18 11111111.11111111.11000000.00000000 /19 11111111.11111111.11100000.00000000 /20 11111111.11111111.11110000.00000000 /21 11111111.11111111.11111000.00000000 /22 11111111.11111111.11111100.00000000 /23 11111111.11111111.11111110.00000000 /24 11111111.11111111.11111111.00000000 /25 11111111.11111111.11111111.10000000 /26 11111111.11111111.11111111.11000000 /27 11111111.11111111.11111111.11100000 /28 11111111.11111111.11111111.11110000 /29 11111111.11111111.11111111.11111000 /30 11111111.11111111.11111111.11111100

There is no need to memorize these, as you practice they will become second nature.

Reserved Host Addresses

As mentioned earlier, for every subnet, the first and the last IP address are reserved:

First IP Address = Network ID

Last IP Address = Broadcast Address. The broadcast address is used for a specific type of network traffic that is destined for every device attached to a network.


IP Address =
Subnet Mask =
Network ID =
Broadcast Address =
Usable IP's = -

Subnet 0

In the not too distant past, it was considered bad practice to use the first network in your subnet range. For example, if we had the IP range of, our networks would be:,,,

In this example, the first network ( would not be used. However, this command in Cisco equipment is really never used and the default Cisco settings assume subnet 0 will always be used. If you take a Cisco exam and they indicate that the subnet zero command is on, you have to remove the first network from your calculations. However, chances are this will not happen on any current exam. You should always assume the first network can be used unless you are told otherwise.

Subnet Cheat Sheet

At this point you should have the basics down pretty well. Now we will create a subnet cheat sheet and show you how to use it to solve more complicated problems.

Bits Block Size / Exponents Decimal Mask Value
0 1 255
1 2 254
2 4 252
3 8 248
4 16 240
5 32 224
6 64 192
7 128 128
8 256
9 512
10 1024
11 2048
12 4096

Create the Subnetting cheat sheet:

Bits: Begin at 0 and count all the way through 12.

Block Size / Exponents: Begin at 1 and double every subsequent row.

Decimal: Begin at 128 and add the number from the row above in column 2.

The first 8 rows of our cheat sheet represent one subnet mask octet. The remaining rows are included as a convenience so you can very quickly determine the exponents - E.g. 2^12=4096.

Putting it all Together

For this next section, I suggest you create your own cheat sheet so you do not have to scroll up to follow along. There are basically three types of subnetting questions that will be asked in our practice section, on any exam, or you need to answer in real life. We will go over these question types and show you how to use the cheat sheet to find the answer very quickly.

Question Type 1: What is the Network ID, Broadcast Address, First Usable IP, or Last Usable IP on the subnetwork that the node belongs to?

No matter which of the four criteria the question asks, you should always follow these identical steps. This makes solving the actual question very easy.

Step 1. Convert the shorthand subnet mask to decimal.

  • /26 = 255.255.255. + Two additional subnet bits.
  • Go to your cheat sheet, start at the bottom (128) and count up two, starting with 128. You should get to 192.
  • Thus, our decimal subnet mask is

Step 2. Determine the block size.

  • The block size is listed in the block size column parallel to your decimal mask.
  • The block size is 64.

Step 3. What is my Network ID?

  • Since we are working in the fourth octet and the block size is 64, the first network is

Step 4. What is the next Network ID?

  • Again, we look at our block size of 64 to determine the next network is
  • Network ID (First IP in the subnet):
  • Broadcast address (last IP in the subnet):
  • First Usable IP (the address after the network ID):
  • Last Usable IP (the address before the broadcast address):

Notes: The block size determines the networks. Since the block size is 64, our networks are,,, and To determine your network, you just have to find the range that includes your IP address. In this example, it is the first network. If your IP was, you would belong to the second network -

Let's quickly go through one more: Enter the last valid host on the network that the host is a part of:

Step 1. Convert the shorthand subnet mask to decimal.

  • /23 = 255.255. + Seven additional subnet bits.
  • Go to your cheat sheet, start at the bottom (128) and count up seven, starting with 128. You should get to 254.
  • Thus, our decimal subnet mask is

Step 2. Determine the block size.

  • The block size is listed in the block size column parallel to your decimal mask.
  • The block size is 2.

Step 3. What is my Network ID?

  • Since we are working in the third octet and the block size is 2, the first network is (2 * 59 = 118). We are simply looking for the largest multiple of the block size without going over the given octet number (118).

Step 4. What is the next Network ID?

  • Again, we look at our block size of 2 to determine the next network is (118 + 2).
  • Network ID (First IP in the subnet):
  • Broadcast address (last IP in the subnet):
  • First Usable IP (the address after the network ID):
  • Last Usable IP (the address before the broadcast address): (This is the answer to the specific question that was asked.)

Question Type 2: How many subnets and hosts per subnet can you get from the network

Step 1: Determine the classful mask.

  • 192 = Class C
  • Class C default mask =

Step 2: Determine how many additional subnet bits exist beyond the classful boundary.

  • Since this is a class C address, we are only going to look at the fourth octet. Since the decimal mask is 224, we know there were three subnet bits added (counting up from the bottom of our cheat sheet).

Step 3: Determine how many host bits remain.

  • We are still only working in the fourth octet. Since three bits went to the subnet in step 2, we have five host bits (0's) remaining.

Step 4: Find the exponents of both subnet bits and host bits using the cheat sheet:

  • Subnet Bits = 2^3 = 8
  • Host Bits = 2^5-2 = 30

The answer is 8 subnets and 30 hosts per subnet.

Question Type 3: You have been asked to create a subnet mask for the network. Your organization requires 900 subnets, with at least 50 hosts per subnet. What subnet mask should you use?

Step 1: Determine how many subnet bits (1's), you have to add to the classful boundary to cover the number of required subnets.

  • The IP address given was a class B address, making the first 16 subnet bits static.
  • Using the cheat sheet, find the exponent of 2 that is equal to or greater than the number of subnets we require (900). We can quickly see that 10 additional subnet bits will give us 1,024 subnets. Make note of the corresponding subnet mask. In this case, The third octet is eight 1's, and the four is two 1's. We can count up from the bottom on our cheat sheet to get to 192.

Step 2: Confirm the number of remaining 0's will cover our required hosts. In this case, there are 6 remaining 0's - 2^6-2=62, which is more than enough for our host requirements.

Our subnet mask is Giving us 1024 subnets and 62 hosts per subnet.

For more examples, visit our Tips & Tricks page.

Advanced Topics

Variable Length Subnet Mask (VLSM)

You are a network administrator and you have been assigned the task of setting up the IP network. You have a single class C IP address range and have to setup the following networks:

  • Network A = 100 Hosts
  • Network B = 40 Hosts
  • Network C = 20 hosts
  • Network D = 10 hosts
  • Network E = 6 Hosts
  • Network F = 2 Hosts
IP Range Network Num IPs Subnet Mask
0-127 Network A 128 /25
128-191 Network B 64 /26
192-223 Network C 32 /27
224-239 Network D 16 /28
240-247 Network E 8 /29
248-251 Network F 4 /30

It's really that easy:

  1. Add up all host requirements to make sure you have enough in a single block.
  2. Work from the top down (largest host requirements) removing the # of required hosts for each network.
  3. Done.
☆ Top 10 High Scores ☆
View Full List
RankAll Star NameScore
7Francois van Niekerk48