In the previous post, we talked about the need for subnetting. However, our final purpose is to be able to perform subnetting based on some requirements. Therefore, it is important to understand some network terminologies. Also, it requires some knowledge of the binary number system. Otherwise, you can just memorize the numbers that we are going to use. Furthermore, we are talking about IPv4 networks in this post.
Basic Terminologies: Network ID and Host ID
Network ID is the portion of an IP address that identifies the TCP/IP network on which a host resides. A host can be any piece of equipment that is connected to the network. For example, if you look at your devices in the same network, you may find the IP addresses starting from ‘192.168.1.’. They may range from ‘192.168.1.1 to 192.168.1.254’. Since all the devices are in the same network, the network ID is ‘192.168.1’ or ‘192.168.1.0’. In this case, host ID may range from ‘1’ to ‘254’ or ‘0.0.0.1’ to ‘0.0.0.254’. So, a whole IP address is a combination of Network ID and Host ID.
IP address = Network ID + Host ID
How to identify the Network ID? Now, there are two more network terminologies that we have to understand. They are Subnet Mask and Gateway. But before that, let’s convert the address into the binary number system.
192.168.1.0 = 11000000.10101000.00000001.00000000
192.168.1.115 = 11000000.10101000.00000001.1110011
We have to convert each portion separated by dots to binary. Each portion is called an octet. So, as we can see above, the first 3 octets or 24 binary digits identify network in our example. Similarly, the last 8 digits signify the host. The number 24 is called the subnet length prefix. So, let’s look into the subnet mask and the subnet length prefix.
If you look into the connection properties of your network, you might find something like follows:
IP address: 192.168.1.6
Subnet mask: 255.255.255.0
Subnet length prefix: 24
The above IP address can be written along with the subnet length prefix as
As previous, let’s convert the subnet mask to the binary system.
255.255.255.0 = 11111111.11111111.11111111.00000000
So, we can see that, there is a series of 1s in the first 3 octets. There is a total of 24 ones. Hence, the prefix is 24. If we AND the subnet mask with the IP address bitwise, we get the Network ID.
IP address: 192.168.1.6 = 11000000.10101000.00000001.00000101
Subnet Mask: 255.255.255.0 = 11111111.11111111.11111111.00000000
AND result(NetID): 11000000.10101000.00000001.00000000 = 192.168.1.0
Let’s take another example.
IP address: 192.168.1.186 = 11000000.10101000.00000001.10111010
Subnet Mask: 255.255.255.240 = 11111111.11111111.11111111.11110000
AND result(NetID): 11000000.10101000.00000001.10110000 = 192.168.1.176
Also, an important point is the subnet mask should be a series of 1 and 0. For example, the valid subnet masks are:
11111111.00000000.00000000.00000000, 11111111.11110000.00000000.00000000, 11111111.11111111.11111111.11111110.
Similarly, the invalid subnet masks can be:
So, the valid values in decimal for each octets are:
0, 128, 192, 224, 240, 248, 252, 254, 255
Examples of subnets
Suppose, we have two IP addresses
192.168.1.250 having subnet mask of
255.255.255.248. Since there are 255 in the first 3 octets, it is sure that they are the part of the Network ID. That leaves us with the remaining fourth octet. For me, I feel easy to calculate the bits for hosts. As we know that 248 signifies the Network ID, the remaining should signify the Host ID. Since there are 8 digits, the total possible combination is
28 = 256. Now,
256 - 248 = 8 = 23. Therefore, we can say that the last 3 digits are the part of hosts and the first 5 digits are the part of the network. Now, let’s perform AND operation of the subnet mask with the above IP addresses. We obtain the following Network IDs:
192.168.1.248. This means they are part of different networks and they need gateways to communicate with each other.
In the above example, if the subnet mask is
255.255.255.0, then the Network ID will be
192.168.1.0 for both the IP addresses. This means that the IP addresses are in the same network.
256 / 8 = 32. This means we can divide a network
192.168.1.0/24 to 32 smaller networks consisting of 8 hosts in each network. In total, there are still 256 hosts. However, it is just a mathematical calculation. In reality, we are always short of two addresses, network ID and broadcast address. The first address of a network is network ID and the last address is broadcast ID.
Network ID: 192.168.1.0
Broadcast address: 192.168.1.255
Network ID: 192.168.1.8
Broadcast address: 192.168.1.15
Network ID: 188.8.131.52
Broadcast address: 184.108.40.206
Hence, it is important two exclude the two address while calculating the number of actual hosts. We will talk about this in another post.
In a nutshell, if you understand the above network terminologies, you can proceed to create subnets. See our next post for further explanations.