An IP address is made up of 32 bits, split into 4 octets. Some bits are reserved for identifying the network and the other bits are left to identify the host.
There are 3 main classes of IP address that we are concerned with.
Class A Range 0 - 127 in the first octet (0 and 127 are, however, reserved)
Class B Range 128 - 191 in the first octet
Class C Range 192 - 223 in the first octet
Below shows you how, for each class, the address is split in terms of network (N) and host (H) portions.
NNNNNNNN . HHHHHHHH . HHHHHHHH . HHHHHHHH Class A Address
NNNNNNNN . NNNNNNNN . HHHHHHHH . HHHHHHHH Class B Address
NNNNNNNN . NNNNNNNN . NNNNNNNN . HHHHHHHH Class C Address
At each dot I like to think that there is a boundary, therefore there are boundaries after bits 8, 16, 24, and 32. This is an important concept to remember.
Typical questions you may see are those asking what a host range is for a specific address or which subnet a certain address is located on. I shall run through examples of each, for each class of IP address.
What subnet does 192.168.12.78/29 belong to?
You may wonder where to begin. Well to start with let's find the next boundary of this address.
Our mask is a /29. The next boundary is 32. So 32 - 29 = 3. Now 2^3 = 8 which gives us our block size.
We have borrowed from the last octet as the 29th bit is in the last octet. We start from zero and count up in our block size. Therefore it follows that the subnets are:-
Our address is 192.168.12.78 so it must sit on the 192.168.12.72 subnet.
What subnet does 172.16.116.4/19 sit on?
Our mask is /19 and our next boundary is 24. Therefore 24 - 19 = 5. The block size is 2^5 = 32.
We have borrowed into the third octet as bit 19 is in the third octet so we count up our block size in that octet. The subnets are:-
Our address is 172.16.116.4 so it must sit on the 172.16.96.0 subnet. Easy eh?
What subnet does 10.34.67.234/12 sit on?
Our mask is 12. Our next bounday is 16. Therefore 16 - 12 = 4. 2^4 = 16 which gives us our block size.
We have borrowed from the second octet as bit 12 sits in the second octet so we count up the block size in that octet. The subnets are:-
Our address is 10.34.67.234 which must sit on the 10.32.0.0 subnet.
We will now change the type of question so that we have to give a particular host range of a subnet.
What is the valid host range of of the 4th subnet of 192.168.10.0/28?
Easy as pie! The block size is 16 since 32 - 28 = 4 and 2^4 = 16. We need to count up in the block size in the last octet as bit 28 is in the last octet.
Therefore the 4th subnet is 192.168.10.48 and the host range must be 192.168.10.49 to 192.168.10.62, remembering that the subnet and broadcast address cannot be used.
What is the valid host range of the 1st subnet of 172.16.0.0/17?
/17 tells us that the block size is 24-17 = 7 and 2^7 = 128. We are borrowing in the 3rd octet as bit 17 is in the 3rd octet. Our subnets are:-
The first subnet is 172.16.0.0 and the valid host range is 172.16.0.1 to 172.16.127.254. You must remember not to include the subnet address (172.16.0.0) and the broadcast address (172.16.127.255).
What is the valid host range of the 7th subnet of address 10.0.0.0/14?
The block size is 4, from 16 - 14 = 2 then 2^2 = 4. We are borrowing in the second octet so count in the block size from 0 seven times to get the seventh subnet.
The seventh subnet is 10.24.0.0. Our valid host range must be 10.24.0.1 to 10.27.255.254 again remebering not to include our subnet (10.24.0.0) and the broadcast address (10.27.255.255).