If a router received two BGP updates for the same prefix and both these updates are aggregate paths how do the router decide which one to take? Let us say that it needs to decide based on AS Path length ( I know there are other criteria but let us say they are all equal and now it reached the AS PAth metric and need to decide based on it). So how does it ensure the shortest path? As the As path can be hiding some ASN's because of the aggregation.

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
    – Ron Maupin
    Dec 15, 2019 at 19:38

2 Answers 2


BGP has a fixed set of criteria for selecting a path. If the AS Path attribute does not select a single path, the path selection algorithm will next use the path origin type, preferring IGP over EGP.

Here is a full explanation of BGP path selection algorithm.

  • Just remember that, regardless of the path selection algorithm, the more specific prefix always wins. So if one aggregate is a more specific prefix than the other, they both might be installed in the route table, but the more specific route will be used to forward packets to destinations covered by both routes. Oct 22, 2019 at 17:00

By default, the aggregating router omits the ASN's from the aggregated networks. The idea is the aggregated route itself is initiated by the aggregating AS, so the ASN's of the original AS's are irrelevant.

(I'll pause here to say it probably works differently with different vendors -- the above as accurate for Cisco though)

When aggregating, however, you can use the keyword as-set which tells the aggregating router to also include the origin ASNs in the the AS-PATH attribute. The issue though, is what order should they be in?

Instead of creating a complicated way of determining the order of the ASNs in the aggregated route, all of the ASN's are included in a construct known as an AS-SET. This way, any routers down the path that receive the aggregate route know which ASNs were involved. And, eBGP's loop prevention mechanism (If I see my ASN in a received advertisement, I ignore the advertisement) still functions.

Seeing it visually helps... and it didn't click for me until I read Mike Pennington's answer to this question, which I would recommend reading as a follow up to your question. Either way, this is a part of his answer and his visual:

In the example below, AS65500 aggregates the eBGP announcements from AS65000 and AS65001 into After aggregating the announcements from AS65000 and AS65001, AS65500 sends NETWORK: AS-PATH: 65500 and NETWORK: AS-PATH: 65500 {65000, 65001} (the aggregate). Typically, an AS will aggregate when it has delegated portions of a larger address block to customers.

It doesn't make sense to build an ordered list when you aggregate space for multiple ASNs; for instance, an ordered AS-PATH for the aggregate below would be either 65500 [65000, 65001] or 65500 [65001, 65000]. However, both of those ordered lists are non-sense because ordering is irrelevant to the aggregate (i.e. both autonomous systems are directly connected to AS 65500). Ordering implies a sequence which is meaningless to the aggregate.

Unordered lists (i.e. mathematical sets) make the most sense for an AS_SET.

      ,-''               `--.
    ,'                       `.
   (         AS65000           )
    `.     ,'
      `--.               _.-'
                    \          ------> NETWORK:   AS-PATH: 65500
                     \         ------> NETWORK:   AS-PATH: 65500 {65000, 65001}
           _.--------------.        router bgp 65500
       ,-''                 `--.     no sync
     ,'                         `.   no auto-summary
    (          AS65500             ) neighbor remote-as 65000
     `.      ,'   neighbor remote-as 65001
       --.                 _.-'      network mask
           `--------------''         aggregate-add summary-only as-set
      ,-''                 `--.
   ,'                         `.
  (           AS65001           )
   `.     ,'
     `--.                 _.-'

When 65500 advertises the aggregate route to new AS's, it will include an AS-PATh of:

NETWORK: AS-PATH: 65500 {65000, 65001}

Indicating the network came from ASN65500, then from an AS-SET consisting of {65000,65001}. This will count as an AS-PATH length of 2 -- the AS-SET counts as 1 regardless of how many ASN's are included. And the AS-Path length can then be compared to other routes with longer or shorter AS-PATH length's to determine priority.

  • but if a router needs to decide on a route based on the shortest path how will it do this? Let us say it received 2 aggregate routes for the same prefix and needs to decide on them based on the shortest route. How will it do this if the AS set does not reflect the path but it reflects the ASs originating the aggregated route?
    – kaki no
    Oct 23, 2019 at 13:20
  • The entire AS-Set counts as one. So, this route: NETWORK: AS-PATH: 65500 {65000, 65001} has an AS-PATH length of 2. It can be compared to another route: NETWORK: AS-PATH: 65599 65598 65596 which has an AS-PATH length of 3. In this case, the first route is preferred.
    – Eddie
    Oct 23, 2019 at 19:24
  • What happens if a router receives two routes who are themselves an aggregate. For example, another AS called ASX received a route for with AS-PATH: 65500 {65000, 65001} from AS 65500 and another route for from AS200 with AS-PATH: 200 300. Suppose ASX wants to aggregate these routes into how will the aggregated AS path/As set look like?
    – kaki no
    Oct 29, 2019 at 13:18
  • I imagine you mean aggregate them into If so, when ASX advertises it to it's peers, it would have an AS Path of : XXXX, {65500, 65000, 65001, 200, 300} (where XXXX is ASX's AS Number). The AS-SET includes all the AS Numbers involved in the longer-prefix routes that were aggregated. Internally, the ASNs in the AS-SET are arbitrary. Externally, the entire AS-SET counts as one AS -- meaning the total AS-PATH Length of the route advertised from ASX would still be 2.
    – Eddie
    Oct 29, 2019 at 17:28
  • ohh, thank you. So, I cannot know the exact paths? What I mean is that I cannot know the different paths it is made up from. I can know the ASs numbers but not the order nor how they are grouped into different paths. Is their a way to keep the exact paths?
    – kaki no
    Oct 31, 2019 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.