BGP - aggregate-address command in action
The aggregate-address command that is available under the BGP router configuration of a Cisco router is a command that allows you to summarize already existing routes into a single entry. For example, refer to the following topology:
In the above topology, the 172.16.2.2/32 and 172.16.3.3/32 are advertised by R2 and R3 to R1, which in turn advertises both routes to R4. Initially, R4's BGP table looks like this:
Network Next Hop Metric LocPrf Weight Path *> 172.16.2.2/32 192.168.14.1 0 1 2 i *> 172.16.3.3/32 192.168.14.1 0 1 3 i
In the following sections, we'll see how the aggregate-address
command behaves when applied alone, when applied with the summary-only
keyword, and when applied with the as-set
keyword.
Used alone
We issue the following command on the BGP router configuration section of R1:
R1(config-router)#aggregate-address 172.16.0.0 255.255.0.0
The resulting BGP table in R4 is:
Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.14.1 0 0 1 i *> 172.16.2.2/32 192.168.14.1 0 1 2 i *> 172.16.3.3/32 192.168.14.1 0 1 3 i
Notice that the aggregate address we configured is added, but the original routes are still included in the BGP table. Also notice that the AS path of the aggregate route is removed.
Used with the summary-only
keyword
This time, we issue the following command on the BGP router configuration section of R1:
R1(config-router)#aggregate-address 172.16.0.0 255.255.0.0 summary-only
The resulting BGP table in R4 is:
Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.14.1 0 0 1 i
Notice that the individual routes to each destination are removed. The summary-only keyword causes R1 to advertise only the summary route and not the individual ones found within it. Also, the AS path of the aggregate route is still removed.
Used with the as-set
keyword
Next we issue the following command on the BGP router configuration section of R1:
R1(config-router)#aggregate-address 172.16.0.0 255.255.0.0 as-set
The resulting BGP table in R4 is:
Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.14.1 0 0 1 {2,3} i *> 172.16.2.2/32 192.168.14.1 0 1 2 i *> 172.16.3.3/32 192.168.14.1 0 1 3 i
Notice here that the as-set keyword causes the AS Path to remain within the aggregate route, and the two alternative ASNs for each component route are included in curly brackets or braces "{ }".
Used with both the summary-only
and the as-set
keywords
Finally, we issue the following command on the BGP router configuration section of R1:
R1(config-router)#aggregate-address 172.16.0.0 255.255.0.0 as-set summary-only
The resulting BGP table in R4 is:
Network Next Hop Metric LocPrf Weight Path *> 172.16.0.0 192.168.14.1 0 0 1 {2,3} i
As expected, the individual component routes are eliminated and only the aggregate route with the alternative ASNs in the AS path remains.
Note that if the aggregate address includes only a single component subnet, its behavior can be a little bit unpredictable.
Links
https://forum.networklessons.com/t/bgp-aggregate-as-set/3248/31?u=lagapidis
https://networklessons.com/cisco/ccie-routing-switching-written/bgp-aggregate-as-set