BGP的選路原則
BGP屬性詳解
BGP選路配置
BGP有11條選路原則
比較前提:關閉同步、下一跳可達、路徑皆優
1.Prefer highest weight(local to router)
首先比較weight 越大越優-不傳遞 CISCO私有屬性
EBGP/IBGP之間選路均可用
2.Perfer highest local preference(global within AS)
比較本地優先級,默認爲100,僅IBGP鄰居之間傳遞,越大越優
3.Prefer rotue originated by the local rotuer(next hop=0.0.0.0)
優選本地下一跳
4.Prefer shortest AS path
比較AS-path,經過的AS數量少優,EBGP鄰居可增添
EBGP/IBGP之間選路均可用
5.Prefer lowest origin code(IGP<EGP<incomplete)
起源碼最小 i=igp(0) e=egp(1) ?=incomplete=2 i>e>?
EBGP/IBGP之間選路均可用
6.Prefer lowest MED(exchanged between autonomous systems)
MED值最小,越小越優
EBGP/IBGP之間選路均可用
7.Prefer EBGP path over IBGP path
普通的EBGP鄰居優於聯邦內EBGP鄰居優於IBGP鄰居
8.Prefer the path through the closest IGP neighbor
優選最近的IGP鄰居(IGP度量值小的)
9.Prefer oldest route for EBGP paths
優選最先建立EBGP鄰居
10.Prefer the path with the lowest neighbor BGP rotuer ID
最小BGP鄰居RID,比較BGP鄰居RID,小優
11.Prefer the path with the lowest neighbor IP address
優選最小的建鄰地址
BGP默認負載均衡的條目數爲1,也就是說BGP默認無負載均衡,可以人爲定義,通過修改max-path參數來改變負載均衡條目數,一旦修改的值大於1,那麼選路原則只會工作到第8條
總結用法:
1.一個路由器有多個出口時一般用weight來控制選路
2.一個AS內有多個出口時一般用Local_pref
3.影響其他人選路用MED out方向,影響自己選路用MED in方向
4.影響多個AS選路用AS-path
5.origin next-hop一般不用,有時會影響BGP的正常選路
選路實例
自然選路:
AS1內部:R1>R2直通
AS1外部:R1>AS2走R3,R2>AS2走R4,R1>AS3有兩條路優選最先建立鄰居的EBGP
AS2內部:R3>R4直通
AS2外部:R3>AS1走R1,R4>AS1走R2,R4>AS3有兩條路優選最先建立鄰居的EBGP
AS3內部:R7>R5直通,R7->R6直通
AS3外部:R5/R6>AS1走R2(EBGP>IBGP),R5/R6>AS2走R4(EBGP>IBGP)
控制選路:
1.AS1>AS2走R2
用Local_pref:在R2上抓取AS2的流量,增大Local_pref值,in方向
2.AS2>AS1走R3
用MED:在R4上抓取AS1的流量,增大MED值,in方向
3.AS1>AS3走R6
用weight:在R2上抓取AS3的流量,增大weight值,在R2與R6建鄰時調用,in方向
4.AS2>AS3走R5
用next-hop:在R4上抓取AS3的流量,定義下一跳地址爲R4->R5的下一跳地址,在R4與R5建鄰時調用,in/out方向都可以
5.AS3>AS2走R6
用AS-path:在R5上抓取AS2的流量,增加AS-path的長度,在R4-R6建鄰時調用,in/out方向都可以
6.AS3>AS1走R5
用Origin:在R6上抓取AS1的流量,定義origin爲?,在R2-R6建鄰時調用,in/out方向都可以