Saturday, February 4, 2012

BGP Route Summarization

CIDR is a mechanism developed to overcome the problem of exhaustion of IP addresses and the growth of Internet routing table. CIDR allows blocks of multiple addresses to be combined, or aggregated, to create a set of classless IP addresses that summarize the routes in routing tables and resulting in fewer route advertisements.

Earlier versions of BGP did not support CIDR until BGP-4. BGP-4 Update messages include both the prefix and prefix length; while previous version included only the prefix, and the length was assumed based on the address class.

A BGP router can advertises overlapping routes to another BGP router. Overlapping routes are non-identical routes that point to the same destination, eg: 10.10.128.0/17 and 10.10.192.0/18, in which the 2nd route is actually included in the 1st route.

Aggregation is the BGP term for summarization. Addresses can be aggregated when advertised by a BGP router. The BGP routers can be configured to include the combined unordered list of all ASes (AS_SET-type AS_PATH attribute) contained in all paths that are being summarized. 2 BGP path attributes that are related to aggregate addressing are:
  • ATOMIC_AGGREGATE – A well-known discretionary attribute that is set to inform the downstream ASes that the originating router has aggregates the routes and indicate that detailed path information might be lost due to route aggregation or summarization. Any downstream BGP router that receives a route with this attribute set must remain the attribute when advertising the route to other BGP peers.
  • AGGREGATOR – An optional transitive attribute that specifies the BGP Router ID and AS number of the router that perform the route aggregation.

Aggregate addresses are not used in the Internet as much as they could be because ASes that are multihomed (connected to multiple ISPs) want to make sure that their routes are advertised without being aggregated into a summarized route.

RIPv1, RIPv2, IGRP, and EIGRP perform autosummarization by default. Autosummarization can be disabled for RIPv2 and EIGRP. Autosummarization must be disabled when an organization is assigned a portion of a Class A, B, or C networks, or else it will claim the ownership of the whole Class A, B, or C networks, which eventually causes routing problems.

The auto-summary BGP router subcommand determines how BGP handles redistributed routes. The no auto-summary BGP router subcommand disables BGP autosummarization. When it is enabled, all redistributed subnets are summarized to their classful boundaries and stored in the BGP table. When it is disabled, all redistributed subnets are present in their original form with the original prefix and prefix length in the BGP table.
Ex: An ISP assigns the 11.22.33.0/24 network to an AS. If the AS uses the redistribute connected command to introduce this network into BGP and BGP autosummarization is enabled, BGP will announce that the AS owns the whole 11.0.0.0/8 address block, which can cause connectivity problems upon other ASes that own a portion of the 11.0.0.0/8 address space. The network 11.22.33.0 mask 255.255.255.0 statement should be configured instead of the redistribute connected command to ensure that the assigned network is advertised correctly.
Note: The default behavior of the auto-summary BGP router subcommand was changed to disabled in Cisco IOS Release 12.2(8)T and later.

The network BGP router subcommand with the mask option installs a prefix into the BGP table and advertises it to other peers when a matching IGP prefix exists in the IP routing table. If the IGP prefix flaps, the BGP prefix also flaps.

Use the network {net-num} command without the mask option to advertise a classful network. Use the network {net-num} [mask net-mask] command to advertise an aggregate of prefixes that originate in the local AS. Remember that the prefix must exactly match and entry in the IP routing table (both address and prefix) for the network to be advertised. This exact match can be accomplished by using a static route with the Null0 interface, or it might already exist in the IP routing table when the IGP already performing the summarization.

When the network command is configured for a classful address and there is at least one subnet of the classful address space exists in the IP routing table; BGP advertises the classful network and not the subnet. If the only single subnet for the classful network becomes unavailable, BGP will withdraw the classful network from all neighbors.
Note: The BGP auto-summarization must be enabled for this scenario to work.

The network command tells BGP what to advertise but not how to advertise it. We will understand this statement when learning about the aggregate-address command later.

BGP Route Summarization using the network Command

Below shows that RT1 learned the summarized BGP route – 192.168.16.0/22 from RT2:
RT1#sh ip route

Gateway of last resort is not set

     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial0/0
B    192.168.16.0/22 [20/0] via 12.12.12.2, 00:00:17
RT1#
RT1#sh ip bgp
BGP table version is 2, local router ID is 12.12.12.1
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
*> 192.168.16.0/22  12.12.12.2               0             0 65002 i
RT1#

The network command was not designed to perform summarization; while the aggregate-address command was designed for summarization.
The aggregate-address command aggregates only networks that are already in the BGP table; while the network command advertises summary routes that must exist in the IP routing table.

A BGP router always chooses the more-specific path when making a best-path decision; however, the BGP router has several options as below when advertising overlapping routes:
  • Advertise both the more-specific and the less-specific route
  • Advertise only the more-specific route
  • Advertise only the less-specific route
  • Advertise only the non-overlapping part of the route
  • Aggregate the more-specific and less-specific routes and advertise the aggregate route
  • Advertise neither route
The aggregate-address {ip-addr net-mask} [summary-only] [as-set] BGP router subcommand creates an aggregate (or summary) entry in the BGP table. The ip-addr net-mask identifies the aggregate address and the mask or the aggregate address to be created. The aggregate-address command automatically generates a BGP route for the summarized route with to Null0 interface and installed in the IP routing table.

