CIDR Notation, Subnetting and Mathematics

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
There's a trick to this, for subnets of greater than 24 bits. (ie smaller subnets than /24)

Subtract the subnet mask's last significant octet from 256, gives you the size of the subnet.
One address for network, one address for broadcast (always).

So 255.255.255.192
256 - 192 = 64 addresses. Subtract 2 for network and broadcast, 62 available.

255.255.255.252
256 -252 = 4, so 2 addresses available. That's why that subnet mask is used for point to point links...

255.255.255.224
256-224 = 32, so 30 usable addresses.

For subnets bigger than a /24 it's a little more complex. You do the same maths but multiply by 256 in the middle.

Eg 255.255.252.0
256 - 252 = 4
4x256 = 1024
So 1022 usable addresses. Always first ip is network and last is broadcast.

Similar logic for a subnet bigger than 16.

255.252.0.0
4x256x256 = 262144, so 262142 available ips in the subnet.


Make the sense?
Oh! so the -2 is for those two reserved IP addresses. Finally, that makes sense to me now, thanks @Sinbad
 

Sinbad

Well-Known Member
Joined
Jun 23, 2020
Messages
1,736
Oh! so the -2 is for those two reserved IP addresses. Finally, that makes sense to me now, thanks @Sinbad
Pleasure.

The broadcast IP is always all 1s in binary and the network ip is all 0s. So first and last addresses in the range.

So if the subnet range is from 10.0.0.0 to 10.1.255.255, those two particular addresses are the network and broadcast addresses respectively.
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
We'll pick this up later tonight, or over the weekend. I'll provide an example or two that will hopefully demystify this.
Fine by me. Maybe give me some random IP addresses and subnet addresses, lets see if I can do it. If I get it right, then I may be ready for the exam.

I've just inquired for exam vouchers and surprise, I was told that if I fail, I get to re-sit the exam for free. So hopefully I can book this as soon as possible, I"m hoping end of July, giving me at least two weeks to prep well. Oh and another thing, I am able to take the exam online from home as well. I just need the full details - if I"m allowed to use a calculator and whatnot.
 
R

[)roi(]

Guest
Fine by me. Maybe give me some random IP addresses and subnet addresses, lets see if I can do it. If I get it right, then I may be ready for the exam.

I've just inquired for exam vouchers and surprise, I was told that if I fail, I get to re-sit the exam for free. So hopefully I can book this as soon as possible, I"m hoping end of July, giving me at least two weeks to prep well. Oh and another thing, I am able to take the exam online from home as well. I just need the full details - if I"m allowed to use a calculator and whatnot.
I'm relaxing ATM, plus a little too inebriated to make much sense...
... so I'll put something together tomorrow; I'll need a break between bottling another two beers,
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
I'm relaxing ATM, plus a little too inebriated to make much sense...
... so I'll put something together tomorrow; I'll need a break between bottling another two beers,
No worries, it’s good to take a break. I’ve had at least 4-5 hours study time, 1 hour spend on CIDR notations.
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
Another question that popped up while I was going through my helpdesk request for this subject (from a few months back, yes I kept the email as I knew I would need it)

So, if you were asked in a question what the network address for 192.168.10.75 was given a subnet mask of 255.255.255.224, the answer would be 192.168.10.64, as 192.168.10.75 falls in between 192.168.10.64 and 192.168.10.96.

If the IP address falls into the range between .64 and .96, how do you work the beginning to the end? I mean the IP address .75 is smack almost in the middle.

Am I missing something obvious here?

I see it says that you need to start from the beginning and add increments of 32 for each range and then select the right range that the IP falls into. Isn't there a quicker way of doing it without needing to use a pen and paper or calculator for that instance?
 
Last edited:

Sinbad

Well-Known Member
Joined
Jun 23, 2020
Messages
1,736
Another question that popped up while I was going through my helpdesk request for this subject (from a few months back, yes I kept the email as I knew I would need it)



If the IP address falls into the range between .64 and .96, how do you work the beginning to the end? I mean the IP address .75 is smack almost in the middle.

Am I missing something obvious here?

I see it says that you need to start from the beginning and add increments of 32 for each range and then select the right range that the IP falls into. Isn't there a quicker way of doing it without needing to use a pen and paper or calculator for that instance?
That's the way to do it.

Eventually with practice you'll get to recognize the common ones.

