Subnetting Shortcuts

by David Davis on January 9, 2007

Need some help with Subnetting? Preparing for your CCNA Exam? In this multi-page list of Subnetting Shortcuts,, you will find tricks, tips, and test preparation know-how when it comes to IP Subnetting, Check it out!

Special Thanks to Mimi Shaw for contributing these shortcuts!

 


When you are going to take a Cisco exam, before the exam starts write the following information down (public and private class address ranges and then the chart) as it will save you a lot of time and headaches.

 

IP Address Classes 

 

Class A:  1 – 126 (127 reserved for loop-back and diagnostic tests)Class B:  128 – 191Class C:  192 – 223Class D:  224 – 239 (reserved, used primarily for IP multicasting)Class E:  240 – 254 (reserved, experimental) Private addresses –Class A:  10.0.0.0 through 10.255.255.255Class B:  172.16.0.0 through 172.31.255.255Class C:  192.168.0.0 through 192.168.255.255 

128 64 32 16 8 4 2 1  
1 0 0 0 0 0 0 0 128
1 1 0 0 0 0 0 0 192
1 1 1 0 0 0 0 0 224
1 1 1 1 0 0 0 0 240
1 1 1 1 1 0 0 0 248
1 1 1 1 1 1 0 0 252
1 1 1 1 1 1 1 0 254
1 1 1 1 1 1 1 1 255

CCNA Video Training  

What the chart represents are the eight bit values of one octet of an IPv4 IP Address.  If you add up all of the bits it comes to
255 which is an all 1’s mask. 

 

If you are wondering how we get 256 in one octet, there is an implied zero at the end.  If you are looking at a network you can have a network address of 192.168.17.0.  The modulus of 128 – 0 would be 256.  To arrive at the subnet mask we can do one of two things, add the positive bits together or take the least significant positive bit and subtract it from 256.

 

Bit Values of one octet

 

           
128 64 32 16 8 4 2 1 (Implied zero)0 Modulus of 128 – 0 would be 256
1 0 0 0 0 0 0 0 128 Subnet Mask
1 1 0 0 0 0 0 0 192
1 1 1 0 0 0 0 0 224
1 1 1 1 0 0 0 0 240
1 1 1 1 1 0 0 0 248
1 1 1 1 1 1 0 0 252
1 1 1 1 1 1 1 0 254  
1 1 1 1 1 1 1 1 255  

Where the chart comes in handy is if you are being asked what the subnet mask would be for /27.  You know that the sum of the first three octets is 24 so you start counting 25 with the first bit (128).   Counting to 27 would get you to the third most significant bit (32).  Look to the subnet mask column and you see that it is .224.

 

I had a teacher (Jeremy Cioara – he has written several Cisco books) and he gave the story of a guy that owned a brick company.  He had a lot with a lot of bricks and people would come and buy bricks.  As the guy got more successful he had to figure out a way of putting the bricks in piles so it would be quick and easy to give them the number of bricks they wanted.  He then put the bricks on pallets in the following quantities – 128, 64, 32, 16, 8, 4, 2 and 1.  As a result, it was easy to come up with quantities for a customer.  For example – a customer wants 188 bricks.  You would give them one of the 128 pallets.  They are 60 bricks short.  You sure as heck are not going to give him a 64-brick pallet because you would loose money so you give him a 32-brick pallet.  You are now 28 bricks short so you give him a 16 brick pallet.  You are still 12 bricks short so you give him an 8-brick pallet and a 4-brick pallet.  Here is the binary of 188:

 

128      64        32        16        8          4          2          1

1          0          1          1          1          1          0          0

 

Jeremy used this method when you had the question of what subnet mask to use when you need ‘x’ hosts and ‘x’ networks.

 

I then had another teacher who used to do the 2ⁿ-2 table.  That’s a little too complicated when you are going against time in a Cisco exam.

 

Here’s how I determine networks/hosts.  You know that you have to subtract two because you need one end for the network and one end for the broadcast address (subnet mask).  So, when you get to a bit value (i.e., 128, 64, 32 etc) you subtract two and the remainder will be the hosts. 

 

Let’s say that you are told that you have 57 hosts and are asked for the subnet mask.  Easy.  Go to the chart – 57 is more than 32 but less than 64.  Try to think 30 and 62 because you are thinking hosts.  You would use the second bit – 64 – and so if you go to the right side for the subnet mask it would be .192. 

 

If you are asked for valid hosts in the 192.168.30.7/28 range you start out by counting off the chart to see the numerical value for the 28th bit.  It is 16.  Then take a look at the last octet (since 28 puts us in the last octet range) and divide it by 16.  In this case we don’t have to because we can see it is less than 16 but if you are given .189 rather than .7 you would divide 189 by 16 and see that it was over 11.  Then multiply 11 times 16 to see the first address in that subnet – 176.  Then add 16 to 176 and you will get the first address of the next subnet (192).  That means that .189 falls in the subnet 176 – 188.  We know that the first number is the network address (192.168.30.176) and the last number is the broadcast address (255.255.255.188 – remember we are breaking down that 256 block so we can’t use the full 256 subnet only the portion blocking our network).  That means that the hosts must fall in the range of 177 – 187 (one after 176 and one before 188).

Going back to our question of valid hosts in the 192.168.30.7/28 range they would be:

 

192.168.30.1

192.168.30.2

