Cisco Support Community
Community Member

Subnetting. How to calculate hosts and subnets if /P < N


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 ????

Everyone's tags (1)

If you're using classful

If you're using classful networks, your last example is illegal because it creates a supernet. is a class C network and can only be subnetted with masks greater than 24 bits. If you were doing this with a class B network like, then your formula would work: 2^(16-12)=16.

Classful networks aren't often seen these days, so running with a formula of 2^(P-N) still makes sense, but N should be the mask length of your assigned CIDR block rather than that of a fixed class-based mask.

CreatePlease to create content