The optional summary-only keyword causes the router to advertise only the aggregate route; the default is advertises both the aggregate prefix and the component more-specific prefixes. Without the summary-only keyword, the aggregation router will still advertises the more-specific prefixes, which can be useful for redundant ISP links.
Ex: ISP1 is advertising the summary and the more-specific routes, and ISP2 is advertising only the summary route. The more-specific routes through ISP1 are followed during normal operation. When ISP1 that advertising the more-specific routes becomes inaccessible, ISP2 that advertising only the summary route is followed.

The optional as-set keyword generates the AS_PATH attribute of the aggregate route to include all the ASNs listed in all the paths of the more-specific routes. The default is that the AS_PATH attribute of the aggregate route lists only the ASN of the aggregation router, in which the aggregate route is advertised as originated from the AS of the aggregation router; and the ATOMIC_AGGREGATE attribute is set to indicate that detailed path information might be lost due to route aggregation or summarization. The ATOMIC_AGGREGATE attribute does not have to be included in the aggregate route when the as-set keyword is specified.

If there is a route within the range indicates by the aggregate-address command exists in the BGP table, the aggregate route will be inserted into the BGP table and advertised to other peers. This process creates more information in the BGP table. The more-specific routes covered by the aggregate route should be suppressed from being advertised to other peers using the summary-only keyword. When the more-specific routes are suppressed, they are still present in the BGP table of the aggregation router.

Both the summary-only and as-set keywords may be specified in an aggregate-address command, which sends only the summary address and lists all the ASes in the path information.

The aggregate-address command does not replace the network command; at least a more-specific route that is to be summarized must reside in the BGP table. The more-specific routes may be injected into BGP by other routers, and the route aggregation is performed by another router or even in another AS – proxy aggregation – the aggregation router needs to configure only the aggregate-address command; instead of the network command.

BGP Route Summarization using the aggregate-address Command

Below shows the BGP tables on RT2 and RT1 when only the summary-only keyword is configured on RT2. Note that the more-specific routes are suppressed (the status code of s) and only the aggregate route is advertised to RT1.
RT2#sh ip bgp
BGP table version is 11, local router ID is 25.25.25.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
*> 192.168.16.0/22  0.0.0.0                            32768 i
*> 192.168.16.0/23  0.0.0.0                            32768 i
s> 192.168.16.0     23.23.23.3               0             0 65003 i
s> 192.168.17.0     23.23.23.3               0             0 65003 i
s> 192.168.18.0     24.24.24.4               0             0 65004 i
s> 192.168.19.0     25.25.25.5               0             0 65005 i
RT2#
======================================================================
RT1#sh ip bgp
BGP table version is 11, local router ID is 12.12.12.1
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
*> 192.168.16.0/23  12.12.12.2               0             0 65002 i
*> 192.168.16.0/22  12.12.12.2               0             0 65002 i
RT1#

Below shows the BGP tables on RT2 and RT1 when both the as-set and summary-only keywords are configured on RT2. Note that RT2 advertises the aggregate route 192.168.16.0/22 with the AS_SET-type AS_PATH attribute to include the combined unordered list of all ASes contained in all paths that are being summarized; also note that the ATOMIC_AGGREGATE attribute is also set even the as-set keyword has been specified. AS_SEQUENCE for AS 65002 is still included to allow receiving routers (RT1) to trace the path back to the aggregator (RT2).
RT2#sh ip bgp
BGP table version is 13, local router ID is 25.25.25.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
*> 192.168.16.0/22  0.0.0.0                100  32768 {65003,65004,65005} i
*> 192.168.16.0/23  0.0.0.0                100  32768 65003 i
s> 192.168.16.0     23.23.23.3        0             0 65003 i
s> 192.168.17.0     23.23.23.3        0             0 65003 i
s> 192.168.18.0     24.24.24.4        0             0 65004 i
s> 192.168.19.0     25.25.25.5        0             0 65005 i
RT2#
======================================================================
RT1#sh ip bgp
BGP table version is 13, local router ID is 12.12.12.1
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
*> 192.168.16.0/23  12.12.12.2        0             0 65002 65003 i
*> 192.168.16.0/22  12.12.12.2        0             0 65002 {65003,65004,65005} i
RT1#sh ip bgp 192.168.16.0 255.255.252.0
BGP routing table entry for 192.168.16.0/22, version 13
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  65002 {65003,65004,65005}, (aggregated by 65002 25.25.25.2)
    12.12.12.2 from 12.12.12.2 (25.25.25.2)
      Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate, best
RT1#sh ip bgp 192.168.16.0 255.255.254.0
BGP routing table entry for 192.168.16.0/23, version 12
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  65002 65003, (aggregated by 65002 25.25.25.2)
    12.12.12.2 from 12.12.12.2 (25.25.25.2)
      Origin IGP, metric 0, localpref 100, valid, external, best
RT1#

Below lists the 2 common types of AS_PATH:
  • AS_SEQUENCE that specifies the ordered list of ASNs towards a destination.
  • AS_SET that specifies an unordered list of ASNs towards a destination.
The main purpose of AS_PATH is used for loop prevention, in which a BGP router will discard EBGP-learned paths that list the local ASN in the AS_PATH attribute; or else a loop may occur. When some AS_PATH detail is lost upon aggregation, this increases the potential for a loop. Note that actually the AS_PATH does not need to list the ASNs in any particular order; a receiving router only need to recognize whether its own ASN is included in the AS_PATH, which is where AS_SET comes into the picture.

3 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This was great explanation.

    ReplyDelete
  3. Hi, so if you have more specific OSPF routes which have not been redistributed in to BGP yet, will the BGP aggregate address still be advertised?

    Mario

    ReplyDelete