1

I have stuck with formula how to calculate hosts and subnets.

For instance, I use formulas:

Host = (2^(32-P))-2, where 32 are all bits for network, /P - is prefix

Subnets = 2^(/P-N), where /P is prefix and N - is network part of class A,B or C

if I have mask 255.255.255.128(/P=25) and IP 192.10.1.0, there will be 126 hosts and 2 subnets

hosts = (2^(32-25)-2)=126

and subnets= 2^(25-24)=2, N=24 as it is class C

So if I have address 192.10.1.0 and mask 255.240.0.0, /P=12 and N = 24

hosts = (2^(32-12))-2=1048574

subnets = 2^(12-24) or for this variant I should use formula 2^P to calculate subnets ????

1
  • Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer.
    – Ron Maupin
    Aug 11, 2017 at 0:17

1 Answer 1

8

First things first: Network Classes (A-E) are obsolete since 1993. Please stop using them.

Your formula is wrong, if you want to know how many /24 networks fit into a /12 you use:

2^(24-12) = 4096

A /12 has 12 fixed bits:

11111111.11110000.00000000.00000000

A /24 has 24 fixed bits:

11111111.11111111.11111111.00000000

The difference between these two are the bits you can use for addressing your subnets (Here I used X to make them visible):

11111111.1111XXXX.XXXXXXXX.00000000

2^12 are 4096 possible combinations, and in conclusion 4096 possible /24s.

If you want the amount of hosts (/32) in a /23, use 2^(32-23) = 512 and substract 2 addresses for network address and broadcast. You end up with 510 hosts.

1
  • Great answer. Shows the basics and the shortcut. Well written, correct and succinct. Bravo, me amigo
    – DTK
    Dec 1, 2014 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.