Subnet Math

narzy

Elite Member
Feb 26, 2000
7,006
1
81
The bane of our existance, the subnet...don't get me started on reverse subnetting...that is a whole other disaster...but for now...for anyone who needs it...for everyone who forget (like me) how to do it every time someone asks....

The number of subnets allowed in the network is two to the power of the number of subnet ID bits.


The number of hosts allowed per subnet is two to the power of the number of host ID bits, less two.

Subnet Math

the number of subnets = the number of subnet bits to the power of 2

eg. 192.168.1.1/25 SM=255.255.255.128

I borrowed 1 bit

1^2=2

Now how many hosts per subnet!

Easy!

The number of hosts = the number of host bits to the 2 to the power of H minus 2 (We have to reserve something for the poor network right?)

or 2 to the power of host bits minus 2

(2^H)-2

eg. 192.168.1.1/25 SM=255.255.255.128
2^H = 2^7 = 128
now don't forget to subtract 2!

128-2=126

Subnet your heart out...
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
Good info. But once you learn to use your fingers it is SO much easier.
128, 192, 224, 240, 248, 252, 254
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
Originally posted by: narzy
Can I have some finger training? ;)

I just gave it to you. Count what I posted on your fingers. That's the number of bits for whatever octet you are working with.
 

narzy

Elite Member
Feb 26, 2000
7,006
1
81
oh, the string of numbers! I thought that was your new signature...(I missed them when I read your original post. That is an awesome trick...
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: spidey07
Good info. But once you learn to use your fingers it is SO much easier.
128, 192, 224, 240, 248, 252, 254

i do the same thing.

in my cisco class people still have trouble subnetting. the teacher took 2 or 3 weeks to cover it and did a piss poor job.
 

BriGy86

Diamond Member
Sep 10, 2004
4,537
1
91
:confused: I'm still curious about the finger method. I just opened up my CCNA book again. I think if I want to move up I'll need to be more familiar with this stuff.
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: JackMDS
http://www.subnetmask.info/

i have an ip calculator on my linux desktop, and keep something like that bookmarked in windows for when i have to keep up with lots of subnets (i dont use a windows desktop often outside of school). otherwise using mah fingers i can do simple stuff in my head without much fuss.

Originally posted by: BriGy86
:confused: I'm still curious about the finger method. I just opened up my CCNA book again. I think if I want to move up I'll need to be more familiar with this stuff.

yeah, you definitely need a strong grasp on subnetting (and really, if you can get the hang of it, you realize its not that hard). basically you count on your fingers, adding one bit to each finger for the network address

for example, lets say you start on your left hand, palm-down.

128 = 10000000 = pinky
192 = 11000000 = ring finger
224 = 11100000 = middle finger
240 = 11110000 = pointer

and so on, with unused bits obviously available for the network addresses

http://www.subnettingquestions.com/

figure a problem, hit reveal/next, get a new problem. good for practicing subnetting
 
Dec 26, 2007
11,782
2
76
Originally posted by: xSauronx
Originally posted by: spidey07
Good info. But once you learn to use your fingers it is SO much easier.
128, 192, 224, 240, 248, 252, 254

i do the same thing.

in my cisco class people still have trouble subnetting. the teacher took 2 or 3 weeks to cover it and did a piss poor job.

Yeah same here.

Also, if you have access to Cisco learning network (Netacad login for example), they have a kind of fun subnetting game. It's easy at first, but after level 4 or so it gets difficult (they start removing the bit values at top/bottom and speed it up).
 

BriGy86

Diamond Member
Sep 10, 2004
4,537
1
91
thanks, so you just have to get used to remembering those specific numbers like 192 and 224 and so on?(I understand how those numbers are gotten) and I assume you just disregard your right ring and pinky finger correct?

I'll check out that site, thanks.
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: BriGy86
thanks, so you just have to get used to remembering those specific numbers like 192 and 224 and so on?(I understand how those numbers are gotten) and I assume you just disregard your right ring and pinky finger correct?

I'll check out that site, thanks.

yep. in subnetting the numbers are always the same so yeah, memorize any combination you can, anything you remember immediately saves you time doing the binary math
 

xSauronx

Lifer
Jul 14, 2000
19,582
4
81
Originally posted by: DisgruntledVirus
Originally posted by: xSauronx
Originally posted by: spidey07
Good info. But once you learn to use your fingers it is SO much easier.
128, 192, 224, 240, 248, 252, 254

i do the same thing.

in my cisco class people still have trouble subnetting. the teacher took 2 or 3 weeks to cover it and did a piss poor job.

Yeah same here.

Also, if you have access to Cisco learning network (Netacad login for example), they have a kind of fun subnetting game.

linkage fail :p (fixed)
 
Dec 26, 2007
11,782
2
76
Originally posted by: narzy
that subnet game is fun :). Its like subnet word muncher ;).

Yeah, I found it on the cd that came with my CCNA exam prep books from Ciscopress. I was playing it for an hour when I first found it haha

 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
Originally posted by: BriGy86
Is there a reason you can't have a 128.0.0.0 subnet mask?

Probably because it would mess with class D and E addresses. Also loopback addresses.
 

BriGy86

Diamond Member
Sep 10, 2004
4,537
1
91
Originally posted by: spidey07
Originally posted by: BriGy86
Is there a reason you can't have a 128.0.0.0 subnet mask?

Probably because it would mess with class D and E addresses. Also loopback addresses.

I forgot about that. but if you enable classless routing wouldn't it also disregard the D and E classes just like it does for A, B, and C?
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
Those classes are still important and reserved even with CIDR and have special treatment, specifically class D. Also remember that 127.0.0.0/24 is reserved for loopbacks. So with a 1 bit mask you're really interfering the operation of IP itself.

I'm just kind of thinking outloud, at first I didn't see a problem with a 1 bit mask until thinking about it more and the implications. Maybe read the RFC about CIDR and I'm sure it will have mention of a 1 bit mask. Then again I've never tried to have or make a route with a 1 bit mask.

RFC1519 - CIDR