Subnetting Restriction – What It Means

ipip addressipv4subnet

I was reading Data Communication book by Forouzan in which there is a one restriction put on CIDR subnetting by Internet authorities:

First IP address in the block should be evenly divisible by the number of addresses. For example, below, the first address, when converted to a decimal number, is 3440387360, which when divided by 16 (block size) results in 215024210.
enter image description here

Since this did not clear the practical significance behind this restriction I went on exploring and came across the video where it is explained as follows:

Whenever we divide any number by kth power of 2 (another restriction being that the block size should be 2^k), the reminder is least significant k bits. So evenly divisible by 2^k means that least significant k bits should all be 0. This way the first address of the allocated address block can be used as a block ID since it has all 0s in the host ID part.

Now that seems more logical despite the fact that I dont understand how

evenly divisible by the number of addresses 2^k

translates to

least significant k bits should all be 0

Can't it be just that the decimal equivalent of least significant k bits should be divisible by 2. I mean if least significant 4 bits (for a block of 2^4 addresses) is binary 1010, then it translates to decinal 10 which is divisible by 2.

So in short why is evenly divisible translates to all 0 LSBs?

Best Answer

This restriction on CIDR was created to forbid that an arbitrary block could be created, let's see an example:

Suppose that we have the full block 192.168.1.0/24 and we want to subnet it with /27

/27 means that from the 32 bits of the address, 27 are network, and 5 are host, then we have 2^5 addresses per subnet.

The subnets are:

First Address    Last Octet  Last Octet 
                             in decimal /32

192.168.1.0      000 00000       0
192.168.1.32     001 00000       1
192.168.1.64     010 00000       2
192.168.1.96     011 00000       3
192.168.1.128    100 00000       4
192.168.1.160    101 00000       5
192.168.1.192    110 00000       6
192.168.1.224    111 00000       7

The first address divided by the number of addresses per subnet is always an integer without decimals, and that is possible because the last k bits are 0.

It makes impossible to have a block starting on 192.168.1.133, for example, because 133/32 = 4.15625

Related Topic