簡介
本檔案介紹在不同情況下實作時邊界閘道通訊協定(BGP)MED屬性越過AS邊界的情況。
必要條件
需求
思科建議您瞭解BGP的基本知識。
採用元件
本文件所述內容不限於特定軟體和硬體版本。本文討論的方案使用以下硬體和軟體版本:
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路運作中,請確保您瞭解任何指令可能造成的影響。
慣例
如需更多文件慣例的相關資訊,請參閱思科技術提示慣例。
背景資訊
多出口鑑別器(MED)提供了一種動態方式,當有另一個自治系統(AS)的多個入口點時,可影響該自治系統(AS)到達某一路由的方式。BGP使用系統化程式來選擇最佳路徑。在考慮MED屬性之前,還要考慮其他重要的屬性,例如weight、local preference、originate route和AS path。因此,如果其中任一條件匹配,則不考慮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。因此,當更新使用特定度量進入AS時,該度量用於在AS內做出決策。
show ip bgp 命令(從R2中選中)顯示xx.xx.xx.xx的度量值,該度量值來自iBGP鄰居xxx.x.xx.x,MED值為100。
eBGP在R2和R3之間運行,因為這些路由處於不同的AS中。當同一更新傳遞到第三個AS時(例如AS#101),該度量將返回為0。
show ip bgp 命令從R3中檢查後,會將其度量刪除,因為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,在R2中重新分發是為了將RIP網路注入到BGP。
路由器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值來通告網路。在本例中是RIP。字首10.0.0.0使用IGP MED值進行通告,IGP MED值是RIP的度量1。 此輸出中可看到這種情況。
在此情境中,會看到MED的行為(在網路透過etworkorredistributtecommand注入到BGP路由器的情況下),其中實際的MED值已替換為IGP指標的MED值。
如果如前所述,此屬性是提示外部鄰居進入AS的路徑優先順序,那麼並不總是考慮是否有其它更重要的屬性來確定最佳路由。
為了對更具確定性的屬性具有相同的效果,請在路set as-path prepend
由對映下使用命令。
如果為某些路由預置AS路徑,則其他AS會繼續看到它。有關AS-path prepend用法的詳細資訊,請參閱使用set-aspath prepend命令。
相關資訊