Subnetting?! You can do it!

Subnetting can be confusing until it is broken into steps and followed logically. Practicing these steps on a regular basis will enable one to understand subnetting.

Before attempting subnetting, one must understand how to work with binary and decimal number conversions. Let's review this first.

20=1
21=2
22=4
23=8
24=16
25=32
26=64
27=128

The following pattern for solving binary numbers to decimal numbers and decimal numbers to binary numbers should be used. Always remember to read from right to left instead of left to right. Also notice that each place doubles in value from right to left.

27 / 26 / 25 / 24 / 23 / 22 / 21 / 20
128 / 64 / 32 / 16 / 8 / 4 / 2 / 1

The above should be memorized. Later this will be important to remember when figuring out the number of subnets and hosts per subnets. Therefore, this skill must be practiced and reinforced as often as possible. Here are a few sample problems.

Example 1 (binary to decimal)
11001011 = 203 or

27 / 26 / 25 / 24 / 23 / 22 / 21 / 20
128 / 64 / 32 / 16 / 8 / 4 / 2 / 1
1 / 1 / 0 / 0 / 1 / 0 / 1 / 1

Example 2 (binary to decimal)
01011110 = 94 or

27 / 26 / 25 / 24 / 23 / 22 / 21 / 20
128 / 64 / 32 / 16 / 8 / 4 / 2 / 1
0 / 1 / 0 / 1 / 1 / 1 / 1 / 0

By writing out the chart and placing the 1's and 0's under the proper place in the chart, all that is left is to add up the place values that have 1's under them and the total will be the decimal number value.

To convert decimal numbers to binary numbers, place 1's in the place values until all the place values with 1's add up to the total. If any numbered place adds a value that is larger than the decimal number, 0's should be placed in those place values.

Example 3 (decimal to binary)
138 = 10001010 or

27 / 26 / 25 / 24 / 23 / 22 / 21 / 20
128 / 64 / 32 / 16 / 8 / 4 / 2 / 1
1 / 0 / 0 / 0 / 1 / 0 / 1 / 0

Another method for converting decimal numbers to binary numbers is the remainder method. Divide the decimal number by 2 and place write down a 1 if there is a remainder or a 0 if there is no remainder. Then divide the answer by 2 and write down a 1 if there is a remainder or a 0 if there is no remainder. The division process continues until there are 8 bits or place values of 1's or 0's. Be sure to write the 1's and 0's down in reverse order from right to left.

Example 4 (decimal to binary)
218 = 11011010

218 / ÷ / 2 / = / 109 / remainder / 0
109 / ÷ / 2 / = / 54 / remainder / 1
54 / ÷ / 2 / = / 27 / remainder / 0
27 / ÷ / 2 / = / 13 / remainder / 1
13 / ÷ / 2 / = / 6 / remainder / 1
6 / ÷ / 2 / = / 3 / remainder / 0
3 / ÷ / 2 / = / 1 / remainder / 1
1 / ÷ / 2 / = / 0 / remainder / 1

The work can be checked by placing the 1's and 0's back into the chart and adding up the place values that have 1's.

Checking the answer (218)

27 / 26 / 25 / 24 / 23 / 22 / 21 / 20
128 / 64 / 32 / 16 / 8 / 4 / 2 / 1
1 / 1 / 0 / 1 / 1 / 0 / 1 / 0

Routers use network addresses to route packets on a network. A network address is a 32 bit address (4 bytes) that can be expressed in dotted decimal or binary form.
Example: 218. 100. 45. 0 or 11011010. 01100100. 00101101. 00000000

Each 8 bits of the 32 bit network address is called an octet. Therefore, each network address consists of 4 octets each with 8 bits, for a total of 32 bits.

octet 1 / octet 2 / octet 3 / octet 4
218. / 100. / 45. / 0

You will work with three classes of network addresses. They are class A, class B, and class C. Here are the ranges of the three classes of networks with an example of each. The ranges represent the first octet.

Class A / 1 - 126 / 12.0.0.0
Class B / 128 - 191 / 183.36.0.0
Class C / 192 - 223 / 200.12.30.0

Each class of network has a default subnet mask. Like the three classes of network addresses, there are three classes of default subnet masks that are divided into four 8 bit octets that can be expressed in dotted decimal or binary

Class A default subnet mask / 255.0.0.0
Class B default subnet mask / 255.255.0.0
Class C default subnet mask / 255.255.255.0

Each of the classes of subnet masks have octets that are divided into a network portion and a host portion. Here is an example of all three classes of subnet masks with the host and network portion labeled and the number of bits in each portion. Network addresses can be labeled in the same manner.

