# Combine the following IP Addresses into a single block

I was asked to combine the ip addresses into a single block: 16.27.24.0/26, 16.27.24.64/26, 16.27.24.128/25

I managed to convert the given ip addresses into binary: 00010000.00011011.00011000.00000000 | 00011010 00010000.00011011.00011000.01000000 | 00011010 00010000.00011011.00011000.10000000 | 00011001

I am not quite sure what needs to be done in order to convert it properly. I believe that in this link it is explained what is supposed to be done. I should do it the way it is explained there. I am not able to access it, but whatever is shown in the preview, that is probably the way it would be gone about. Please help. Thanks

• Don't convert the netmask to binary as well, that just makes it complicated.
– orlp
Commented May 13, 2017 at 11:59

The address is just a 32-bit binary number. E.g. yours:

00010000.00011011.00011000.00000000
00010000.00011011.00011000.01000000
00010000.00011011.00011000.10000000


However, these addresses are very precise, and without any further information point to exactly one address. But we want to be more general, and be able to talk about a whole group of addresses. That is a block, and what the netmask is for.

When I use a netmask of /n, it means 'only look at the first n bits of this address, those are meaningful, the rest can be anything'. Think of it like this, the address we give is full, but then we strike out the most specific parts that can be anything:

United States, Middleberge, Otter Lane 5322

In your case, the first 26 or 25 bits matter, so we strike through the last 6 or 7 bits:

00010000.00011011.00011000.00000000
00010000.00011011.00011000.01000000
00010000.00011011.00011000.10000000

But we still need to combine the blocks. Note that the top two lines have the exact same start, but then one ends in a 0 followed by anything, and the other in a 1 followed by anything. But since that exhaustively covers everything, we can just extend the 'anything' part one up to combine them:

00010000.00011011.00011000.00000000
00010000.00011011.00011000.10000000

Here we can do the exact same:

00010000.00011011.00011000.00000000

We can now convert our IP address back to decimal, giving 16.27.24.0. The netmask is 32 - 8 = 24 (because we strike out 8 binary digits). So the full IP address + netmask is 16.27.24.0/24.