Cisco BGP-4 Command and Configuration Handbook

 < Free Open Study > 

Syntax Description:

This command has no arguments.

Purpose: If multiple BGP routes to the same destination exist, BGP selects the best path based on the route attributes in the following order:

  1. Ignore a route if the next hop is not known.

  2. Ignore IBGP routes that are not synchronized.

  3. Prefer the route with the largest weight.

  4. Prefer the route with the largest local preference.

  5. Prefer the route that was locally originated.

  6. Prefer the route with the shortest AS path.

    If using bgp bestpath as-path ignore, skip this step. When using the as-set option for aggregated routes, as_set counts as 1 regardless of the number of AS entries in the set. Confederation sub-AS numbers are not used to determine the AS-path length.

  7. Prefer the route with the lowest origin (IGP < EGP < Incomplete).

  8. Prefer the route with the lowest MED. This comparison is only between routes advertised by the same external AS.

    If you're using bgp always-compare-med , compare MEDs for all paths. If used, this command needs to be configured on every BGP router in the AS.

    If you're using bgp bestpath med- confed , the MEDs are compared only for routes that have an AS confederation sequence in their AS-path attribute.

    If a prefix is received with no MED value, the prefix is assigned a MED value of 0. If you're using bgp bestpath med missing-as-worst, a prefix with a missing MED value is assigned a MED value of 4,294,967,294.

  9. Prefer EBGP routes to IBGP routes.

  10. Prefer the route with the nearest IGP neighbor.

  11. Prefer the oldest route.

  12. Prefer the path received from the router with the lowest router ID.

By default, Cisco IOS Software sets the MED value to 0 for a prefix that does not have the MED value set. If all other attributes are equal, the route with a MED of 0 is considered the best. Using this command causes the router to consider prefixes with a missing MED to have a MED of infinity.

Cisco IOS Software Release: 12.0

Configuration Example: Comparing MEDs from Different Autonomous Systems

In Figure 3-4, Router B is learning about network 150.150.150.0/24 from Routers A and C. Router C is using a MED of 20, and Router A is not setting the MED value. By default, BGP sets the missing MED value to 0. Because Routers A and C are in different autonomous systems, the MED values for 150.150.150.0/24 are not compared. For this example, we will force Router B to compare the MED values using the command bgp always-compare-med.

Figure 3-4. By Default, BGP Sets a Missing MED Value to 0

Router A router bgp 1 network 150.150.150.0 mask 255.255.255.0 neighbor 172.17.1.1 remote-as 2 ! ip route 150.150.150.0 255.255.255.0 serial0 ___________________________________________________________________________ Router B router bgp 2 bgp always-compare-med neighbor 172.17.1.2 remote-as 1 neighbor 10.1.1.2 remote-as 3 Router C router bgp 3 neighbor 10.1.1.1 route-map setmed out network 150.150.150.0 mask 255.255.255.0 neighbor 10.1.1.1 remote-as 2 neighbor 10.1.1.1 route-map setmed out ! ip route 150.150.150.0 255.255.255.0 serial1 ! route-map setmed permit 10 set metric 20

Router B is receiving an advertisement for network 150.150.150.0/24 from Routers A and C:

rtrB# show ip bgp BGP table version is 3, local router ID is 172.16.2.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 150.150.150.0/24 172.17.1.2 0 0 1 i * 10.1.1.2 20 0 3 I

The best-path algorithm has selected the route from Router A as the best because we are comparing MEDs. Router A does not send a MED value for network 150.150.150.0/24. By default, BGP sets the MED value for prefixes from Router A to 0.

Now modify the BGP configuration on Router B so that the missing MEDs are treated as infinity:

Router B router bgp 2 bgp bestpath med missing-as-worst

Verification

Verify that the best-path algorithm has selected the route from Router C as the best due to a lower MED value:

rtrB# show ip bgp BGP table version is 3, local router ID is 172.16.2.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * 150.150.150.0/24 172.17.1.2 0 0 1 i *> 10.1.1.2 20 0 3 i

Troubleshooting

Step 1. Verify that the BGP neighbors are in the Established state using the show ip bgp neighbors command.

If the neighbor relationship is not in the Established state, see section 8-23.

Step 2. If the command bgp bestpath missing-as-worst does not produce the desired result, check the other path attributes, such as weight and local preference. The other attributes might be selecting the best path before MED values are compared.

 < Free Open Study > 

Категории