cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1698
Views
0
Helpful
5
Replies

bgp MED

ed
Level 1
Level 1

bgp always compare-med.... is this one obsolete and no longer needed?

I am doing my lab and it seems like route updates gets evaluated with metric attribute with or without  "bgp alwaysys compare-med" comman.

iI thought in order for the router to compare metrics from neighbors that come from different AS, that command is needed when AS path sequence is tied.

1 Accepted Solution

Accepted Solutions

Hi,

this is not because it chose the 2nd path which has lowest MED that it used MED to choose it, it may have chosen it for a different reason further in the BGP best path selection process.

Can you try putting the MED for this path higher than other 2 and see if it still chooses the lowest MED .

Regards.

Alain.

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

View solution in original post

5 Replies 5

Reza Sharifi
Hall of Fame
Hall of Fame

You need the command if you want to change the default behavior:

The MED is one of the parameters that is considered when selecting the  best path among many alternative paths. The path with a lower MED is  preferred over a path with a higher MED. During the best-path selection  process, MED comparison is done only among paths from the same  autonomous system. The bgp always-compare-med command  is used to change this behavior by enforcing MED comparison between all  paths, regardless of the autonomous system from which the paths are  received.

The bgp deterministic-med  command can be configured to enforce deterministic comparison of the  MED value between all paths received from within the same autonomous  system.

http://www.cisco.com/en/US/docs/ios/12_3t/ip_route/command/reference/ip2_b1gt.html#wp1074407

HTH

that's what i thought also, but my findings prove otherwise.

the doc is saying the command is needed and In order for the router to compare metrics from  neighbors that come from different ASs, you need to issue the special  configuration command bgp always-compare-med on the router.

I am attaching the topology i am using ( this is based on BGP case study i got from cisco site).

I have used two methods to consider MED in the selection process, One is using "bgp bestpath as-path ignore" and the second one is AS prepending  ... just to make the AS sequence equal.

Now the route update (180.10.0.0) is coming from different AS(200 and 300)  going to R1 in AS100,

My expectation is the metric will be ignored without "bgp always-compare=med" statement however they are evaluated either they are on or not there.

R1#sh run

hostname R1

!

interface Serial1/0

ip address 3.3.3.1 255.255.255.0

serial restart-delay 0

!

interface Serial1/1

ip address 2.2.2.1 255.255.255.0

serial restart-delay 0

!

interface Serial1/2

ip address 4.4.4.1 255.255.255.0

serial restart-delay 0

!

interface Serial1/3

ip address 5.5.5.1 255.255.255.0

serial restart-delay 0

!

router bgp 100

no synchronization

bgp log-neighbor-changes

bgp bestpath as-path ignore

neighbor 2.2.2.2 remote-as 200

neighbor 3.3.3.3 remote-as 300

neighbor 4.4.4.4 remote-as 300

neighbor 5.5.5.5 remote-as 400

no auto-summary

!

end

R2#sh run

hostname R2

interface Serial1/0

ip address 24.24.24.2 255.255.255.0

serial restart-delay 0

!

interface Serial1/2

ip address 2.2.2.2 255.255.255.0

serial restart-delay 0

!

router bgp 200

no synchronization

bgp log-neighbor-changes

neighbor 2.2.2.1 remote-as 100

neighbor 2.2.2.1 route-map setmetric out

neighbor 24.24.24.4 remote-as 300

no auto-summary

!

ip prefix-list nlri1 seq 5 permit 180.10.0.0/16 le 24

!

route-map setmetric permit 10

match ip address prefix-list nlri1

set metric 50

!

end

R3#sh run

hostname R3

no ip domain lookup

ip domain name lab.local

ip auth-proxy max-nodata-conns 3

ip admission max-nodata-conns 3

!

interface FastEthernet0/0

ip address 34.34.34.3 255.255.255.0

duplex auto

speed auto

!

interface Serial1/3

ip address 3.3.3.3 255.255.255.0

serial restart-delay 0

!

router bgp 300

no synchronization

bgp log-neighbor-changes

neighbor 3.3.3.1 remote-as 100

neighbor 3.3.3.1 route-map setmetric out

neighbor 34.34.34.4 remote-as 300

no auto-summary

!

ip prefix-list nlri1 seq 5 permit 180.10.0.0/16 le 24

!

route-map setmetric permit 10

match ip address prefix-list nlri1

set metric 120

end

R4#sh run

hostname R4

interface Loopback0

ip address 180.10.0.1 255.255.255.0

!

interface FastEthernet0/1

ip address 34.34.34.4 255.255.255.0

duplex auto

speed auto

!

interface Serial1/1

ip address 4.4.4.4 255.255.255.0

serial restart-delay 0

!

router bgp 300

no synchronization

bgp log-neighbor-changes

network 180.10.0.0 mask 255.255.255.0

neighbor 4.4.4.1 remote-as 100

neighbor 4.4.4.1 route-map setmetric out

neighbor 24.24.24.2 remote-as 200

neighbor 34.34.34.3 remote-as 300

no auto-summary

!

ip prefix-list nlri1 seq 5 permit 180.10.0.0/16 le 24

!

route-map setmetric permit 10

match ip address prefix-list nlri1

set metric 200

!

end

the show ip bgp cmd tells me that R2 is selected w lower metric.... this is without bgp always-compare-med statement, yet, it got evaluated as lower metric

R1#sh ip bgp

BGP table version is 5, local router ID is 5.5.5.1

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path

*  180.10.0.0/24    4.4.4.4                200             0 300 i

*>                  2.2.2.2                 50             0 200 300 i

*                   3.3.3.3                120             0 300 i

Hi,

this is not because it chose the 2nd path which has lowest MED that it used MED to choose it, it may have chosen it for a different reason further in the BGP best path selection process.

Can you try putting the MED for this path higher than other 2 and see if it still chooses the lowest MED .

Regards.

Alain.

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

i think you're right, it was not based on MED on best path selection but rather something else further and in my case "the lowest router-id"

Raising up the metric on R2 higher than R3 and R4 still selects R2 as best path, therefore what shows in "show ip bgp" cant just be relied on. Incressing the router-id of R2 higher than R3 and R4 (lower RID prefered) justifies that R2 is no longer best path but rather R3 or R4. In this case MED is now used since both routers are now in the same AS and the default is to comapre the MED value in the same AS, the lower value wins.

By using "bgp always-compare-med", it includes R2 in different AS to be considered in the lowest MED selection process.

Giving R2 a lowest metric value makes R2 the best path.

Both of your answers are correct that " bgp always-compre-med" is indeed needed, but since cadet alain has enlightened me further im giving him the most credit.

'wish credits can be given to both helpful answers but maybe i will see try doing that. Thanks Reza and Cadet for your reply!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card