1

My way to calculate netmask number of host, for example: i want to know the number of hosts for netmask 255.255.255.192 (prefix 26)

255.255.255.192 11111111.11111111.11111111.11000000             26                      128+64=192

the 192 is 128+64 of the two "1" bits of the latest octet, the number of host is the number of 0 bits(host part) of the latest octet, so 000000 are 6, so 2^6-2 is 62, and ipcalc confirm is ok

ipcalc 10.2.0.1/26
Address:   10.2.0.1             00001010.00000010.00000000.00 000001
Netmask:   255.255.255.192 = 26 11111111.11111111.11111111.11 000000
Wildcard:  0.0.0.63             00000000.00000000.00000000.00 111111
=>
Network:   10.2.0.0/26          00001010.00000010.00000000.00 000000
HostMin:   10.2.0.1             00001010.00000010.00000000.00 000001
HostMax:   10.2.0.62            00001010.00000010.00000000.00 111110
Broadcast: 10.2.0.63            00001010.00000010.00000000.00 111111
Hosts/Net: 62                    Class A, Private Internet

My question is: how to know/calculate the number of subnets with a prefix..for example 26 or 27? I have to do the net part(26 "1" bit^2=)?

elbarna
  • 466

2 Answers2

2

As you already know from calculating hosts, if you have n bits, then you can have 2n different combinations of those bits. You can use exactly the same calculation for subnets as well – at least when all subnets have the same size.

For example, if you have a /24 network (aka "class C") and want to divide it into equal-size /29 subnets, you'll be using 29−24 = 5 subnet bits and therefore you have 2(29−24) = 25 = 32 subnets.

This works regardless of network size; any difference in 'classes' is irrelevant. As another example, if you have a /16 network and want to divide it into /27's, it'll be 2(27−16) = 211 = 2048 subnets.

(And if you divide a network into /32's, you'll get the number of hosts the same way!)

grawity
  • 501,077
1

I found the solution, to calculate subnets, for example for netmask with prefix 29

255.255.255.248 11111111.11111111.11111111.11111000             29                      128+64+32+16+8=248

we have in the latest octet

11111000

so, the number of host is 6

000=3=2^3-2=6

the number of subnets is 32

11111=2^5=32

This way is ok for class C of ip, for class A and B is a little difficult, but a good and nice help is here

elbarna
  • 466