Route summarization: How to get the route summary patently. (VLSM, CIDR)
I've come up with a very simple method of calculating route summary addresses without converting to binary. Essentially you just compare the numbers to the bit values and determine if they match on each bit.
Example 1.
192.168.1.160/30
192.168.1.164/29
192.168.1.172/29
192.168.1.180/30
you start by taking the highest and lowest number from the range to be summarized.
160, 180.
then compare them to the bit values starting from the left.
128 64 32 16 8 4 2 1
Because both numbers are bigger than 128, they both match on that bit and have a value of one on that bit.
128 64 32 16 8 4 2 1
1
then add the value of the next bit (128+64=192) and determine if both numbers are higher or lower than that value. because 160 and 180 are both lower than 192 they both match on that bit and both have a value of 0 for that bit.
128 64 32 16 8 4 2 1
1 0
now because both numbers were less than 192, you add 128 to the next bit value of 32 and disregard the bit value of 64. (128+32=160) because both 160 and 180 are higher than 160 they both match on that bit and both have a value of 1 for that bit.
128 64 32 16 8 4 2 1
1 0 1
now add the accumulated value of the summary address to the next bit value of 16 (128+32=160+16=176) because 160 is lower than and 180 is higher than 176, they have a different value on this bit therefor this bit is not included in the summary address.
128 64 32 16 8 4 2 1
1 0 1 x x x x x
so you can see that the route summary address for this example is 192.168.1.160/27
I'll give another example here but once you get the hang of it you can work out summary addresses very quickly in your head.
Example 2
172.16.146.0/24
172.16.147.0/23
172.16.149.0/23
172.16.151.0/24
bit values: 128 64 32 16 8 4 2 1
looking at the highest and lowest number in the example, 146 + 151, are they both higher or lower than the first bit value of 128. they are both higher so this bit matches with a value of 1.
128 64 32 16 8 4 2 1
1
adding the next bit value (128+64=192) are they both higher or lower than 192? they're both lower so this bit has a matching value of 0 for both.
128 64 32 16 8 4 2 1
1 0
adding the next bit value of 32 to the accumulated summary value of 128 (128+32=160) you can see both 146 and 151 are lower than 160 so this bit has a matching value of 0 for both bits.
128 64 32 16 8 4 2 1
1 0 0
adding the next bit value of 16 to the accumulated summary value of 128 (128+16=144) you can see that both 146 + 151 are higher than 144 so this bit has a matching value of 1.
128 64 32 16 8 4 2 1
1 0 0 1
adding the next bit value of 8 to the accumulated summary value of 144 (128+16=144+8=152) you can see that both numbers are lower than 152 so both numbers still match on this bit with a value of 0.
128 64 32 16 8 4 2 1
1 0 0 1 0
adding the next bit value of 4 to the accumulated summary value of 144 (128+16=144+4=148) you can see that 146 is lower and 151 is higher than 148 so this bit does not match and is not part of the route summary address.
128 64 32 16 8 4 2 1
1 0 0 1 0 x x x
so the answer for this example is 172.16.144.0/21
In your earlier example (example 3)
192.168.6.000/27
192.168.6.064/27
192.168.6.128/26
192.168.6.160/26
192.168.6.192/28
192.168.6.208/28
192.168.6.224/30
192.168.6.228/30
192.168.6.232/30
just look at the highest and lowest number 0 + 232, one is higher than 128 and one is lower therefor you don't need to look any further or calculate anything else the first bit with a value of 128 does not match and is not part of the summary address.
Some ranges are easier than others but I find this a much quicker method so hopefully you will find it helpful too.
Aoibheann
Related videos on Youtube
user179048
Updated on September 18, 2022Comments
-
user179048 over 1 year
i'm looking for a smart and short way to calculate summary routes. (CIDR, route summarization)
I'm common with the subject matter of summarization, supernets, VLSM, CIDR etc. but I don't always want to convert all the IP addresses into binary format to get the result.
Im looking for a smart way to save valuable time.
Main question at example 3Example1:
Lets say we have these two IP addresses:- 172.16.64.0/23
- 172.16.66.0/23
I can immediately see that the summary route will be 172.16.64.0/22.
I see that i'm using 2 subnets -> it's 1 bit -> I subtract 1 bit from the /23 = /22In Binary format:
172.16.64.0 - - -> 10101100.00010000.01000000.00000000
172.16.66.0 - - -> 10101100.00010000.01000010.0000000022 left-most matching bits = /22
When AND-ing these IP addresses the result is
172.16.64.0 - - -> 10101100.00010000.01000000.00000000Voila it's working without converting :)
Example2:
- 192.168.4.192/29
- 192.168.4.200/29
- 192.168.4.208/29
- 192.168.4.216/29
A brief look on these IPs, i see 4 subnets, which are 2 bits.(subtract 2 from /29)
So my guess is 192.168.4.192/27192.168.4.192 - - -> 10000000.10101000.00000100.11000000
192.168.4.200 - - -> 10000000.10101000.00000100.11001000
192.168.4.208 - - -> 10000000.10101000.00000100.11010000
192.168.4.216 - - -> 10000000.10101000.00000100.1101100027 left-most matching bits = /27
When AND-ing these IP addresses the result is :
192.168.4.192 - - -> 10000000.10101000.00000100.11000000Voila, we've got 192.168.4.192/27. So seems it's working.
Example3:
(BUT) What if we have odd numbers and differents subnetmasks (like in the example below)
How can I immediately get the route summary? (without converting to binary?)- 192.168.6.000/27 (10000000.10101000.00000110.00000000)
- 192.168.6.064/27 (10000000.10101000.00000110.01000000)
- 192.168.6.128/26 (10000000.10101000.00000110.10000000)
- 192.168.6.160/26 (10000000.10101000.00000110.10100000)
- 192.168.6.192/28 (10000000.10101000.00000110.11000000)
- 192.168.6.208/28 (10000000.10101000.00000110.11010000)
- 192.168.6.224/30 (10000000.10101000.00000110.11100000)
- 192.168.6.228/30 (10000000.10101000.00000110.11100100)
- 192.168.6.232/30 (10000000.10101000.00000110.11101000)
once it is converted it is easy to see, that it's 24 left-most matching bits = /24
But is there a way to skip the converting an find out the summary route immediately, just from the IPs+masks?Example4: This example is a little bit mean, because it dissents my idea of example 1:
- 192.168.1.0/24 - 11000000.10101000.00000001.00000000
- 192.168.2.0/24 - 11000000.10101000.00000010.00000000
The result is 192.168.0.0/22
However, I could not explain why especially this is not working anymore.I hope this forum has some smart people who can help me find a working solution. :)
Thanks in advance