Calculating a subnet address

Soldato
Joined
1 Jun 2005
Posts
5,152
Location
Kent
Does anyone know a formula for working out the address of a subnet within a large range of subnets? For example, if i have a class A IP and subnet it into 2048 subnets, whats the address of subnet X?

I can work it out myself, but i don't have a good way of explaining my method, so would like to know a formula to work it out (taking into account that subnet 0 would be the 1st subnet).
 
What kind of solution are you looking for, something that can be programed or a simple process that someone with pen and paper who knows the powers of 2 and can do some simple math to get the quad decimal addresses?
 
What i am looking for is something i can do with a pen, paper and calculator. Its simple to work out for example the 4th subnet in the 192.168.0.0/27 network, but working out the 210th subnet in the 10.0.0.0/19 subnet is a little more complex.
 
OK, here's my take on this ...

You've got a class A address which is subnetted into 2048 networks.
This 11 bits (2048 = 2 ^ 11) plus the default Class A /8 gives you your /19 network mask.

To get the networks, we only need to calculate for the octets affected by the subnet mask, so your starter /8 means the first octet remains the same and we need to consider the next 11 bits i.e. all 8 bits of the second octet and the first 3 bits of the third. The remaining 5 bits of the third octet are part of the host identifer, so this means the network part must be a multiple of 32 (2 ^ 5).

So, to work out the offset for subnet X, just multiply 32 by X. Divide by 256 to get the second octet value and the remainder is the third octet.
Example for 10.0.0.0, subnet 100
100 x 32 = 3200, 3200 / 256 = 12 R 128, Network address 10.12.128.0

Or, multiplying by 32 and dividing by 256 is the same as dividing by 8, with the remainder the number of 32s

Example for 10.0.0.0, subnet 937
937 / 8 = 117 R 1, 1 * 32 = 32, Network address 10.117.32.0
 
Last edited:
Great thats just what i was after, thankyou.

One more question, when using that method should i be searching for exactly the subnet i want, or 1 less then the subnet i want? I ask because 10.0.0.0 would be subnet 1, 10.0.32.0 subnet 2 etc... so because counting starts at 0 should i subtract 1 from the subnet i am after?
 
This could get confusing as the all zeros subnet is always known as subnet 0, 10.0.0.0 in the example.

Maybe a slight renaming to subnet #1, subnet #2 etc. in which case you do as you posted and calculate for 1 less.
 
Back
Top Bottom