Class A

network / host / host / host
255. / 0. / 0. / 0
8 bits / 24 bits

Class B

network / network / host / host
255. / 255. / 0. / 0
16 bits / 16 bits

Class C

network / network / network / host
255. / 255. / 255. / 0
24 bits / 8 bits

Subnetting is the act of creating subnets or subnetworks. A subnet or subnetwork occurs when the original network is segmented in order to make more efficient use of bandwidth and to provide more available addresses on a network.

Bits are "borrowed" or turned on from the host portion of a network address in order to create subnets. The bits that are left over are the bits used to create hosts. One very important rule to remember is that a minimum of two bits must be borrowed to create usable subnets, and a minimum of two bits must be left in order to create usable hosts. Below is a table for each class of address showing the total bits in the host portion, the maximum number that can be borrowed to create subnets, and the minimum number that must be left to create hosts on each subnet.

class A / 24 bits total / 22 maximum borrowed for subnets / 2 bits left for hosts
class B / 16 bits total / 14 maximum borrowed for subnets / 2 bits left for hosts
class C / 8 bits total / 6 maximum borrowed for subnets / 2 bits left for hosts

Here are the steps that are taken to create subnets and hosts.

  1. Determine the class of the network
  2. Break the host portion of the address into binary form.
  3. Determine the number of subnets needed. (number of bits to borrow or turn on)
  4. Determine the number of hosts. (number of 0 bits left in the host portion of the address)
  5. Write the default subnet mask.
  6. Find the subnet mask. (based on number of bits borrowed)
  7. Determine the range of hosts. (based on 0 bits left in octet where borrowing occurred)

Now it's time to work through a class C example.
Let's use the address 210. 102. 50. 0.

We will need 8 usable subnets, so we must borrow 4 bits from the host portion of the address. Always borrow by using the highest order bit first. Break the host portion of the address into binary then "turn on" or borrow the first 4 bits from the host portion in the fourth octet. The bold type represents the bits that we are borrowing.

210. 102. 50. 0 0 0 0 0 0 0 0

1 1 1 1 0 0 0 0

We take the number of bits borrowed (4) and make the "4" an exponent of 2, giving us 24= 16. Our number of of total subnets will be 16. However, the first subnet must be reserved for the network and the last for the broadcast. Therefore our total number of usable subnets, are 14 or 24-2=14. This will more than satisfy the need for 8 subnets.

Our total number of hosts can be determined by adding up the 0 bits that are left in the entire host portion of the address. Remember, some of the original 0's will be gone due to the borrowing to create subnets.

210. 102. 50. 0 0 0 0 0 0 0 0

1 1 1 1 0 0 0 0

128+ 64+ 32+ 16

The number of bits left is 4, so we make the "4" and exponent of 2 which will be 24= 16, for a total of 16 hosts per subnet. However, once again, the first and last hosts are not usable since they will be on the first and last subnets. Therefore our total number of usable hosts will be 14 or 24-2=14.

Our default subnet mask for a class C address is 255. 255. 255. 0. To find out our subnet mask for our 4 bits borrowed we simply add up the 1's starting with the highest order bit. Look at the example above that has the first four bits of the host portion in bold. This will give us 128+64+32+16=240. So the subnet mask for the address we are subnetting is 255. 255. 255. 240 The "240" is placed in the same octet in the subnet mask, as the borrowing occurred in the network address (octet 4). To determine the range of the hosts, go back to the equation for the number of bits (0's) left after borrowing. 24= 16. Therefore our range is 16. Now we are ready to write out our subnets.

Bits / Subnet# / Range / Subnets / From/To / Broadcast
0000 / 0 / reserved / 210.102.50.0 / reserved / reserved
0001 / 1 / 16 / 210.102.50.16 / .17-.30 / 210.102.50.31
0010 / 2 / 32 / 210.102.50.32 / .31-.46 / 210.102.50.47
0011 / 3 / 48 / 210.102.50.48 / .49-.62 / 210.102.50.63
0100 / 4 / 64 / 210.102.50.64 / .65-.78 / 210.102.50.79
0101 / 5 / 80 / 210.102.50.80 / .81-.94 / 210.102.50.95
0110 / 6 / 96 / 210.102.50.96 / .97-.110 / 210.102.50.111
0111 / 7 / 112 / 210.102.50.112 / .113-.126 / 210.102.50.127
1000 / 8 / 128 / 210.102.50.128 / .129-.142 / 210.102.50.143
1001 / 9 / 144 / 210.102.50.144 / .145-.158 / 210.102.50.159
1010 / 10 / 160 / 210.102.50.160 / .161-.174 / 210.102.50.175
1011 / 11 / 176 / 210.102.50.176 / .177-.190 / 210.102.50.191
1100 / 12 / 192 / 210.102.50.192 / .193-.206 / 210.102.50.207
1101 / 13 / 208 / 210.102.50.208 / .209-.222 / 210.102.50.223
1110 / 14 / 224 / 210.102.50.224 / .225-.238 / 210.102.50.239
1111 / 15 / 240 / 210.102.50.240 / .241-.254 / 210.102.50.255

