A Quick Mathematical Formula for Subnetting

March 24, 2016 | Views: 21368

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Let’s begin.

Steps:

  1. Write powers of 2 left to right
  2. Write CIDR subnet masks from 1 to 32. This will take 4 lines, one for each octet in the IP addresses
  3. Write the subnet mask: add powers of 2 from left to current column

 

You can invert 2 and 3 if you think it’s more logical (I’m used to this way).

You an add the number of usable IP by doing (power of 2) -2

A more mathematical way to express the the subnet mask calculation is: current value = value on the left (previous value) + power of 2 of this column.

 

It should take about 1 minute to do this when the exam starts. It will be extremely useful all through the exam to double check any IP and subnet. The only missing part would be a list of possible subnet values (i.e 0, 16, 32, … for a /28 CIDR), but I found it’s best to do this when you need it rather than pre-calculate it. It’s not needed that often during the exam, as most of the exam is being “nice” with you and gives you easy values such as 0, 128, 64, …

 

You should be able to generate this table:

2x 128 64 32 16 8 4 2 1
1st octet 1 2 3 4 5 6 7 8
2nd 9 10 11 12 13 14 15 16
3rd 17 18 19 20 21 22 23 24
4th 25 26 27 28 29 30 31 32
mask 128 192 224 240 248 252 254 255

 

A few examples of how to use this table and concept:

– Find the last usable IP in the subnet 172.16.1.0/30

/30 gives a 4 total IP’s (0 to 3), meaning 2 usable IPs (1 and 2), 0 is the subnet and 3 is the broadcast. Answer is 172.16.1.2

 

– Can 192.168.15.23 use 192.168.16.35 as default gateway if subnet is 255.255.254.0?

254 as a mask gives us 2 IP in the third octet, so:

  • 192.168.0.x and 192.168.1.x are in the same subnet
  • 2.x and 3.x
  • 4.x and 5.x
  • 6.x and 7.x

The answer is “no,” as both IP’s are not in the same subnet.

 

– What is the CIDR subnet mask for /12?

The answer is 255.240.0.0

 

– What mask do you need to have 64 hosts in a subnet?

64 total IP’s won’t be enough (don’t forget broadcast and subnet IP’s remove usable IP’s from the total). You need to choose a subnet that can accommodate 126 hosts (128-2) hence a mask of 255.255.255.128, or /25

 

Thanks and I hope this is helpful to you.

Share with Friends
FacebookTwitterLinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterLinkedInEmail
Ready to share your knowledge and expertise?
22 Comments
  1. Of all the charts I have seen, this one is the most practical. You essentially have all 4 octets which is perfect. Thanks!

  2. Of all the charts I have seen, this one is the most practical. Thanks!

Page 5 of 5«12345
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel