let's say I have 200.35.1.0/24 network block. I need to address 20 hosts on each subnet. How do I specify the minimum number of host bits that are required?
3 Answers
First, you have to add 2 addresses to the number of hosts you want. These are for network and broadcast addreses (therefore, for 20 hosts you get 20+2=22)
Second, convert this number to the binary (22d = 10110b)
Now, count how many bits you used and that's your answer (in this case, it will be 5 bits, so 32-5=27 bits for network) Your subnets will be then 200.35.1.0/27, 200.35.1.32/27, 200.35.1.64/27, and so on..
Alternatively, you can use some network subnet calculator, most of them allow you to choose or enter number of hosts per subnet (always choose closest bigger number by at least 2 hosts, as I said in 1st step). Example of such calculator is http://www.subnet-calculator.com/
- 344
- 1
- 3
I think everyone is everywhere of how to get the number of available hosts given a prefix length of a certain size, for example with an /24 IPv4 prefix, you have 32-24 = 8 bits for hosts, giving 2^8 = 256 hosts or 254 "usable" ones. This is usually taught in any networking class or explanation of subnetting.
The inverse of 2^x is log(x)/log(2) so to get the number of bits for 22 addresses, you just do:
log(22)/log(2) = 4.459
Obviously you can't do decimal prefix length so you have to round that up to the closest integer, which is 5. You need 5 bits, or 32-5 = 27, i.e. a /27 network!
- 1,096
- 5
- 11
With a class C to get hosts, I count from 128 backwards cutting it in half each step. So 128, 64, 32. It has to be 32 hosts because half of 32 is 16, not enough for 20. That's 3 bits borrowed. That is from a standard /24 to a /27. The networks are added by starting with 2 and doubling them, so 2, 4, 8 which gives you 8 nets for 3 bits borrowed. I made a video for my class that shows you how to make an easy to remember cheat sheet, that helps you understand the basic concept of subnetting a class C network. https://www.youtube.com/watch?v=zqH0COM81Qc
- 1
- 4