# Calculating number of bits for host reservation

My question is about calculating the number of bits to be able to represent a required number of hosts (its a basic question .

I was following the explanation at nugget lab (Subnetting Examples.pdf - "Great Exception")

I'll be quoting this to make it easy:
There is a similar rule for finding the number of bits to reserve for hosts. For example, if I wanted to break a range into 25 hosts per network, I know that I'll need to save 5 bits as host bits to satisfy the requirement. This rule works fine, but does not account for the two hosts that are unusable from every range: the network IP address and the broadcast IP address. The fact that binary counting starts from zero helps us with one of those IP addresses, but we can still come up one short in certain cases. For example, if we were asked to break a network into subnets that can hold up to 31 hosts, you would assume it would take 5 bits since 31 in binary is:
0 0 0 1 1 1 1 1
However, when you work out the problem you'll find that you only get 30 hosts per subnet (1 IP address short). The same thing happens with every “full” binary number: 3, 7, 15, 31, 63, 127. So how do you avoid this issue? You can always add 1 to the number of hosts required. For example, if you're asked to break a range into 25 hosts per subnet, figure it out for 26. If you're asked to break a range into 63 subnets, figure it out for 64…and so on.
I realize this exception gets somewhat technical… so to summarize:
When subnetting based on the number of networks, SUBTRACT 1 from the number
When subnetting based on the number of hosts per network, ADD 1 to the number

The way they explain it, is by searching the first exponent of 2, that represents a number lower than the number of hosts you are searching. For example, if you search 100 hosts, '64' is the first number that gets a binary '1' (since 128 is higher then 100).
```128  64  32  16  8  4  2  1
0    1    x   x   x  x  x  x

```

x = don't care, since we allready found the highest bit. So, we will need 7 bits for the hosts.

This approach is ok, but there is a problem when you need for example 8 hosts, you'll endup with 4 bits since '1000' is binary for '8'. However, you are looking for 8 combinations, so the correct number of bits is 3, since 2³ = 8.

Now, I find my approach simpler, and it takes care of everything: just add '2' to the number of hosts you are searching, and then figure out how many bits you need to represent all the combinations (hosts).

So, if I would be ask to give the number of bits required to represent 3 hosts, then I would say 3 bits. 3 hosts + 2 hosts = 5 host, 2 bits is not enough since 2² = 4. 3 bits is enough since 2³ = 8.

Is my approach also fine ? Which is the common approach ?

• I really didn't like the way the Nuggets did subnetting. I think they made it a bit more complicated than it had to be with the calculator and converting to binary tricks (the 291 MS Press book was far worse though).

It seems easy enough to do in your head. Take whatever the required hosts are and add two. You don't need to do that for the subnet bits (in most cases - research subnet zero for more).

I do exactly what you do. It's easier and faster (at least for me). Nearly every trick I've seen just seems to make things more complicated.

Probably the best tip to keep in mind is that each subsequent bit is twice the value while each previous bit is half that value. By simply remembering that the 10th bit is 1024 and the fifth bit is 32, you can get to pretty much any reasonable value by doubling or halving that value a few times (i.e. What's the 12th bit worth? 1024*2*2 = 4096).

I think the best subnetting instruction I got was from Chris Bryant. His CCNA guide or his CCNA Trainsignal videos are great.
• errorken: If you read the entire guide, he says to add 2.

I've searched and read tons of subnetting guides. The guide from Jeremy Cioara(latest cbt nuggets instructor for ccna/ccent) has been the very fastest. After much practice with his guide and doing lots of examples, it's very easy to do complete subnetting back and forth in less than 10 seconds, in my head.

I really can't say enough about his video and pdf subnetting guides.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9638535,"math_prob":0.82360995,"size":5166,"snap":"2023-40-2023-50","text_gpt3_token_len":1344,"char_repetition_ratio":0.1352189,"word_repetition_ratio":0.46759722,"special_character_ratio":0.26558265,"punctuation_ratio":0.105405405,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97625005,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-26T19:50:54Z\",\"WARC-Record-ID\":\"<urn:uuid:534b96b6-f494-4507-a354-48c97805373d>\",\"Content-Length\":\"91108\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:73c21e12-0495-46bd-acf8-d2dc2d94d87e>\",\"WARC-Concurrent-To\":\"<urn:uuid:86c8514f-6f43-46eb-9840-be18eef7d1cf>\",\"WARC-IP-Address\":\"162.159.138.78\",\"WARC-Target-URI\":\"https://community.infosecinstitute.com/discussion/32826/calculating-number-of-bits-for-host-reservation\",\"WARC-Payload-Digest\":\"sha1:WPG4CUXI3UUDH2XNKDERIEGFS2M5POEG\",\"WARC-Block-Digest\":\"sha1:6S6AJE22MYWCDD6PK5DN6M4W4DAKAOBT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510219.5_warc_CC-MAIN-20230926175325-20230926205325-00142.warc.gz\"}"}