BGP Best Path Selection Flashcards

1
Q

BGP Best-Path

A

The BGP best-path selection algorithm influences how traffic enters or leaves an autonomous system (AS). Some router configurations modify the BGP attributes to influence inbound traffic, outbound traffic, or inbound and outbound traffic, depending on the network design requirements.

BGP installs the first received path as the best path automatically. When additional paths are received for the same network prefix length, the newer paths are compared against the current best path. If there is a tie, processing continues until a best path winner is identified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

BGP Best-Path Algorithm

A
  1. Prefer the highest weight
  2. Prefer the highest local preference
  3. Prefer the route originated by the local router
  4. Prefer the shortest AS_Path
  5. Prefer the best origin code
  6. Prefer the lowest multi-exit discriminator (MED)
  7. Prefer an external path over an internal path
  8. Prefer the path through the closest IGP neighbor
  9. Prefer the oldest route for eBGP paths
  10. Prefer the path with the lowest neighbor BGP RID
  11. Prefer the path with the lowest neighbor IP address
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Rule 1

A

All BGP prefixes must pass the route validity check, and the next-hop IP address must be resolvable for the route to be eligible as a best path.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Weight

A

BGP weight is a Cisco-defined attribute.

Weight is a 16-bit value (0 through 65,535) assigned locally on the router.

The path with the higher weight is preferred.

Weight can be set for specific routes with an inbound route map or for all routes learned from a specific neighbor.

Weight is not advertised to peers and only influences outbound traffic from a router or an AS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Weight Example

A

R4 is an edge router for AS 400 and sets the weight to 222 for the 172.16.0.0/24 prefix received from R2. This ensures that R4 uses R2 for outbound traffic to this prefix.

R6 is an edge router for AS 400 and sets the weight to 333 for the 172.24.0.0/24 prefix received from R3. This ensures that R6 uses R3 for outbound traffic to this prefix.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Local Preference

A

Local preference (LOCAL_PREF) is a well-known discretionary path attribute and is included with path advertisements throughout an AS.

Default local preference value is 100.

The local preference attribute is a 32-bit value (0 through 4,294,967,295) that indicates the preference for exiting the AS to the destination network prefix.

The local preference is not advertised between eBGP peers and is typically used to influence the outbound traffic (that is, leaving an autonomous system).

Local preference can be set for specific routes by using a route map or for all routes received from a specific neighbor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Local Pref Example

A
  • *R4** is an edge router for AS 400 and sets the local preference to 222 for the 172.16.0.0/24 prefix received from R2, making it the preferred path for AS 400.
  • *R6** is an edge router for AS 400 and sets the local preference to 333 for the 172.24.0.0/24 prefix received from R3, making it the preferred path for AS 400.

Phase 1: Initial BGP Edge Route Processing

  • *R4** receives the prefix for 172.16.0.0/24 from R2 and sets the local preference to 222.
  • *R6** receives the prefix for 172.24.0.0/24 from R3 and sets the local preference to 333.

Phase 2: BGP Edge Evaluation of Multiple Paths

  • *R4** detects that the 172.24.0.0/24 path from R3 (AS 300) has a higher local preference than the path from R2 (AS 200). R4 marks the path from R6 as the best path for the prefix and sends route withdrawals to R5 and R6 for the path from R2.
  • *R6** detects that the 172.16.0.0/24 path from R2 (AS 200) has a higher local preference than the path from R3 (AS 300). R6 marks the path from R4 as the best path for the prefix and sends a route withdrawals to R5 and R4 for the path from R3.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Locally Originated

A

Locally Originated in the Network or Aggregate Advertisement

The third decision point in the best-path algorithm is to determine whether the route originated locally.

Preference is given in the following order:

  1. Routes that were advertised locally
  2. Networks that have been aggregated locally
  3. Routes received by BGP peers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Shortest AS_PATH

A

A shorter AS_Path is preferred over a longer AS_Path.

Prepending ASNs to AS_Path makes the AS_Path longer, thereby making that path less desirable compared with other paths.

In general, paths that have had AS_Path prepended are not selected as the BGP best path because AS_Path is longer than the non-prepended path advertisement.

Inbound traffic is influenced by prepending AS_Path length in advertisements sent to other ASs, and outbound traffic is influenced by prepending advertisements received from other ASs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Shortest AS_PATH Example

A

R4 prepends AS 222 210 for the 172.24.0.0/24 path received from R2, making it the least preferred path for AS 400.

R6 prepends AS 333 321 for the 172.16.0.0/24 path received from R3, making it the least preferred path for AS 400.

Remember that BGP routers do not remove inferior routes. The routes must be withdrawn from a neighbor in order to be removed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Origin Type

A

The next BGP best-path decision factor is the well-known mandatory BGP attribute named origin.

By default, networks that are advertised on Cisco routers using the network statement are set with the i (for IGP) origin, and redistributed networks are assigned the ? (incomplete) origin attribute.

IGP over EGP over Incomplete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Origin Type Example

A

R4 sets the origin to incomplete for the 172.24.0.0/24 path received from R2, making it the least preferred path for R4, R5, and R6.