Remember the trick for working out how many addresses are in a subnet. You don't need a pencil or calculator.
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
Remember the trick for working out how many addresses are in a subnet. You don't need a pencil or calculator.
Just looked back, there's no way in hell I will be able to do that without a calculator. I can't even get past the 5 times table. I swear I have maths dyslexia.
 

Sinbad

Well-Known Member
Joined
Jun 23, 2020
Messages
1,736
Just looked back, there's no way in hell I will be able to do that without a calculator. I can't even get past the 5 times table. I swear I have maths dyslexia.
You can't do 256-192 without a calculator?
or 256-128?
Just memorise them then. There are only 6 possible combinations.
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
You can't do 256-192 without a calculator?
or 256-128?
Just memorise them then. There are only 6 possible combinations.
Maths dyslexia. single numbers are easy to calculate but larger units of numbers not so much.

Here's another one, just going through with Practice Tests A part.
A device connected to the company's network is having an IP address 120.168.1.1. A network administrator wants to verify that the device had a TCP/IP stack loaded. Which of the following addresses should the network administrator ping?

A: 128.0.0.1
B: 127.0.0.1
C: 192.0.0.1
D: 191.168.1.1
Now how would I know a TCP/IP stack load?
 

biometrics

Well-Known Member
Joined
Oct 17, 2019
Messages
20,417
Maths dyslexia. single numbers are easy to calculate but larger units of numbers not so much.

Here's another one, just going through with Practice Tests A part.

Now how would I know a TCP/IP stack load?
127.0.0.1 is itself.

Pinging myself on my phone. It's working so my phone's TCP/IP stack is working.

Screenshot_20200718-151659__01.jpg
 

biometrics

Well-Known Member
Joined
Oct 17, 2019
Messages
20,417
127.0.0.1 is also known as a loopback address.

127.0.0.1

A loopback address is a special IP address, 127.0. 0.1, reserved by InterNIC for use in testing network cards. This IP address corresponds to the software loopback interface of the network card, which does not have hardware associated with it, and does not require a physical connection to a network.Jan 18, 2018
1595078646440.png
https://kb.iu.edu › aikz
What is a loopback address? - IU Knowledge Base - Indiana University
 
R

[)roi(]

Guest
@BloodrayneZA
Let's look at breaking down a class C subnet using a mask of 255.255.255.192; same process will apply for other masks like 255.255.255.240
For simplicity we'll breakdown the commonly used private class C i.e. 192.168.1.0

Let's start by Representing the subnet mask in binary.

subnet mask.png

Let's calculate a few values
subnet values.png

  1. To determine the Mask bits; we simply sum up all the 1's i.e. 26
  2. To determine the number of devices per range;
    • we take the total number of bits (4 octets * 4 = 8 * 4 = 32)
    • and subtract the Mask bits (32 - 26) = 4 and then use that as an exponent of 2 i.e. 2^4 or 2 * 2 * 2 * 2 = 64
    • finally we subtract 2; 1 for the network address and 2 for the broadcast address; leaving us 62 usable devices per subnet.
  3. To determine the number of subnets; we simply divide the sum of network portion's bits (in this case it's the last octet) i.e. 256 by the #devices per range + 2 i.e. 256 / 64 = 4
Finally we calculate the 4 subnet address ranges
subnet address ranges.png
The first range has an index of 0; we calculate as follows:
  • Network Address -> index * by 2 ^ # of subnets i.e. 0 * 2 ^ 4 = 0 * 64 = 0 => 192.168.1.0
  • Broadcast Address -> Network Address + # Devices / Range + 1 i.e. 192.168.1.0 + 62 + 1 => 192.168.1.63
  • Usable Host Range is the addresses in between the Network and Broadcast Address
The only thing that change for the next subnet block is the index; from 0 to 1. We keep computing subnet ranges up to the # Subnets (4) minus 1; because our index starts at zero.

I'd suggest creating this in Excel for a bit of practice; by creating the formulas; you'll become more familiar with the calculations.

As another example; here is the result for a subnet mask of 255.255.255.240
subnet 240.png

See if that makes sense -- let me know if you need more clarity.

This can be computed manually; it just takes a little more time. Naturally you'd want to use a subnet calculator when dealing with much large networks i.e. when a subnet mask that stretches over to class B or class A masks. That certainly wouldn't be a practical question for any examination.
 
Last edited by a moderator:

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
Thanks Droid. That helped.

