Saturday, February 23, 2013

Reversing Subnet mask and bit notation

     This article is a follow up to the IP subnetting. In this article I will discuss about reversing subnet mask to find IP address ranges inside a network. I will also explain what is bit notation. Let's get started...

Reversing Subnet Mask

Reversing a subnet mask is very easy to do and it is generally used to find address ranges and class of a network. The default subnet masks for three classes of networks are as follows:
Class A - 255.0.0.0
Class B - 255.255.0.0
Class C - 255.255.255.0
And as we perform subnetting, the host bits on the left side are converted to network bits.
Let's say, for example, we have a subnet mask 255.255.255.224. Now this is a class C network subnet mask (although it is not always the case). Let's convert it to binary-
11111111.11111111.11111111.11100000
Consider the last octet. It has 3 network bits and 5 host bits. It reveals two things. First, since there are 3 network bits and maximum number represented with 3 binary digits is 7 (111), the address range is divided into total 7 segments. Similarly, 5 host bits and the maximum number represented by 5 bits is 32 (11111), there are 32 addresses available per network segment. This is including the network identifier and the broadcast address, so we have to subtract that to get the actual number of usable hosts.

Let's take another example. The subnet mask is 255.255.255.252.
Converting it to binary-
11111111.11111111.11111111.11111100
Concentrate on the last octet. Since it has 6 network bits, there can be 64 individual network segments in this address range. (max. number represented by 6 binary bits (111111) is 64) The given address has only two host bits. Hence, there are only 4 addresses available per segment. Excluding the first and last. There are only two usable addresses per network segment. Two addresses per segment is not very useful inside a corporate network. This type of subnet masking is mainly used in WAN links to avoid wastage of address ranges.

Bit Notation

Bit notation is just another way of representing subnet masks. Subnet masks till now were represented as a series of 4 octets. In the bit notation, we consider only the number of 1's in the binary form of subnet mask and write it against the ip address.

For example, consider ip address 192.168.10.34 having subnet mask 255.255.255.240.
Its binary representation is 11111111.11111111.11111111.11110000
Here we count the total number of 1's in this form which is 28. It can be written with the IP address as-
192.168.10.34/28.
Another example, an ip address 192.168.2.3 has subnet mask 255.255.255.192. Its binary form is 11111111.11111111.11111111.11000000
Here there are 26 1's present and hence bit notation becomes-
192.168.2.3/26.

Thanks for reading! Do leave a comment below...

No comments:

Post a Comment