Vous êtes sur la page 1sur 2

R3 prefers the path via R4 to reach 150.1.1.

0 because the shorter as path length R3(config)#do show ip bgp Network * 150.1.1.0/24 *> * 150.2.2.0/24 *> *> 150.3.3.0/24 R3(config)# Next Hop 2.2.2.2 4.4.4.4 4.4.4.4 2.2.2.2 0.0.0.0 Metric LocPrf Weight 0 0 0 0 0 0 0 32768 Path 2 1 ? 4 ? 4 1 2 ? 2 ? ?

I want that R3 goes via R2 to reach 150.1.1.0/24 so i will use the med: R4(config)#route-map med permit 10 R4(config-route-map)#set metric 40 R4(config)#router bgp 4 R4(config-router)#neighbor 3.3.3.3 route-map med out R2(config)#route-map med permit 10 R2(config-route-map)#set metric 20 R2(config)#router bgp 2 R2(config-router)#neighbor 3.3.3.3 route-map med out And by default the med value is compared if it is advertised by the same AS in t his case AS 4 advertises the med 40 and AS 20 advertises the med 20 so i should configure the following command : R3(config)#router bgp 3 R3(config-router)#bgp always-compare-med R3 still prefers the path via R4 because R3 before comparing the med ,it looks t hat the shorter as path length is via R4 (4) comparing with the as path length v ia R2(2 1) (the order preference the med comes after the shortest as path length ): R3(config-router)#do show ip bgp Network Next Hop *> 150.1.1.0/24 4.4.4.4 * 2.2.2.2 * 150.2.2.0/24 4.4.4.4 *> 2.2.2.2 *> 150.3.3.0/24 0.0.0.0 R3(config-router)# Metric LocPrf Weight 40 0 20 0 40 0 20 0 0 32768 Path 4 ? 2 1 ? 4 1 2 ? 2 ? ?

How to override this behavior so R3 will use the med as the criteria in order to reach 150.1.1.0/24 via R2? to solve this problem I will add another sequence in the route map called med an d configured in R4 above in order to increase the as path length to be equal wit h as path length received from R2 thus R3 will use the med to decide the best pa th : On R4: ip prefix-list 150-1-1-0 seq 5 permit 150.1.1.0/24 ! route-map med permit 10 set metric 40 ! route-map med permit 20 match ip address prefix-list 150-1-1-0

set as-path prepend 4 R3 chooses the med metric and ignore the prepend R3(config)#do show ip bgp Network *> 150.1.1.0/24 * * 150.2.2.0/24 *> *> 150.3.3.0/24 Next Hop 4.4.4.4 2.2.2.2 4.4.4.4 2.2.2.2 0.0.0.0 Metric LocPrf Weight 40 0 20 0 40 0 20 0 0 32768 Path 4 ? 2 1 ? 4 1 2 ? 2 ? ?

when i changes the order of sequence in route- map: route-map med permit 20 match ip address prefix-list 150-1-1-0 set as-path prepend 4 ! route-map med permit 30 set metric 40 here R3 chooses the prepend and ignore the med metric R3(config-router)#do show ip bgp Network *> 150.1.1.0/24 * * 150.2.2.0/24 *> *> 150.3.3.0/24 Next Hop 4.4.4.4 2.2.2.2 4.4.4.4 2.2.2.2 0.0.0.0 Metric LocPrf Weight 0 0 20 0 40 0 20 0 0 32768 Path 4 4 ? 2 1 ? 4 1 2 ? 2 ? ?

how to force R3 to choose the med instead of the shortest as path,in other word how to override the shortest as path and use the med?