How to split a network block to sub blocks in Java. I want to find out from a given 67.10/16 block, what blocks of /18 can I generate. For e.g. output should be this..
67.10.0/18
67.10.64/18
67.10.128/18
67.10.192/18
Or If I input 67.10/16 and the target cidr of /17 then the output should be
67.10.0/17
67.10.128/17
What is the best and efficient way of doing this.
Thank You
For example – subnet 67.10.1.1 /16 into four blocks.
In general:
Convert the base IP address to a number.
01000011 00001010 00000001 00000001 (1,124,729,089)
Convert the base mask to a number.
11111111 11111111 00000000 00000000 (4,294,901,760)
Mask the base IP with the mask giving the true base IP.
01000011 00001010 00000000 00000000 (1,124,728,832)
Convert the new mask (/18) to a number
11111111 11111111 11000000 00000000 (4,294,950,912)
XOR the original mask and the new mask to get the addition factor
00000000 00000000 11000000 00000000 (49,152)
Starting with the true base IP