Wednesday 26 December 2018

BGP Series 6: BGP AS-Path Attribute

BGP AS-Path Attribute:

  • This attribute is used to decide the best-path for a certain prefix.

  • By default, if a bgp router gets two or more updates for the same prefix, then, it will decide at the best path by simply looking at the AS-path attribute...ie. which of these routes went through the fewest number of AS and whichever route had the lowest number (quantity, not value) of AS-path, that is the best route

  • AS_SEQ (As-sequence) is a component of AS-path attribute

    • To know what it is, let us see the below example
    • img
    • R3 in AS-3 sends advertisement for 1.1.0.0/24 to R4 with as-path as 3 since it originated in AS3
    • Also, R4 in AS4 has another route 1.1.1.0/24. Now, it sends update for 1.1.0.0/24 (after appending its own as as well) and for 1.1.1.0/24 to R5
    • Similarly, let us consider R1 sends it route to R2 which R2 sends to R5. Also, R2 adds its own route and sends to R5.
    • Thus, R5 gets a total of 5 routes
    • This orderly arrangement of AS-paths is called AS-sequence since we can trace back to the origin of the route using the AS-SEQ
  • There is also another component of AS-path called AS-SET:

    • Now, let us consider R5 does a route summarization (summarization is a separate configuration and including AS-SET is also another configuration) and sends 1.1.0.0/22 to R6 by adding its own AS as AS-path. Now, we won’t get the sequence of the AS from the update of R5. But, R5 will send the summarized routes with an ‘{}’
    • It will actually show up in the ‘1.1.0.0/22 5 {4 1 3 2}’ way if we do a ‘show ip bgp’ on R6. that is called an AS-SET
  • What’s the difference between AS-SEQ and AS-SET:

    • There is order to AS-SEQ. But, in AS-SET, there is no order and detail like where this route originated, where it passed through, etc...All that AS-SET tells is I’m not going to tell you about origin or path of those routes. All I will tell you is that those routes either lives in (originated in) or passed through these AS
    • So, when this reaches R7, it will see something like this→ 1.1.0.0/22 6 5 {4 1 3 2} which means I received it from AS 6 and AS 6 router got it from an AS-5 router with that AS-SET
  • But, what is the value of giving the AS-SET, why do we need it in first place:

    • The reason why its there is because the AS-path attribute is not just used for best path selection, it is also used for something else.
    • It is to PREVENT ROUTING LOOPS as well
    • When a router receives a BGP Update and it sees its own AS number in the AS-path, then, it means there is a routing loop since that route had been sent via my AS. It will discard that route
    • Thus, it is used for loop prevention
  • In above example, if there was a bgp neighborship b/w R7 and R5, then, R5 will see its own AS in the R7’s Update message and discard that update due to its own AS in the AS-SEQ

  • Similarly, in above example, if there was a bgp neighborship b/w R7 and R1, then, R1 will drop it because he sees his own AS in the AS-SET. Note that even though R1 didn’t have the summarized route, he will drop it because that’s how BGP works...If we see our own AS in the message, discard it regardless of anything.

  • img

  • But, if R5 during summarization was not configured to add the AS-SET, then, R1 would have accepted the summarized route

No comments:

Post a Comment