Remember that subnet 0 and subnet 15 are not usable. Also, notice that in subnet 15 the broadcast address is 210. 102. 50. 255 and that all the bits are 1111 which equals 15. This is a good way to check the work if there are not many subnets. We can now label a subnet address like this

Example:

network / network / network / subnet/host
210. / 102. / 50. / 32

Now let's take the class B address 166. 62. 0. 0 We will need 6 usable subnets, so we must borrow 3 bits from the host portion of the address. Always borrow in the third octet first in a class B address. Break the host portion of the address into binary then "turn on" or borrow the first 3 bits from the host portion in the third octet. The bold type represents the bits that we are borrowing.

166. 62. 0 0 0 0 0 0 0 0. 0 0 0 0 0 0 0 0

1 1 1 1 1 1 1 1. 1 1 1 1 1 0 0 0

We take the number of bits borrowed (3) and make the "3" an exponent of 2, giving us 23= 8. Our number of total subnets will be 8. However, the first subnet must be reserved for the network and the last for the broadcast. Therefore our total number of usable subnets, are 6 or 23 -2= 6.

Our total number of hosts can be determined by adding up the bits that are left (0's) in the entire host portion of the address.

166. 62. 0 0 0 0 0 0 0 0. 0 0 0 0 0 0 0 0

1 1 1 0 0 0 0 0. 0 0 0 0 0 0 0 0

128+ 64+ 32

The number of bits left is 13, so we make the "13" an exponent of 2 which will be 213= 8,192, for a total of 8,192 hosts per subnet. The first and last hosts are not usable since they will be on the first and last subnets. Therefore our total number of usable hosts will be 8,190 or 213 -2= 8,190. Our default subnet mask for a class B address is 255. 255. 0. 0.

To find out our subnet mask for our 3 bits borrowed we simply add up the 1's starting with the highest order bit. Look at the example above that has the first 3 bits of the host portion in bold. This will give us 128 +64 +32 = 224. So the subnet mask for the address we are subnetting is 255. 255. 224. 0 The "224" is placed in the third octet in the subnet mask since this is where the borrowed bits are.

To find the range of our hosts, we added up the number of bits left within the last octet we borrowed from. In this case it is the third octet. The number of bits left is 5. We take the "5" and make it an exponent of 2, which gives us 25= 32. So our range is 32. Now we are ready to write out our subnets.

Bits / Subnet# / Range / Subnets / From/To / Broadcast
000 / 0 / reserved / 166.62.0.0 / reserved / reserved
001 / 1 / 32 / 166.62.32.0 / 32.1 - 63.254 / 63.255
010 / 2 / 64 / 166.62.64.0 / 64.1 - 95.254 / 95.255
011 / 3 / 96 / 166.62.96.0 / 96.1 - 127.254 / 127.255
100 / 4 / 128 / 166.62.128.0 / 128.1 - 159.254 / 159.255
101 / 5 / 160 / 166.62.160.0 / 160.1 - 191.254 / 191.255
110 / 6 / 192 / 166.62.192.0 / 192.1 - 223.254 / 223.255
111 / 7 / 224 / 166.62.224.0 / 224.1 - 255.254 / 255.255

Here is an example of a class B subnet address with each portion labeled.

166. 62. 96. 14

network / network / subnet / host
166. / 62. / 96. / 14

Let's do another class B example with the given address of 180. 10. 0. 0. We want to create 254 usable subnets so we will need to borrow 8 bits. This will give us 28= 256 -2= 254 subnets. The entire third octet has been used, so now our host bits will come from the fourth octet. By using the 8 bits in the fourth octet, we will have 28= 256 -2= 254 hosts per subnet. The range equals 28= 256. However,our binary number range will only go from 0 to 255. Therefore, we will "carry" the extra 1 into the end of the third octet, which will give us a range of 1. the subnet mask will be 255. 255. 255. 0. We will do a few subnets, rather than doing 254 subnets.

Bits / Subnet# / Range / Subnets / From/To / Broadcast
00000000 / 0 / reserved / 180. 10. 0. 0 / reserved / reserved
00000001 / 1 / 1 / 180. 10. 1. 0 / 1.1 - 1.254 / 1.255
00000010 / 2 / 2 / 180. 10. 2. 0 / 2.1 - 2.254 / 2.255
00000011 / 3 / 3 / 180. 10. 3. 0 / 3.1 - 3.254 / 3.255

This pattern will continue all the way to the last address usable address 180. 10. 254. 255. The address that follows this one is reserved for broadcast.

In the next class B example, our address is 141. 200. 0. 0. We will borrow all the bits of the third octet, and 3 bits in the fourth octet, giving us 11 bits borrowed. This will give us 211 - 2= 2,046 subnets, each having 25 - 2= 30 hosts, with a range of 32, and a subnet mask of 255. 255. 255. 224.

Again, we will do only a few examples and will skip to the next octet to show how this works.

Bits / Subnet# / Range / Subnets / From/To / Broadcast
00000000.000 / 0 / reserved / 141.200.0.0 / reserved / reserved
00000000.001 / 1 / 32 / 141.200.0.32 / .33 - .62 / .63
00000000.010 / 2 / 64 / 141.200.0.64 / .65 - .94 / .95
00000000.011 / 3 / 96 / 141.200.0.96 / .97 - .126 / .127
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
00000001.000 / 8 / 1.0 / 141.200.1.0 / 1.0 - 1.30 / 1.31
00000001.001 / 9 / 1.32 / 141.200.1.32 / 1.33 - 1.62 / 1.63
00000001.010 / 10 / 1.64 / 141.200.1.64.0 / 1.65 - 1.94 / 1.95

This pattern would continue until we reach 141.200.2.0, 141.200.3.0, etc.

A subnet mask shows the total number of routing bits or 1 bits that a router is using. The other bits, the 0 bits are reserved for the hosts. For example, if we return to our class C address of 210. 102. 50. 0, with a subnet mask of 255. 255. 255. 240. The subnet mask can be represented with the address at the end with a forward slash. This will give us 210. 102. 50. 0/28. The "28" represents the 28 bits of the subnet mask.

255. 255. 255. 240

8 + 8 + 8 + 4 = 28

The same can be done for the other addresses. 166. 62. 0. 0/19, 180. 10. 0. 0/24, and 141. 200. 0. 0/27

What if you are given a subnet address such as 193. 211. 2. 5 and you needed to know the network address for the subnet? You will have to use a Boolean algebra operation called AND.AND is the same as multiplication. AND means that a binary 0 AND 1 = 0, 0 AND 0 = 0, 1 AND 1 = 1.

To AND the subnet address 193. 211. 2. 5, we break the address 193. 211. 2. 5, and the default subnet mask 255. 255. 255. 0 into binary and AND them together. We then take the result of the ANDing

Example:

1 1 0 0 0 0 0 1. 1 1 0 1 0 0 1 1. 0 0 0 0 0 0 1 0. 0 0 0 0 0 1 0 1

1 1 1 1 1 1 1 1. 1 1 1 1 1 1 1 1. 1 1 1 1 1 1 1 1. 0 0 0 0 0 0 0 0

______

1 1 0 0 0 0 0 1. 1 1 0 1 0 0 1 1. 0 0 0 0 0 0 1 0. 0 0 0 0 0 0 0 0

The next step is to take the binary result of the ANDing and convert it into a decimal dotted address. The answer is 193. 211. 2. 0. An easier way would be to simply place all zeroes in the host portions to find the network address that a subnet lies on. However, what if you needed to find out what the origin of the subnetwork that a subnet lies on? For example, what subnet is the host 210. 102. 50. 151 on? To find out we must again use the ANDing process, but this time we must use the subnet mask that we got through the borrowing of bits. In this case the subnet mask is 255. 255. 255. 240.

1 1 0 0 1 0 1 0. 0 1 1 0 0 1 1 0. 0 0 1 1 0 0 1 0. 1 0 0 1 0 1 1 1

1 1 1 1 1 1 1 1. 1 1 1 1 1 1 1 1. 1 1 1 1 1 1 1 1. 1 1 1 1 0 0 0 0

______

1 1 0 0 1 0 1 0. 0 1 1 0 0 1 1 0. 0 0 1 1 0 0 1 0. 1 0 0 1 0 0 0 0

When we convert the binary result back into dotted decimal, we get 210. 102. 50. 144. This is the subnet that 210. 102. 50. 151 is on.

The router uses the ANDing process to route packets on the network. This process allows the router to decide where to send a packet and which host to send the packet to.