Thursday, October 13, 2011

notes: Best Path Selection

BGP path attributes

1.  Well-Known: Must be recognized by every BGP implementation.
     a.   Mandatory: Must be present in all updates
           - Next-Hop (see below)
           - AS-Path (see below)
           - Origin (see below)
     b.  Discretionary: Could be present in an update, but not required.
          - Local Preference (see below
          - Atomic Aggregate - Is a signal to inform that original information may have been lost when the updates were summarized into a single entry.

2.  Optional: Is not expected to be recognized by all BGP implementations
      a.  Transitive: Will be propagated if not recognized but the partial bit will be set to indicate that the attribute was not recognized.
           - Aggregator - Identifies the AS and router within that AS which created the route aggregate.
           - Community - Is used for route tagging. (see below)
       b.  Non-Transitive: Will be discarded if not recognized.
            - MED (multi-exit discriminator) (see below)

- Only the best routes(>) are considered candidates to be advertised and candidate to be placed in the routing table.
- A outbound routing policy affects inbound traffic.
- A inbound routing policy affects outbound traffic.

- Prerequisites:
> A prefix must have IGP next-hop reachability for BGP to consider that route.
> Synchronization rule must be met or disabled.

- BGP BestPath Selection process based on BGP attributes in the following order:

1. Prefer the highest Cisco weight (local to router).
2. Prefer the highest local preference (local to AS).
3. Prefer the routes that a router originated locally.
4. Prefer the shortest AS paths (only length is compared).
5. Prefer the lowest origin code (IGP before EGP before Incomplete).
6. Prefer the lowest MED. (metric between AS)
7. Prefer external (eBGP) paths over internal (iBGP) paths
   - For eBGP paths, prefer the oldest (most stable) path.
   - For iBGP paths, prefer the path through the closest IGP neighbor (lowest IGP metric).
8. If route reflectors configured:
  - When multiple iBGP routes, non-reflected route are preferred above reflected routes.
  - Then reflected routes with a shorter cluster ID are preferred above routes with longer cluster-lists.
9. Prefer paths from router with the lower BGP router-ID.


WEIGHT
- Used for route-selection of OUTBOUND decisions when ONE router has MULTIPLE links to a provider/providers.
- Provides local routing policy, locally significant within a router, and is never routed in updates.
- BGP weights are specified per neighbor with "neighbor weight" command or with a route-map per routes/paths.
- Weight is applied to new incoming updates, to affect OUTBOUND routing decisions.
- To enforce newly set weight values, re-establish BGP sessions with the neighbors (refer to Clearing BGP Sesssion).
- If no weight value is specified, the default value of 0 is applied.
- Routes that the router originates locally have a default value of 32768.
- Routes can be matched on any combination of prefix-lists, AS-path filters, or other BGP attributes.
- Routes not matched by the route-map will be discarded.

command:

- Changes the weight in a route-map

set weight {value} 

- Sets the weight for all routes received from this neighbor
- Weight value (1-65535)

neighbor {ip} weight {weight} 


- Sets the weight only for the routes matched by the route-map for the neighbor

neighbor {ip} route-map {map-name} in


LOCAL PREFERENCE
- Used for route-selection of OUTBOUND decisions, when SINGLE/MULTIPLE routers have SINGLE/MULTIPLE links to a provider/providers.
- A BGP router can set local preference when processing incoming route updates, or when doing redistribution,
or when sending outgoing route updates.
- Default value is 100, the higher value is always preferred.

command:

- Changes the local preference in a route-map

set local-pref {value} 

- Changes the default local preference in all updates received from a neighbor

router bgp 1
 bgp default local-preference {pref}



- The route-map sets the local-preference to incoming updates from eBGP neighbors

neighbor {ip} route-map {map-name} in 

 - Used to change the local-preference advertised to a iBGP neighbor

neighbor {ip} route-map {map-name} out


AS-PATH
- Used for route-selection of INBOUND decisions, to decide which return path to use when MULTIPLE pathsd exist.
- AS-path prepending useful in two scenarios:
- Manipulating the outgoing AS-path length could result in proper return path selection for primary/backup links.
-  Distributing the return traffic load for multi-homed customers.
- To enforce newly set AS-path length, re-send BGP updates outbound to the neighbors (refer to Clearing BGP Sesssion)
- AS-path prepending should be performed on outgoing eBGP updates over the non-desired return path or the path where the traffic load should be reduced.
-  AS-path prepending cannot be monitored or debugged on the sending router. It can only be observed on the receiving router.

commands:

- Prepends an ASN in the route-map

set as-path prepend as-number [as-number] 

- Applies the prepended AS-path to all routes matching
router bgp 1
neighbor {ip} route-map {map-name} out 

- Ignores the AS-path length in its decision process
- Cisco IOS takes into consideration the length of the AS-path attribute
RFC 1771 does not include this step


bgp bestpath as-path ignore


MED
- Used for route-selection of INBOUND decision, when MULTIPLE return paths from the SAME AS to ONE/MORE routers exist.
- There is by default no MED attribute attached to a route, except if the router originated the route.
The Cisco default MED value of received updates is then assumed to be 0.
- The MED is not propagated outside of a receiving AS.
- A lower MED value is more preferred.
- By default, the MED is considered only during selection of routes from the same AS, which does not include intra-confederation autonomous systems.
- Default MED behaviour with redistribution works differently. With the "network" command or redistribution the metric in the routing table will be used as the MED.

commands:

- Changes the MED in a route-map
 
set metric {value} 

- Applies the new MED value set in the route-map

router bgp 1
neighbor {ip} route-map {map-name} in|out



- This changes the default MED value

default-metric {number}

>>> Advanced MED configs <<<


- Used to consider MED for routes coming from a different AS's

bgp always-compare-med 

- Causes a missing MED to be interpreted as infinity (worst)
- If a MED is not attached to a BGP route, it is assumed as value 0, and thus interpreted as the best metric which is not always wanted.

bgp bestpath med missing-med-worst

- Allows routers to compare MED's learned from confederation peers

bgp bestpath med confederation

- Ensures the comparison of MED's from different neighbors in the same AS
- By default ,routes from the same autonomous system are grouped, and only the best entries of each group are then compared
 
bgp deterministic-med

No comments:

Post a Comment