'bgp always-compare-med' vs 'bgp deterministic-med'

這兩個指令看似大同小異,分開使用有不同的結果,合併使用也有不同結果,著實讓人摸不清楚,就算是很有經驗的BGP網管人員可能也無法完全說明白這兩個指令共同運作的來龍去脈,因此我希望可以留下一些個人的見解留在網路上給大家參考:


bgp always-compare-med

Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems.

在預設情況下,MED只用於比較來自相同來源AS路由的優劣;透過這個"bgp always-compare-med"指令的啟用,MED也可以被用來在不同來源的AS之間加以比較路由的好壞。如果使用這個指令的話,同一個AS裏面所有的路由器都應該要啟用這個特色,不然的話,有可能會發生loop的情況。


bgp deterministic-med

Enabling the bgp deterministic-med command ensures the comparison of the MED variable when choosing routes advertised by different peers in the same autonomous system. The bgp always-compare-med command is useful when multiple service providers or enterprises agree on a uniform policy for setting MED.

如果使用了"bgp deterministic-med"這個指令,路由器將會先將BGP路由根據來源AS加以分組之後,分別選出best route然後再將這些各分組選出的best route依序兩兩比較,依此原則選出最終的best route。


Note: The bgp deterministic-med and bgp always-compare-med commands are not enabled by default. Also, the two commands are separate; enabling one does not automatically enable the other.


我們拿下列的路由表來當成範例加以比較,依照不同的情況來選出best route

entry 1 : AS 65500, med 150, external, rid 192.168.13.1
entry 2 : AS 65100, med 200, external, rid 1.1.1.1
entry 3 : AS 65500, med 100, internal, rid 192.168.8.4

Note: BGP是利用兩個兩個路由一組的方式來比較單一目的地位址,由最新的entry開始再依序跟次新的entry加以比較(也就是由上而下的方式)。比方說entry 1跟entry 2先比較,選出較好的路由之後再跟entry 3加以比較,依此類推。

我們緊接著來看這兩個指令共同運作的幾種情況:

1)bgp always-compare-med DISABLED, bgp deterministic-med DISABLED

=> BGP先比較entry 1和entry 2。Entry 2被選出為較好的路由,因為它擁有較低的router-ID。因為來自於不同的AS,因此沒有檢查MED。接著entry 2跟entry 3一起比較。BGP最後選擇entry 2當成best path因為它是external route。


2)bgp always-compare-med ENABLED, bgp deterministic-med DISABLED

=>BGP先比較entry 1和entry 2。雖然分別屬於不同的AS,但是因為bgp always-compare-med指令的啟用,因此會針對MED加以比較。因為entry 1有較低的MED數值,因此entry 1被選成較好的路由。接著,BGP針對entry 1和entry 3加以比較。因為entry 1和entry 3都來自於相同的AS因此再次比較MED。最後BGP選出entry 3成為best path。


3)bgp always-compare-med DISABLED, bgp deterministic-med ENABLED

=>BGP根據來自相同AS的路由加以分組並且在每一組中選出最好的路由。BGP Table就會像是以下的情況:

entry 1 : AS 65100, med 200, external, rid 1.1.1.1
entry 2 : AS 65500, med 100, internal, rid 192.168.8.4
entry 3 : AS 65500, med 150, external, rid 192.168.13.1

以上例來說,BGP將路由依據來源AS分為兩組AS65100和AS65500。BGP在每組中選出最佳路由。Entry 1是AS65100這一組中唯的路由,因此成為AS65100的最佳路由。Entry 2是AS65500這一組中的最佳路由,因為entry 2的MED小於entry 3。接著BGP比較entry 1和entry 2,因為這兩個entries來自於不同的AS,因此在比較路由時不考慮MED。最後EBGP路由勝過IBGP路由,因此entry 1成為最佳路由。


4)bgp always-compare-med ENABLED, bgp deterministic-med ENABLED

=>BGP將路由依據來源AS分為兩組AS65100和AS65500。BGP在每組中選出最佳路由。Entry 1是AS65100這一組中唯一的路由,因此成為AS65100的最佳路由。Entry 2是AS65500這一組中的最佳路由,因為entry 2的MED小於entry 3。BGP接著利用MED來比較entry 1和entry 2,結果entry 2被選成最佳路由。

Comments

Popular posts from this blog

TCP/IP 明確擁塞通知 (ECN)

L2TPv3 Enables Layer 2 Services for IP Networks

Q-in-Q(Dot1Q Tunnel) Sample Configuration