Subnets.. work of the devil

Turfzilla

Senior member
May 25, 2004
424
0
0
How do you figure how many bits needs to be barrowed to create X ammount of hosts in a class C network... What is the math behind it? Anyone know?
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
I always just counted in binary.

128, 192, 224, 240, 248, 252 for the mask and 256-number-2 for the number of hosts.

So, 256-192 = 64 addresses. subtract two for the network and broadcast and you have 60 usable addresses for a 255.255.255.192 mask. 192 is two bits since we counted 128, 192.
 

ColdZero

Senior member
Jul 22, 2000
211
0
0
Think of it like cutting a pie. For every bit that you add to your subnet mask, you are cutting the pie one more time. Looking at it in binary when you are first learning it makes it a little easier.

So we have a class C subnet mask which can be represented a few different ways:
1. 255.255.255.0
2. /24 (CIDR Notation)
3. 11111111.11111111.11111111.00000000

When you are trying to figure out if you are on the same IP network as somebody else, you compare your subnet mask with their IP address. If you write it out in binary, anywhere there is a 1 in your subnet mask, just drop their 1 down.

My IP: 192.168.1.10
Your IP and Subnet mask: 192.168.1.15 255.255.255.0

My IP in Binary: 11000000.10101000.00000001.00001010
Your Sbnetmsk: 11111111.11111111.11111111.00000000

Your IP: 11000000.10101000.00000001.00001111

When you do a bitwise AND on both our address, you will get the same network portion, this means we are both on the same subnet and you can send traffic to me.

Now, what does this have to do with how many addresses you need. When you need to determine how many addresses you need, always add 2 to the number, one is the network address, the other is the broadcast address. So if somebody said do you, I need a network that will support 30 physical hosts, you actually need to allocate 32 address. Some newer equipment will allow you to get around this, but ignore that stuff for now.

So what you do create a binary subnetmask that will support 32 possible addresses:

New Subnet mask: 11111111.11111111.11111111.11100000
In Base 10: 255.255.255.224

To get that 224, add up the binary values of those last 3 digits of 1's at the end

128+64+32 = 224 and that is your subnet mask

Those zeros at the end of the subnet mask are what you can change for your possible addresses, since there are 4 0's you have 2^4 possible combinations of addresses, which is 32. Now say you needed 33 addresses, you would have to move one bit over so the subnet mask would be:

New Mask: 1111111.11111111.11111111.11000000
In Base 10: 255.255.255.192

128+64 = 192

This would give you 5 0's to change, 2^5 is 64 addresses you can play with.

I hope this helps, I probably made it sound more complicated than it seems.

Uhhh, or you could just use that calculator posted above.