R6 sets the origin to incomplete for the 172.16.0.0/24 path received from R3, making it the least preferred path for R4, R5, and R6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

MED

A

BGP sets the MED automatically to the IGP path metric during network advertisement or redistribution.

If the MED is received from an eBGP session, it can be advertised to other iBGP peers, but it should not be sent outside the AS that received it.

The MED’s purpose is to influence traffic flows inbound from a different AS.

A lower MED is preferred over a higher MED.

In order for the MED to be an effective decision factor, the paths being decided upon must come from the same ASN.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

MED Example

A

AS 100 advertises the 172.16.0.0/24 and 172.20.0.0/24 network prefixes with different MED values at each edge router (R1 and R2).

AS 200 sends traffic out R3 to the 172.16.0.0/24 network prefix because R1’s MED (40) is lower than R2’s MED (60).

AS 200 sends traffic out R4 to the 172.20.0.0/24 network prefix because R2’s MED (30) is lower than R1’s MED (70).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

MED Example 2

A

R4 sets the MED to 40 for 172.16.0.0/24, 50 for 172.20.0.0/24, and 90 for 172.24.0.0/24.

R6 sets the MED to 80 for 172.16.0.0/24 and 10 for 172.24.0.0/24.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Missing MED Behavior

A

An organization may expect its different SPs to advertise a MED value for every prefix. If a MED is missing, the path without a MED is preferred over a path that contains a MED. An organization can modify the default behavior so that prefixes without a MED are always selected last.

R6’s route map is configured to NOT set the MED on the 172.20.0.0/24 prefix when received by R3. When the MED is not advertised, the value is assumed to be zero (0). All three routers in AS 400 evaluate the MED of 0 (from R3) versus 50 (from R2). The routers select the path through R3 as the preferred path.

The command bgp bestpath med missing-as-worst under the BGP router process sets the MED to infinity (4,294,967,295) if the MED is missing from a path. The command should be placed on all nodes in an AS to keep the best-path the same for all routers.

The BGP configuration command default-metric metric sets the metric to the value specified when a path is received without a MED. This allows routers to calculate the BGP best path for prefixes without requiring that the MED attribute be set manually or be set to infinity.

17
Q

Always Compared MED

A

The default MED comparison mechanism requires the AS_Path values to be identical because the policies used to set the MED could vary from AS to AS. This means that the MED can influence traffic only when multiple links are from the same service provider. Typically, organizations use different service providers for redundancy. In these situations, the default BGP rules for MED comparison need to be relaxed to compare MEDs between different service providers.

The always-compare-med feature allows for the comparison of MED regardless of the AS_Path.

Enable this feature on all BGP routers in the AS, or routing loops can occur.

18
Q

BGP Deterministic MED

A

The best-path algorithm compares a route update to the existing best path and processes the paths in the order in which they are stored in the Loc-RIB table. The paths are stored in the order in which they are received in the BGP table.

If always-compare-med is not enabled, the path MED is only compared against the existing best path and not against all the paths in the Loc-RIB table, which can cause variations in the MED best-path comparison process.

19
Q

BGP Deterministic MED part 2

A

R4 advertises the 172.16.0.0/24 prefix with a MED of 200, and R5 selects R4’s path as the best path because no other paths exist.

R3 advertises the 172.16.0.0/24 prefix with a MED of 100. The AS_Path is from a different autonomous system compared to R4’s, so the MED is not considered in the BGP best-path calculation. R4’s path remains the best path because it is the oldest eBGP-learned route.

R2 advertises the 172.16.0.0/24 prefix with a MED of 150. The AS_Path differs from R4’s, so MED is not considered in the BGP best-path calculation. R4’s path remains the best path because it is the oldest eBGP-learned route.

20
Q

BGP Deterministic part 3

A

BGP deterministic MED corrects the problem by grouping together paths with identical AS_Path values as part of the best-path identification process. Each group’s MED is compared against the other group’s MED.

With BGP deterministic MED enabled, the best-path selection outcome is different.

R2’s and R3’s paths are grouped together because they have an identical AS_Path value (200 100). R4 is placed into a separate group, by itself, because of its AS_Path (300 100).

R3 is the best path for AS_Path group 200 100, and R4 is the best path for AS_Path group 300 100. The two AS_Path groups are then compared against each other, and because R3’s MED is lower than R4’s, R3’s path is chosen as the best path, regardless of the order in which the routes are advertised.

21
Q

eBGP over iBGP

A
  1. eBGP peers (most desirable)
  2. Confederation member AS peers
  3. iBGP peers (least desirable)
22
Q

Prefer the Oldest BGP Path

A

BGP can maintain large routing tables, and unstable sessions result in the BGP best-path calculation executing frequently. BGP maintains stability in a network by preferring the path from the oldest (established) BGP session. The downfall of this technique is that it does not lead to a deterministic method of identifying the BGP best path from a design perspective.

23
Q

Router ID

A

The next step for the BGP best-path algorithm is to select the best path using the lowest router ID of the advertising EBGP router.

If the route was received by a route reflector, then the originator ID is substituted for the router ID.