Say for example I combine 16 existing prefixes which have '/12' netmask length, how would I calculate the netmask length of the new address?
I know how to combine 2 addresses, but not sure how to go about with this?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.Sign up to join this community
I know how to combine 2 addresses...
It's the exact same "power of 2" math... 2 = 2^1, so 2 /12's equal (12-1) /11. 16 = 2^4, so 16 /12's become a (12-4) /8.
In theory, in practice, the /12's may not fall on an even power of 2. [See Also: Subnet Table] x.0/12 and x.16/12 can form x.0/11, but x.16/12 and x.32/12 cannot form x.16/11 (because 16 is the middle of x.0/11)
aggregate tool written by Joe Abley (available in Ubuntu, probably in other Linux distribution as well) can be useful:
% aggregate aggregate: maximum prefix length permitted will be 32 10.0.0.0/12 10.16.0.0/12 10.32.0.0/12 10.48.0.0/12 10.64.0.0/12 10.128.0.0/12
10.0.0.0/10 10.64.0.0/12 10.128.0.0/12
I simply write them out and work it out. As an example let's take the following few prefixes:
10.32.0.0/16 10.45.0.0/16 10.37.0.0/16 . . .etc
They all match on the first octect so no worries. You need to figure out where they match on the first different octect. In the example above we write them out and convert them to binary. Make a note of where they are the same in binary:
32 37 45 00100000 00100101 00101101 ----xxxx
The above all match in the first four bits, and so that becomes the boundary. The amount of bits also tells you the slash you're going to use. You then use the 'all zeros' address as the subnet. In the above example, they all match up to the 4th bit in the second octect. Each octect is 8 bits and so the new bit boundry becomes 8 + 4 = 12.
so our end result of the above is: 10.32.0.0/12