Wednesday, October 23, 2013

Network ID vs. Subnet ID

The fact that a Network Identifier and a Subnet Identifier are different things never occurred to me until I started studying for Cisco's ICND1 exam. In the workplace the two terms are often used interchangeably even though they technically mean different things. Below I will try to explain the two concepts, so that you can distinguish the difference.

For both examples we will use the following IP address and subnet mask:

172.16.5.120 255.255.252.0

Class A Network:   1-126.X.X.X 255.0.0.0
Class B Network: 128-191.X.X.X 255.255.0.0
Class C Network: 192-223.X.X.X 255.255.255.0

The network ID is the first IP address in the "Network". Since our IP address falls in the Class B network range, we simply drop the last two octets and replace them with 0's. Our Network ID is 172.16.0.0. If our IP address were in the Class A network range, we would only replace the last three octets with 0's and if it was in the Class C range we would replace only the last octet with a 0. We do this because of the subnet mask of the different classes.

10.25.0.50 = 10.0.0.0
192.168.10.25 = 192.168.10.0

To determine Subnet ID, we first have to identify which bits are the network bits and which bits are the host bits. In order for the third octet of our subnet mask to be 252 we require 22 network bits. You can determine this by using the figure below.

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
 1  |  1 |  1 |  1 | 1 | 1 | 0 | 0

We know that the first two octets provide 8 network bits each, for a total of 16. We are left to figure out how many network bits are required for the third octet. Since the third octet is 252, we subtract that from 255 (because 8 bits can provide a maximum real number of 255) and then leave off the bits required to support this number. In this case 2 bits which add up to 3 (2+1), so they become host bits. If the third octet were 248 we would leave off the last 3 bits for a total of 7 (4+2+1) and so on. In binary, our subnet mask literally looks like this:

11111111.11111111.11111100.00000000
   255  .   255  .   252  .   0  

The 1's are referred to as the network bits and the 0's are referred to as the host bits. As I said, the two bits we left off add up to 3 and this is how we determine the breakdown of the different subnet ranges. Remember, when counting in binary you start with 0. The third octet of the first range will start at 0 and end at 3, the next will start at 4 and end at 7, and so on.

172.16.0.0 - 172.16.3.255
172.16.4.0 - 172.16.7.255
172.16.8.0 - 172.16.11.255
    and so on down to
172.16.252.0 - 172.16.255.255

Our IP address again is 172.16.5.120. Using what we learned we can now determine that our Subnet ID is 172.16.4.0, because our IP address falls within that range in our chart.

Now you know the difference between a Network ID and a Subnet ID, I hope this has been helpful. Please leave a comment if you need further clarification and please let me know what you thought!