192.168.30.3

192.168.30.4

192.168.30.5

192.168.30.6

192.168.30.7

192.168.30.8

192.168.30.9

192.168.30.10

192.168.30.11

192.168.30.12

192.168.30.13

192.168.30.14

 

And if you counted them up you would see there are 14 of them.  Remember the 2ⁿ-2 formula – it is the bit value minus 2 (one for network and one for broadcast address or subnet mask) equals number you can use for hosts.

 

If you want to know how many of these 16-bit networks we can get out of that third octet, divide 256 by 16.  It is 16.  Don’t slip and think that the number of networks you can get is the bit value – it just works out that way with /28.  For a /26 you can get 4 networks (0 – 63; 64 – 127; 128 – 191 and 192 – 255 (and I didn’t use the number 256 because I started at zero – the modulus (value of 256) comes from zero to 255). 

 

There is another way to figure out how many 16-bit networks you can get out of an octet – if you take a look at our bit values of 128, 64, 32, 16, 8, 4, 2 and 1; double the number of networks per bit value starting with 2 for 128.  You would then have 4 for 64, 8 for 32, 16 for 16, 32 for 8, 64 for 4 and 128 for 2.  This is easier than dividing 256 by 16 to see that you can have 16 networks.

 Train Signal CCNA Video Training 

If you are given a problem asking the subnet mask of 172.16.64.0/18 go back to the chart and when you start counting at the first bit (128) think of it as being in the third octet rather than the forth octet so /18 would be the second bit (64) and the subnet mask would be .192. 

 

By the way, if they asked you how many hosts you would have it is easy.  You’ve noticed that the bit values are cut in half for descending order so you just double them for ascending.  Start with your most significant bit of the last octet (128) and multiply it by two to come up with the bit value of the least significant bit of the third octet and keep doubling.

/17       /18       /19       /20       /21       /22       /23       /24       /25       /26       etc.

32768  16384  8192    4096    2048    1024    512      256      128      64

 

On a /18 network you would have 16382 hosts (16384 – 2).  

     

That’s the theory of my easy way to do subnetting.  Here are some example questions.  (Answers are at the end).

 

Questions 

 

1.       Which two of the addresses are available host addresses on the subnet 192.168.73.46/27?

 

a.       192.168.73.13

b.      192.168.73.37

c.       192.168.73.62

d.      192.168.73.55

e.     &nbsp
;
None of the above

  

2.      What is the subnet for the host IP address 172.16.222.0/22?

 

a.       172.16.208.0

b.      172.16.120.0

c.       172.16.220.0

d.      172.16.223.0

e.       None of the above

  

3.      Your network uses the 172.80.0.0 class B address.  You need to support 460 hosts per subnet while allowing for the maximum number of subnets.  Which mask would you use?

a.       255.255.255.192

b.      255.255.0.0

c.       255.255.192.0

d.      255.255.254.0

  

4.      You have a network with five departments and you were given a Class C IP Network from your ISP.  Pick the subnet mask that gives you a subnet for each of the departments and gives you the ability to have enough hosts for each department.  The departments have the following users – Sales – 7; Engineering – 16; HR/Accounting – 12; Shipping – 19 and Main – 6

 

a.       255.255.255.192

b.      255.255.255.224

c.       255.255.255.248

d.      255.255.255.252

e.       255.255.255.240

  

5.      Using a subnet mask of 255.255.255.224, which of the IP addresses below can you assign to the hosts on this subnet?  Select all that apply

 

a.       22.17.118.63

b.      86.40.16.159

c.       91.12.175.91

d.      167.134.16.53

e.       192.168.16.130

  

6.  Your ISP has given you the following IP address/subnet mask – which addresses are valid addresses for hosts:  IP Address:  192.141.27.0    Subnet mask: 255.255.255.240

 

a.       199.141.27.2

b.      199.141.27.175

c.       199.141.27.13

d.      199.141.27.11

e.       199.141.27.208

f.       199.141.27.112

  

Train Signal CCNA Video Training

 

Answers

1 – b, d (‘a’ is in the 0 – 31 subnet and d is the broadcast address)

2 – c

3 – d

4 – b (the largest block of hosts is 19 which means you have to go to 32.  Divide 256 by 32 and you see that you can do 8 blocks if you start at subnet zero so use /27.  If we didn’t have enough room to have five equal networks in the block we would then start with the largest block and then carve off subsequent blocks)

5 – c, d & e

6 – a, c & d

           

 

{ 3 comments… read them below or add one }

M. P. Shui 04.15.10 at 12:58 pm

I was taught to calculate the number of subnet, hosts, range of valid IPs and the subnet mask of an address from a individual address and mask.

Can you explain how to calculate the total subnet range from a given IP mask, instead of just one?

There has to be a fast way of finding the answers to the above questions, instead of doing each selection individually, especially when taking the Cisco Test

Thank you

Brian E 11.27.11 at 5:34 pm

On Question #1, the second subnet of 192.168.73.46/27 is 32-63, so 192.168.73.62 is a valid host.

Jon 03.03.12 at 3:50 pm

Then take a look at the last octet (since 28 puts us in the last octet range) and divide it by 16. In this case we don’t have to because we can see it is less than 16 but if you are given .189 rather than .7 you would divide 189 by 16 and see that it was over 11.

Where does 11 come from

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Previous post:

Next post: