cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
334
Views
0
Helpful
6
Replies

subnetting

carl_townshend
Spotlight
Spotlight

How many addresses can i have with a 252 mask, is it 2. do you just times by 2 the number of zeros you have, i.e if I have 2 zeros left, do I just do 2 x 2 -2 for the network and broadcast address ?

6 Replies 6

pkhatri
Level 11
Level 11

Hi Carl,

I presume you mean a 255.255.255.252 mask, right ?

One simply way of working out the number of useable addresses you can have in this case is to subtract the last octet from 256 and then take a further 2 away from it. You have to subtract 2 from this to account for the network and broadcast addresses, respectively.

Some examples:

255.255.255.252: 256-252-2 = 2

255.255.255.248: 256-248-2 = 6

This only works if the first three octets are 255. However, this can be extended to cases where the mask is less than /24 too.

Hope that helps,

Paresh

PS. Pls rate helpful posts.

burleyman
Level 8
Level 8

Yes and no.....here is how I do it.

255.255.255.255 = 1 ip address

255.255.255.254 = 2 ip addresses

255.255.255.252 = 4 ip addresses

255.255.255.248 = 8 ip addresses

255.255.255.240 = 16 ip addresses....

Note...you have to subtract 2 ip addresses from the above to get useable IP Addresses

Do you see a pattern?...baicly you double as you go up...so 255.255.255.224 would be 32 ip addresses and so on.

hope this helps.

Mike

Hi All,

how about some of your tricks for less than /24 and /16. Curious to see how they are done quickly, as I sometimes find them frustrating. Cheers.

coolboarderguy...

Hi all,

Here's my way of doing it:

Prefix length >= 24:

(256 - fourth_octet_of_mask) - 2

16 >= Prefix length > 24:

256*(256 - third_octet_of_mask) - 2

8 >= Prefix length > 16:

65536*(256 - second_octet_of_mask) - 2

Prefix length < 8:

16777216*(256 - first_octet_of_mask) - 2

Hope that helps.

Paresh.

johansens
Level 4
Level 4

Are you trying to make a algorithm to program in a programminglanguage, or are you just curious to know how to make the calculations yourself?

I find the best way is to simply remember how many you can have with the different masks:

255 = 1 address - subnet - broadcast = 0 hosts

254 = 2 addresses - subnet - broadcast = 0 hosts

252 = 4 addresses - subnet - broadcast = 2 hosts

248 = 8 addresses - subnet - broadcast = 6 hosts

240 = 16 addresses - subnet - broadcast = 14 hosts

224 = 32 addresses - subnet - broadcast = 30 hosts

192 = 64 addresses - subnet - broadcast = 62 hosts

128 = 128 addresses - subnet - broadcast = 126 hosts

0 = 256 addresses - subnet - broadcast = 254 hosts

Ie.. just remember the 255, 254, 252... part and of course the obligatory binary value-sequence of 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, etc. etc. then you are set... :)

If you need to have more than a /24 network, then you just multiply like this:

255.252.0.0 = two zeroes before a 'interesting' mask-value.. = 256 * 256 * the value which is 4 here = 262144 - subnet - broadcast = 262142 hosts...

There is of course the 'other' way:

When you have a value unequal to 255, subtract the value from 255 and you have the Cisco wildcard.. with the wildcard, subtract one address and you have the number of hosts..

255.255.255.252 = 0.0.0.3, 3-1 = 2 hosts

255.255.255.240 = 0.0.0.15, 15-1 = 14 hosts

255.255.255.224 = 0.0.0.31, 31-1 = 30 hosts

But for the longer prefixes, you'll need to first add one to each part of the wildcard values and multiply them together before subtracting the subnet and broadcast again:

255.252.0.0 = 0.3.255.255 = (3+1)*(255+1)*(255+1) = 262144, 262144-subnet-bcast = 262142 hosts

Did it help, or did I confuse you?

hi

thanks johnansens, im confused about this " 256 * 256 * the value which is 4 here " , what value goes at the end, is it the first interesting mask ?