My problem has always been that you already know how many subnets you need and how many host per subnet, so how do you determine the correct subnet mask.
Below are the step to determine the subnet mask, Network ID's, IP ranges per subnet and Broadcast ID's. As an example I want 8 subnets with at least 100 hosts per subnet on a private network.
1. Determine number of subnets required. Let say we want 8 subnets
2. Determine the first factor of '2' above the number of subnets. Since 8 is a factor of 2 (2^3) we will need go up 1 and use 2^4 or 16. This is the number of subnets
3. Subtract that number from 256. 256 - 16 = 240. This number will be to 'mask' and will be placed in the last octet for now (i.e. 255.255.255.240).
4. Determine the number of usable subnets. The formula is 2^(subnets)-2 or 2^4-2 = 14
5. Determine the number of hosts required per subnet. If this number greater than 256 / (number of subnets) then we will have to move then 'mask' to the left. Lets say we want to have a 100 hosts per subnet. So, 256 / 16 = 16. Since 100 is greater than 16 we will need to move the 'mask' to the left 1 octet. (255.255.240.0). This leaves us with 4094 usable IP addresses per subnet. X.X.16.256, so 16 * 256 = 4096 - 2 = 4094 per subnet, but remember that we will only have 14 valid subnets.
6. Now that we have the number of subnets and the subnet mask. How do we determine the following: network ID for each subnet? Valid range for each subnet? Broadcast IP for each subnet?
7. Let say we will be using 192.168.x.x for our IP scheme.
8. Determine the IP block size. This is easy. It is the number of subnets. In our example Block Size = 16
9. The block size will help us determine the Net ID, range and broadcast. See the table below. Notice that the Network ID's are a multiple of the block size and the Broadcast ID's are 1 IP address before the next block.
NOTE: Any block that has a 0 (zero) or 255 in the 'mask' octet is not valid (in the example the mask octet is the 3rd) , so the first and last lines below are not valid.
Network ID Valid IP range Broadcast IP
192.168.0.0 192.168.0.1 - 192.168.15.254 192.168.15.255
192.168.16.0 192.168.16.1 - 192.168.31.254 192.168.31.255
192.168.32.0 192.168.32.1 - 192.168.47.254 192.168.47.255
192.168.48.0 192.168.48.1 - 192.168.63.254 192.168.63.255
192.168.64.0 192.168.64.1 - 192.168.79.254 192.168.79.255
192.168.80.0 192.168.80.1 - 192.168.95.254 192.168.95.255
192.168.96.0 192.168.96.1 - 192.168.111.254 192.168.111.255
192.168.112.0 192.168.112.1 - 192.168.127.254 192.168.127.255
192.168.128.0 192.168.128.1 - 192.168.143.254 192.168.143.255
192.168.144.0 192.168.144.1 - 192.168.159.254 192.168.159.255
192.168.160.0 192.168.160.1 - 192.168.175.254 192.168.175.255
192.168.176.0 192.168.176.1 - 192.168.191.254 192.168.191.255
192.168.192.0 192.168.192.1 - 192.168.207.254 192.168.207.255
192.168.208.0 192.168.208.1 - 192.168.223.254 192.168.223.255
192.168.224.0 192.168.224.1 - 192.168.239.254 192.168.239.255
192.168.240.0 192.168.240.1 - 192.168.255.254 192.168.255.255
10. Note that I have not used any binary....yet. The only way to determine the CIDR or slash value is to use binary. Open calc.exe, click view and select scientific. Enter 240 and select bin. The value is 11110000. Now plug that into a binary of the subnet mask. 11111111.11111111.11110000