Thursday, March 14, 2013

BGP - Aggregation - aggregate-address

BGP Routing table of the Internet is enormous and its over 400K routes which puts a considerable amount of stress on the edge devices anytime there is a flap or a change in routing topology. Although there are mechanism in place to minimize the impact it is still in our best interest to keep the BGP routing table as small as possible. "aggregate-address" command is one of the ways in which we can combat the issues created by large BGP tables.

In this blogtorial we will look at the "aggregate-address" command and its options (in subsequent posts) to see how we can aggregate routes in BGP. Consider this simple 3 router topology. 

Complete configs can be downloaded here.

Objective:
  • On R2 consolidate the 11.11.11.0/25 and 11.11.11.128/25 from R1 and advertise the aggregate 11.11.11.0/24 to R3.  
First let's get all of the interfaces and BGP configured. 

 !  
 hostname R1  
 !  
 interface FastEthernet1/0  
  description connected to r2  
  ip address 1.1.1.1 255.255.255.0  
  duplex auto  
  speed auto  
 !  
 router bgp 1  
  no synchronization  
  bgp log-neighbor-changes  
  network 11.11.11.0 mask 255.255.255.128  
  network 11.11.11.128 mask 255.255.255.128  
  neighbor 1.1.1.2 remote-as 2  
  no auto-summary  
 !  
 ip route 11.11.11.0 255.255.255.128 Null0  
 ip route 11.11.11.128 255.255.255.128 Null0  

 !  
 hostname R2  
 !  
 interface FastEthernet1/0  
  description connected to r1  
  ip address 1.1.1.2 255.255.255.0  
  duplex auto  
  speed auto  
 !  
 interface FastEthernet1/1  
  description connected to r3  
  ip address 2.2.2.2 255.255.255.0  
  duplex auto  
  speed auto  
 !  
 router bgp 2  
  no synchronization  
  bgp log-neighbor-changes  
  neighbor 1.1.1.1 remote-as 1  
  neighbor 2.2.2.3 remote-as 3  
  no auto-summary  
 !  

 !  
 hostname R3  
 !  
 interface FastEthernet1/1  
  description connected to r2  
  ip address 2.2.2.3 255.255.255.0  
  duplex auto  
  speed auto  
 !  
 router bgp 3  
  no synchronization  
  bgp log-neighbor-changes  
  neighbor 2.2.2.2 remote-as 2  
  no auto-summary  

Now that the basic configurations are done, let's do some show commands to verify everything.

 R2#show ip bgp  
 BGP table version is 3, local router ID is 2.2.2.2  
 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
        r RIB-failure, S Stale  
 Origin codes: i - IGP, e - EGP, ? - incomplete  
   Network     Next Hop      Metric LocPrf Weight Path  
 *> 11.11.11.0/25  1.1.1.1         0       0 1 i  
 *> 11.11.11.128/25 1.1.1.1         0       0 1 i  

 R3#show ip bgp  
 BGP table version is 3, local router ID is 2.2.2.3  
 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
        r RIB-failure, S Stale  
 Origin codes: i - IGP, e - EGP, ? - incomplete  
   Network     Next Hop      Metric LocPrf Weight Path  
 *> 11.11.11.0/25  2.2.2.2                0 2 1 i  
 *> 11.11.11.128/25 2.2.2.2                0 2 1 i  

We see two routes in R2 and R3 and it is originated from R1 as expected. Now let's get the aggregation configured on R2 so R3 receives the 11.11.11.0/24.

 R2(config)#router bgp 2  
 R2(config-router)#aggregate-address 11.11.11.0 255.255.255.0
  
 R2#show ip bgp  
 BGP table version is 4, local router ID is 2.2.2.2  
 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
        r RIB-failure, S Stale  
 Origin codes: i - IGP, e - EGP, ? - incomplete  
   Network     Next Hop      Metric LocPrf Weight Path  
 *> 11.11.11.0/25  1.1.1.1         0       0 1 i  
 *> 11.11.11.0/24  0.0.0.0              32768 i  
 *> 11.11.11.128/25 1.1.1.1         0       0 1 i  

 R3#show ip bgp  
 BGP table version is 4, local router ID is 2.2.2.3  
   Network     Next Hop      Metric LocPrf Weight Path  
 *> 11.11.11.0/25  2.2.2.2                0 2 1 i  
 *> 11.11.11.0/24  2.2.2.2         0       0 2 i  
 *> 11.11.11.128/25 2.2.2.2                0 2 1 i  
 R3#sh ip route  
    2.0.0.0/24 is subnetted, 1 subnets  
 C    2.2.2.0 is directly connected, FastEthernet1/1  
    11.0.0.0/8 is variably subnetted, 3 subnets, 2 masks  
 B    11.11.11.0/25 [20/0] via 2.2.2.2, 02:01:29  
 B    11.11.11.0/24 [20/0] via 2.2.2.2, 00:02:16  
 B    11.11.11.128/25 [20/0] via 2.2.2.2, 02:01:29  

Notice that after the "aggregate-address 11.11.11.0/24" command is applied under the BGP config on R2, there is an aggregate route (11.11.11.0/24) which is being advertised along with the more specific routes. One thing to quickly notice is here is the AS PATH attribute for the aggregate-route shows { 2 } instead of {2 1}. This is something known as an "atomic aggregate".

 R2#show ip bgp 11.11.11.0 255.255.255.0  
 BGP routing table entry for 11.11.11.0/24, version 4  
 Paths: (1 available, best #1, table Default-IP-Routing-Table)  
 Flag: 0x820  
  Advertised to update-groups:  
     2  
  Local, (aggregated by 2 2.2.2.2)  
   0.0.0.0 from 0.0.0.0 (2.2.2.2)  
    Origin IGP, localpref 100, weight 32768, valid, aggregated, local, atomic-aggregate, best  

Atomic-aggregate basically means that the route did not inherit the attributes from the more specific routes. As you can see the "atomic-aggregate" route replaces the AS_PATH with the originating router's ASN (in this case ASN 2). Aggregate routes also do not inherit other attributes of the more specific routes such as no-export, no-advertise communities etc. So what if you had to retain the as-path or other attributes? Answer lies in my blogtorial "aggregate-address as-set" -- an optional parameter which can be used in conjunction with the "aggregate-address" command to retain attributes.

Now that we have an understanding of the aggregate command let's look at the various options which it has to offer.

 R2(config-router)#aggregate-address 11.11.11.0 255.255.255.0 ?  
  advertise-map Set condition to advertise attribute  
  as-set     Generate AS set path information  
  attribute-map Set attributes of aggregate  
  nlri      Nlri aggregate applies to  
  route-map   Set parameters of aggregate  
  summary-only  Filter more specific routes from updates  
  suppress-map  Conditionally filter more specific routes from updates  
  <cr>  

Out of these options -- few are worth exploring.
Many more articles to come so stay tuned.

Please reshare/subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.