BGP路由协议MED属性<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

多出口区分MEDMulti-Exit Discriminators)属性是一个可选非过渡属性。自治系统使用本地优先级属性(Local Preference)来进行出自治系统路由的选择;而MED属性用于判断进入该自治系统的最佳路由,当一个运行BGP的自治系统得到目的地址相同、下一跳不同的多条路由时,在其它条件相同的情况下,MED值较小的路由将被优先选作进入该自治系统的外部路由。

在缺省情况下,自治系统的MED值为0

一般情况下,路由器只比较来自同一 AS 中各 EBGP 邻居路径的 MED 属性,不比较来自不同 AS MED 值。若非得要比较的话, Quidway 系列路由器提供的“ bgp always-compare-med ”命令,可实现用户的这一要求。

注:缺省情况下,不比较来自不同自治系统邻居的路径的 MED 属性值。除非能够确认不同的自治系统采用了同样的 IGP 和路由选择方式,否则不要使用该配置命令。

下面的例子就是一个这样的问题,教师在讲述 BGP 路由协议 MED 属性时,可以引用这个例子来说明。

 

相同路由比较为什么有时没有选择MED值小的路由?
1.组网:
                            <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

 

2.配置:
RTA#

!

router bgp 500

neighbor 201.1.1.2 remote-as 700

neighbor 201.1.1.2 route-map SETMED out

!

route-map SETMED permit 10

set metric 50

!

RTB#

!

router bgp 600

neighbor 160.1.1.2 remote-as 700

neighbor 160.1.1.2 route-map SETMED out

!

route-map SETMED permit 10

set metric 100

!

RTC#

!

router bgp 700

neighbor 160.1.1.1 remote-as 600

neighbor 160.1.1.1 filter-list 1 out

neighbor 201.1.1.1 remote-as 500

neighbor 201.1.1.1 filter-list 1 out

!

ip as-path access-list 1 permit ^$

!

 

.......
3.现象描述:三台Quidway之间分别建立了EBGP邻居关系,其中RTC同时收到RTARTB发来的因特网路由,从而可以通过两条链路到达因特网。根据RTC的要求,RTA将自己发送给RTC的路由设置MED值为50,而RTB将自己发送给RTCMED设置为100RTC希望选择MED小的路由作为最佳路由,从而对相同目的地来说,把通过RTA的链路作为主链路,而把通过RTB的链路作为备份链路。
现已知路由192.10.0.0/16同时由RTARTB传给RTC,但RTC选择了RTB传来的路由。
可见,RTC确实同时从RTARTB收到了路由192.10.0.0/16,它们的AS-PATH长度相同,并且MED值符合要求。
RTC#show ip route

Routing Tables:

Destination/Mask Proto Pre Metric Nexthop Interface

...

176.17.20.0/24 BGP 256 100 160.1.1.1 Serial0

192.10.0.0/16 BGP 256 100 160.1.1.1 Serial0

RTC#show ip bgp

BGP local router ID is 200.1.7.2

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

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

Network Next Hop Metric LocPrf Path

*> 176.17.20.0/24 160.1.1.1 100 600 i

*> 192.10.0.0/16 160.1.1.1 100 600 400 300 100 i

* 201.1.1.1 50 500 400 300 100 i
问题:RTC为什么没有选择MED值最小的路由?

 

 

4.处理过程:为了能够在不同AS传来的相同路由之间比较MED值,从而选择MED小的路由作为最佳路由,需要配置一条命令BGP ALWAYS-COMPARE-MED 。新的配置为:
RTC#
!
router bgp 700
 bgp always-compare-med
 neighbor 160.1.1.1 remote-as 600
 neighbor 160.1.1.1 filter-list 1 out
 neighbor 201.1.1.1 remote-as 500
 neighbor 201.1.1.1 filter-list 1 out
!    
配置该命令后,清除原来的BGP路由(clear ip bgp *),等RTC上的路由再次稳定后结果如下:
RTC#show ip bgp

 

BGP local router ID is 200.1.7.2
Status codes: s suppressed, d damped, h history, * valid, > best, i internal
Origin codes: i - IGP, e - EGP, ? - incomplete

 

    Network               Next Hop        Metric    LocPrf    Path
*>  176.17.20.0/24       160.1.1.1         100                600 i
*>  192.10.0.0/16        201.1.1.1         50                 500 400 300 100 i
*                        160.1.1.1         100                600 400 300 100 i
......
5.原因分析:Quidway路由器的BGP协议在路由优选过程中考虑若干因素,包括本地优先级、AS路径长度、起点类型、MED值等。在前几项都相同的情况下,应选择MED值小的路由作为最佳路由。需要注意的是,MED值只在同一AS传来的路由之间才有比较性。