Another question, if you may. This question came across to me during a practice test which kind of caught me off guard.

A technician, Ann, has to assign two IP addresses to WAN interfaces on connected routers. Which of the following subnet masks should Ann use for this subnet to conserve address space?

A: /28
B: /30
C: /24
D: /29

Does the same rule apply? or is there another way of doing this?
 

Johnatan56

Well-Known Member
Joined
Jun 22, 2020
Messages
1,533
Location
Vienna
1595608293321.png
I deleted all of these a month or two ago. :(

These were my notes for it, all I have left:
How to subnet:


Given IP: 196.168.1.100 /29

The number behind the slash is how many 1s there are, so /29 is:
11111111.11111111.11111111.11111000

The IP 196.168.1.100 in binary is:
11000000. 10101000.00000001.01100100

Now logic gate, where 1 and 1 = 1, 1 and 0 = 0, 0 and 1 = 0 and 0 and 0 = 0.

11111111.11111111.11111111.11111000
11000000. 10101000.00000001.01100100
--------------------------------------------------------
11000000. 10101000.00000001.01100000 => subnet address.

Convert to decimal: 196.168.1.96

Subnet mask: N.N.N.H > 255.255.255.96



How to do this more quickly/without having to convert the entire number into binary:

Take the subslash (/29) and divide it by 8. 29 / 8 = 3. Therefore the first 3 octets are fixed.
Get the network portion borrowed in the last octet: 29%8 = 5. Therefore the network portion is 5.

Subnet address: 192.168.1. <=fixed
calculate the last octet:
01100100
We only want the first 5 though, the rest are zero (the 5 is the network bits borrowed from the host):
01100000



The final subnet address is: 192.168.1.01100000 => 192.168.1.96



How to get the range out of this:
256 / 2^(network bits borrowed) = 256 / 2^5 = 256 / 32 = 8.

Therefore the broadcast address of the given IP is: 192.168.1. (subnet + range – 1) = 192.168.1.103



If asked what the total number of hosts is: 2^(8-n) if class C, 2^(16-n) if Class B, etc.
In this case it is a class C address: 2^(8-5) = 2^3 = 8 hosts.



Calculate the total number of networks possible:
2^n = 2^5 = 32 networks total

But cisco does not allow the 0th and final address to be used, therefore total number of usable networks:
2^n - 2 = 2^5 – 2 = 32 – 2 = 30 networks usable



Part 2


Now how to figure out if said: x number of departments with y number of hosts:

Say you have 9 departments, each with 15 hosts.

2^1 – 2 = 0
2^2 – 2 = 2
2^3 – 2 = 6
2^4 – 2 = 14

The number of departments fits between 2^3 and 2^4. We always take the larger of the two as the amount of bits we will borrow.

Therefore our network bits borrowed = 4.

This means our total number of networks = 24 = 16. Our total number of usable hosts is 14 (total – 2).
Our total number of hosts is = 2^(8 - n) (in a class C Address) = 2^(8-4) = 24 = 16 total hosts. You should make sure your total hosts is not more than required hosts (either the question is wrong or you have made a mistake).

In order to calculate range:
256 / 2^n = 256 / 2^4 = 256 / 16 = 16.

Continue as done above in part 1.





Extra questions:

200.25.48.255 /25
198.200.199.100 /27


15 departments with 8 hosts each. IP Address: 199.0.56.0
3 departments with 20 hosts each. IP Address: 205.23.23.0
1 department with 100 hosts. IP Address: 220.255.30.25

Bonus: Given 10 departments, what is the subnet of the following IP Address: 220.25.40.38

I had networking as a major for 1st and 2nd year, I was good at it, but I don't really remember most of this, even though I literally took this as a hobby project to build an android app as calc to calc subnets etc. for me as my 1st year's programming project.
 

BloodrayneZA

Well-Known Member
Joined
May 2, 2020
Messages
2,822
Location
Helheim
Thanks, you guys have been really a great help.

I feel almost ready to write the exam - just a few things to go over and try to remember.
 

SauRoN

Active Member
Joined
May 2, 2020
Messages
495
Absolutely no need to actually know how to work this out by hand in the real world and I haven’t seen an exam ever ask you to actually do it.

Expecting you to know the common masks and ranges yes, actually asking you to construct it by hand no.

Even the most legendary of networking ninjas I know use the freely available subnet calculators found online.


Sent from my iPhone
 
Top