BGP Always-compare-med & Deterministic-med

There are two BGP configuration commands that can influence the MED-based path selection, the bgp deterministic-med and the bgp always-compare-med commands.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. Enabling the bgp always-compare-med command ensures the comparison of the MED for paths from neighbors in different autonomous systems. The bgp always-compare-med command is useful when multiple service providers or enterprises agree on a uniform policy for setting MED. Thus, for network X, if Internet Service Provider A (ISP A) sets the MED to 10, and ISP B sets the MED to 20, both ISPs agree that ISP A has the better performing path to X.

[Command Function] After using the bgp deterministric-med command, the router classifies the path based on the neighbor AS and MED to ensure that the path is classified in the same way at all times. This can produce the deterministic best path. ?
1> first classification according to AS, MED comparison within the same AS
2> and then compare attributes between AS, if you use the bgp always-compare-med, regardless of the time has come, all med value of the minimum preferred. If you do not use bgp always-compare-med, then compare the BGP after thirteen items. Until the result is reached.
That is, the time not seen after using bgp deterministric-med is only classified according to AS.
[Experimental prelude]
By default, when BGP processes the steps of routing entries, it will be compared in order of time. For example, entry1, entry2, entry3 (entry1 is the latest received, entry3 is the oldest entry), the router will put the new one at the top of the stack, and the old one at the bottom of the stack
entry 1
entry 2
entry 3
first compare entry1 and entry2, Choose the winner and compare it with entry3, and so on, so as to choose the best path.
You can analyze this calculation process by the following experimental results.
[experiment]

[Note: R1, R2, R3 loopback ports are all 192.168.1.0/24 network segment, used to simulate three BGP routes that reach R7 to reach the same destination address, R 1 advertises out MED value is 100, R2 advertises out sign The MED value is 150, and the ip os co is used to manually set the IGP metric value on the three interfaces of R7. The order of the arrival of the routing entries is determined by the order of the nei command.
We examine the three routing entries entyrA1, entryA2, entryB to analyze the problem:

Let's look at the different results by controlling the time when these three routes reach R7. The following table shows the final results
(Note: first analyze the first line of the table below, A1 first reaches the routing table of R7, then A2 arrives, and finally B Arrival, in chronological order we can sort
entryB from newest to oldest : AS (PATH) 3, med 0, igp metric 12, internal, rid 6.6.6.6
entryA2: AS (PATH) 12, med 150, igp metric 11, internal, rid 5.5.5.5
entryA1: AS (PATH) 12, med 100, igp metric 13, internal, rid 4.4.4.4
Then B first compares with A2, the AS number is different, MED is not considered; meanwhile IBGP routing, compare IGPmetrcic, A2 ( metric = 11 <12) wins; then A2 and A1 are compared, the same AS number, the MED value is compared, A1MED value is small, A1 wins, consistent with the experimental results, you can analyze the following items yourself)


1> For those who do not use bgp deterministric-med, you can calculate the result yourself according to the above calculation method.
2> The results after using the bgp deterministric-med command are the same. This is the result of comparing the routing entries after grouping. The router divides the three routes into 2 groups according to AS number, A1 and A2; group B, and then selects the winner A1 from A1 and A2 according to the MED value, and then compares with the winner of group B, because B is down The one-hop IGP metric is small and wins, and B will win no matter who receives it first.
Note
? It can be seen that bgp deterministric-med can indeed produce the most deterministic route, because after grouping according to AS, each entry in the same group will use the MED value comparison to determine the best MED value, if If it is used with the bgp always-compare-med command, it will definitely produce the optimal route with the smallest MED value; the result before using it is uncertain. The literal translation of this command is also the deterministic med of bgp, which shows that it is still very useful.

Published 220 original articles · won praise 2 · Views 4463

Guess you like

Origin blog.csdn.net/qq_43207781/article/details/105503599
BGP