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 and IP, 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 and mask, /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 ????

  • 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 '17 at 0:17

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:


A /24 has 24 fixed bits:


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


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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