简介
本文档介绍边界网关协议(BGP)MED属性,当该属性在不同场景中实施时跨越AS边界。
先决条件
要求
建议本文的读者具备 BGP 的基础知识。
使用的组件
本文档不限于特定的软件和硬件版本。本文中讨论的场景使用了以下硬件和软件版本:
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
规则
有关文档规则的详细信息,请参阅思科技术提示规则。
背景信息
多出口鉴别器(MED)提供了一种动态方式,当存在另一个自治系统(AS)的多个入口点时,该方式可以影响另一个自治系统(AS)到达特定路由的方式。BGP使用系统化的过程来选择最佳路径。在考虑MED属性之前,需要考虑其他重要属性,如权重、本地优先级、源路由和AS路径。因此,如果其中任一条件匹配,则不考虑MED属性。
注意:当所有其他因素相等时,首选MED值最低的退出点。
案例研究
场景 1
当BGP发言者从对等体获取路由时,路由MED会传递到其他内部BGP(iBGP)对等体,但不会传递到外部BGP(eBGP)对等体。
路由器R1和路由器R2被视为同一个AS,例如AS#100,而路由器R3属于AS#101。为了方便起见,我们按照惯例使用 /24 区块中的 IP 地址。
路由器 R1 和 R2 配置如下:
路由器 1 |
(Config)#interface Loopback10
(Config-if)#ip address xx.xx.xx.xx xxx.xxx.xxx.xxx
(Config-if)#interface FastEthernet0/0
(Config-if)#ip address xx.xx.xx.xx xxx.xxx.xxx.xxx
(Config)#router bgp 100
(Config-router)#no synchronization
(Config-router)#bgp router-id xx.xx.xx.xx
(Config-router)#bgp log-neighbor-changes
(Config-router)#network xx.xx.xx.xx mask xxx.xxx.xxx.xxx route-map ATTACH_MED
(Config-router)#neighbor xxx.x.xx.x remote-as xxx
(Config-router)#no auto-summary
(Config)#access-list 10 permit xx.xx.xx.xx
(Config)#route-map ATTACH_MED permit xx
(Config)#match ip address xx
(Config)#set metric xxx |
路由器 2 |
(Config)#interface FastEthernet0/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#interface Serial1/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#encapsulation frame-relay IETF
(Config-if)#no fair-queue
(Config-if)#frame-relay map ip xxx.x.xx.x 203 broadcast
(Config-if)#no frame-relay inverse-arp
(Config-if)#frame-relay lmi-type ansi
(Config)#router bgp 100
(Config-router)#no synchronization
(Config-router)#bgp router-id xx.xx.xx.xx
(Config-router)#bgp log-neighbor-changes
(Config-router)#neighbor xxx.x.xx.x remote-as 100
(Config-router)#neighbor xxx.x.xx.x remote-as 101
(Config-router)#neighbor xxx.x.xx.x ebgp-multihop 3
(Config-router)#no auto-summary |
路由器R3的配置如下所示:
路由器 3 |
(Config)#interface Serial1/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#encapsulation frame-relay IETF
(Config-if)#no fair-queue
(Config-if)#frame-relay map ip xxx.x.xx.x 302 broadcast
(Config-if)#no frame-relay inverse-arp
(Config-if)#frame-relay lmi-type ansi
(Config)#router bgp 101
(Config-router)#no synchronization
(Config-router)#bgp log-neighbor-changes
(Config-router)#neighbor xxx.x.xx.x remote-as 100
(Config-router)#neighbor xxx.x.xx.x ebgp-multihop 3
(Config-router)#no auto-summary
|
在此设置中,R1和R2运行iBGP。当包含特定指标的更新进入自治系统后,该指标会被用于在自治系统内部做出决策。
show ip bgp 命令从R2检查后,显示xx.xx.xx.xx的度量值,该度量值来自iBGP邻居xxx.x.xx.x,MED值为100。
R2 和 R3 之间运行了 eBGP,因为它们属于不同的自治系统。当前述更新传递到第三个自治系统(例如 AS 101)时,指标将变回到为 0。
从R3检查到show ip bgp命令时,会删除其度量,因为xx.xx.xx.xx跨越了AS边界(101)。
在这种情况下,很明显,MED属性可以影响来自邻居自治系统的入站流量。
MED属性不能影响更远程自治系统的路由决策。当BGP发言者从对等体获取路由时,它可以将路由的MED传递到任何iBGP对等体,但不能传递到eBGP对等体。
因此,MED仅在相邻自治系统之间具有相关性。
场景 2
如果注入BGP的路由(通过etworkorredistributtecommand)来自IGP(RIP或EIGRP或OSPF),则MED从IGP度量中派生,且该路由将通告给具有此MED的eBGP邻居。
在这个网络中,R1 配置为在 RIP 网络中运行。路由器 R2 和 R3 之间运行了 BGP。其中,R2 属于 AS 100,R3 属于 AS 101。
路由器R1配置如下:
路由器 R1 |
(Config)#interface Loopback10
(Config-if)#ip address xx.xx.xx.xx xxx.xxx.xxx.xxx
(Config-if)#interface FastEthernet0/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config)#router rip
(Config-router)#network xx.x.x.x
(Config-router)#network xxx.x.xx.x
(Config-router)#no auto-summary
|
路由器 R2 和 R3 针对 BGP 进行了配置,将 RIP 网络注入到 BGP 的重新分发操作在 R2 中执行。
路由器 R2 |
(Config)#interface FastEthernet0/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#interface Serial1/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#encapsulation frame-relay IETF
(Config-if)#no fair-queue
(Config-if)#frame-relay map ip xxx.x.xx.x 203 broadcast
(Config-if)#no frame-relay inverse-arp
(Config-if)#frame-relay lmi-type ansi
(Config)#router rip
(Config-router)# network xxx.x.xx.x
(Config-router)#no auto-summary
(Config-router)#router bgp 100
(Config-router)#no synchronization
(Config-router)#bgp router-id xx.xx.xx.xx
(Config-router)#bgp log-neighbor-changes
(Config-router)#neighbor xxx.x.xx.x remote-as 101
(Config-router)#neighbor xxx.x.xx.x ebgp-multihop 3
(Config-router)#redistribute rip metric 1
Config-router)#no auto-summary
|
路由器 R3 |
(Config)#interface Serial1/0
(Config-if)#ip address xxx.x.xx.x xxx.xxx.xxx.x
(Config-if)#encapsulation frame-relay IETF
(Config-if)#no fair-queue
(Config-if)#frame-relay map ip xxx.x.xx.x 302 broadcast
(Config-if)#no frame-relay inverse-arp
(Config-if)#frame-relay lmi-type ansi
(Config)#router bgp 101
(Config-router)# no synchronization
(Config-router)#bgp router-id xx.xx.xx.xx
(Config-router)#bgp log-neighbor-changes
(Config-router)#neighbor xxx.x.xx.x remote-as 100
(Config-router)#neighbor xxx.x.xx.x ebgp-multihop 3
(Config-router)#no auto-summary |
RIP 和 BGP 均在 R2 上运行。如果您使用命show ip bgp
令进行检查,您可以看到前缀xx.x.x.x网络显示的度量为1,该度量源自RIP。
但是,在eBGP上运行的R3中,通过考虑从IGP派生的MED值来通告网络。在这种情况下,IGP 也就是 RIP。前缀10.0.0.0使用IGP MED值进行通告,MED值是RIP的度量值1。 这可以从此输出中看到。
在此场景中,可以看到网络通过etworkorredistributtecommand注入BGP路由器时MED的行为,其中实际MED值替换为IGP度量的值。
如果如前所述,此属性是对外部邻居有关进入AS的路径优先级的提示,则并不总是考虑是否有其它更重要的属性来确定最佳路由。
为了对更具确定性的属性具有相同的效果,请在路set as-path prepend
由映射下使用命令。
如果为某些路由预置AS路径,其他AS会继续看到它。有关AS-path prepend用法的详细信息,请参阅使用set-aspath prepend命令。
相关信息