Cisco BGP-4 Command and Configuration Handbook

 < Free Open Study > 

3-1 bgp always-compare-med

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 you're using bgp bestpath as-path ignore, skip this step. When you use 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.

    NOTE

    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.

BGP normally does not compare MED values for routes from different autonomous systems. This command allows for the comparison of MED values for routes from different autonomous systems.

Cisco IOS Software Release: 11.0

Configuration Example: Comparing MED Values from Different Autonomous Systems

In Figure 3-1, Router B is learning about network 193.16.1.0/24 from Routers A and C. AS 4 is being simulated using loopbacks, a static route, and route maps.

Figure 3-1. MEDs From Different Autonomous Systems Are Normally Not Compared

Router A interface Loopback0 ip address 5.5.5.5 255.255.255.255 ! interface FastEthernet0 ip address 172.17.1.2 255.255.255.0 ! router bgp 1 redistribute static route-map setmed neighbor 172.17.1.1 remote-as 2 neighbor 172.17.1.1 route-map setas out no auto-summary ! ip route 193.16.1.0 255.255.255.0 Loopback0 route-map setmed permit 10 set metric 200 route-map setmas permit 10 set as-path prepend 4 ___________________________________________________________________________ Router B interfacef Ethernet0/0 ip address 172.17.1.1 255.255.255.0 ! interface Serial2/0 ip address 10.1.1.1 255.255.255.252 clockrate 64000 ! router bgp 2 neighbor 10.1.1.2 remote-as 3 neighbor 172.17.1.2 remote-as 1 ___________________________________________________________________________ Router C interface Loopback1 ip address 6.6.6.6 255.255.255.255 ! interface Serial0 ip address 10.1.1.2 255.255.255.252 ! router bgp 3 redistribute static route-map setmed neighbor 10.1.1.1 remote-as 2 neighbor 10.1.1.1 route-map setas no auto-summary ! route-map setmed permit 10 set metric 100 route-map setas permit 10 set as-path prepend 4 ip route 193.16.1.0 255.255.255.0 Loopback1

Router A is advertising network 193.16.1.0/24 with a metric or MED of 200, and Router C is advertising network 193.16.1.0/24 with a metric or MED of 100. Because Routers A and C are in different autonomous systems, Router B does not use the MED value to determine the best path. From the best path selection criteria, we can see that Router B uses the router ID to determine the best path to 193.16.1.0/24. The BGP ID of a neighbor BGP router can be found by using the show ip bgp neighbors command. A router's own BGP ID can be found using the show ip bgp summary or show ip bgp commands.

rtrA# show ip bgp summary BGP router identifier 5.5.5.5, local AS number 1 BGP table version is 3, main routing table version 3 1 network entries and 1 paths using 133 bytes of memory 1 BGP path attribute entries using 52 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP activity 2/3 prefixes, 5/4 paths Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 172.17.1.1 4 2 122 123 3 0 0 01:45:46 0 _____________________________________________________________________________________ rtrB# show ip bgp neighbors BGP neighbor is 10.1.1.2, remote AS 3, external link BGP version 4, remote router ID 6.6.6.6 BGP state = Established, up for 01:49:19 BGP neighbor is 172.17.1.2, remote AS 1, external link BGP version 4, remote router ID 5.5.5.5 BGP state = Established, up for 01:46:44 _____________________________________________________________________________________ rtrC# show ip bgp summary BGP router identifier 6.6.6.6, local AS number 3 BGP table version is 3, main routing table version 3 1 network entries and 2 paths using 153 bytes of memory 2 BGP path attribute entries using 192 bytes of memory BGP activity 1/0 prefixes, 3/1 paths Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 10.1.1.1 4 2 139 141 3 0 0 01:52:18 1

Router A has a lower router ID than Router C. If all other path selection criteria are equal, the route learned from Router A is used. Inspect the BGP table on Router B to ensure that 193.16.1.0/24 is being learned from both Routers A and C.

rtrB# show ip bgp BGP table version is 3, local router ID is 172.17.1.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 * 193.16.1.0 10.1.1.2 100 0 3 4 ? *> 172.17.1.2 200 0 1 4 ?

The route learned from Router A should be installed in the IP routing table even though this route has a higher MED than the route learned from Router C.

rtrB# show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort not set 172.17.0.0/24 is subnetted, 1 subnets C 172.17.1.0 is directly connected, Ethernet0/0 172.16.0.0/24 is subnetted, 1 subnets 10.0.0.0/30 is subnetted, 1 subnets C 10.1.1.0 is directly connected, Serial2/0 B 193.16.1.0/24 [20/200] via 172.17.1.2, 00:10:36

Modify the BGP configuration on Router B to allow the comparison of MED values from different autonomous systems.

Router B router bgp 2 bgp always-compare-med neighbor 10.1.1.2 remote-as 3 neighbor 172.17.1.2 remote-as 1

Verification

Verify that the best path to 193.16.1.0/24 has changed to the route with the lowest MED.

rtrB# show ip bgp BGP table version is 4, local router ID is 172.17.1.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 *> 193.16.1.0 10.1.1.2 100 0 3 4 ? * 172.17.1.2 200 0 1 4 ? rtrB# show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set 172.17.0.0/24 is subnetted, 1 subnets C 172.17.1.0 is directly connected, Ethernet0/0 172.16.0.0/24 is subnetted, 1 subnets S 172.16.4.0 is directly connected, Serial2/0 10.0.0.0/30 is subnetted, 1 subnets C 10.1.1.0 is directly connected, Serial2/0 B 193.16.1.0/24 [20/100] via 10.1.1.2, 00:02:08

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. Make sure you understand the algorithm for route selection listed at the beginning of this section. A route with a lower MED might not be selected if other attributes with a higher precedence are used to select the best route.

 < Free Open Study > 

Категории