1. 程式人生 > 其它 >BGP選路解析(H3C)

BGP選路解析(H3C)

1.1        解析BGP選路的意義

每個路由協議都有自己計算路由的方法,計算路由的方法稱為路由演算法,BGP選路方法就是BGP的路由演算法,BGP執行路由演算法的目的是計算出有效路由進而優選出最優路由,選路演算法是BGP路由協議的核心演算法之一。

1.2        BGP選路與常見IGP選路的區別

眾所周知,鏈路狀態演算法的路由協議,其路由非通告所得,而是計算所得,所以在鏈路狀態演算法如OSPF,在其作用域內無法人為地干涉路由優選,即演算法不可改變,在路由器的實現中在程式碼中固定,人為干涉的結果會導致路由無法計算或計算出錯,在鏈路狀態演算法的作用域之間,有相對比較簡單的計算規則,一般也沒有必要人為地去幹涉選路(如OSPF協議的區域間路由)。

以上原因導致OSPF的路由計算對網路管理員來說比較傻瓜化,大部分的選路工作由機器完成,管理員參與的部分極少。

基於距離向量的IGP,如RIP由於路由協議中攜帶的資訊量極少,可供選路決策的條件很少,所以討論其協議內部的路由優選意義不大。

BGP選路是一個比較複雜的過程,需要深入討論,原因是BGP的設計者將需要大部分由程式碼固化完成的工作分了一部分出來“允許”管理員參與完成,在協議中也包含了豐富的優選引數,可供選路時自動或人為地進行控制與決策。這也說明,關於BGP的主要工作內容由兩部分:

²        在AS之間及AS內部傳遞路由――自動完成

²        控制、管理、優化路由――自動或由管理員手動完成

通過選路,我們可以看出設計者設計如此多屬性的原因,與通用的IGP協議採用單一Metric計算路由相比,BGP的眾多屬性更細緻地反映一條路由的“歷史背景”,在選路過程中可以自動或手動地利用這些豐富的材料進行綜合考慮,進而更為細膩地優選和控制路由。

2         BGP選路過程解析

2.1        選路規則

BGP IPv4選路規則如下:

Ø         下一跳(Next_Hop)不可達的路由及其他無效路由不參與優選;

Ø         優選協議優先順序值低的路由;

Ø         標籤路由(有LSP隧道)優於非標籤路由;

Ø         若配置了Preferred-value值,優選值高的;

Ø         優選本地優先順序(Local_Pref)最高的路由;

Ø         優選本路由器始發的路由;

Ø         優選AS路徑(AS_Path)最短的路由;

Ø         依次選擇Origin屬性值為IGP、EGP、Incomplete的路由;

Ø         優選MED值最低的路由;

Ø         EBGP路由優於聯盟EBGP路由,聯盟EBGP路由由於IBGP路由;

Ø         優選下一跳(Next_Hop)花費(Cost)值最低的路由;

Ø         優選Cluster_List長度最短的路由;

Ø         優選Originator_ID最小的路由;

Ø         Router ID值小者優先;

Ø         BGP會話地址小者優先。

以上優選規則是從前到後依次比較的,只有在前一個條件無法選出最優路由的情況下才考慮緊接的後一個條件。

2.2        例項解析選路過程

在本小節,通過例項的方式,按照以上選路規則解析路由器在選路過程中各步驟的決策條件。由於BGP屬性豐富,實際使用環境千變萬化,在實際使用中會出現各種應用場景,一個完整體現所有決策過程的拓撲會很複雜,為了簡潔明瞭地展開,本文用簡化的拓撲來解析每個決策步驟。

 

 

 

圖1說明:

RA、RB、RC都屬於AS100,三者建立Full mesh IBGP連線

RD、RE屬於AS200,二者建立IBGP連線

RA環回地址:192.168.100.1

RB環回地址:192.168.100.2

RC環回地址:192.168.100.3

步驟1NEXT_HOP不可達的路由及沒有隧道的標籤路由都是無效路由,不參與優選

解析:RA從RB和RC分別收到關於20.1.1.0/24的路由,但下一跳沒有改變,下一跳屬於AS外部路由,RA不可達,所以下面兩條路由沒有星號(*)標誌,都是無效的路由。

在RA上的BGP表資訊如下:

 [RA]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

     Network       NextHop         MED        LocPrf     PrefVal Path/Ogn

   i 20.1.1.0/24        10.1.4.2        0          100        0       200i

   i                  10.1.5.2        0          100        0       200i 

步驟2:優選協議優先順序低的路由

解析:在路由有效的情況下比較路由優先順序。通過路由策略修改協議優先順序,RA從RC收到的路由優先順序修改為250,而RA從RB收到的路由優先順序為預設的255,所以在RA上優選的結果是從RC收到的路由更優。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

     Network         NextHop         MED       LocPrf     PrefVal Path/Ogn

 *>i 20.1.1.0/24       192.168.100.3     0          100        0       200i

 * i                 192.168.100.2     0          150        0       200i

[RA-bgp]disp ip rout 20.1.1.1

Routing Table : Public

Summary Count : 1

Destination/Mask    Proto   Pre  Cost         NextHop         Interface

20.1.1.0/24         BGP    250  0           192.168.100.3   GE0/1.112     

步驟3:標籤路由優於非標籤路由

解析: 取消上一步修改路由優先順序的路由策略配置,RA從RB和RC的路由優先順序一致,根據協議優先順序無法選出最優路由。繼續比較,首先考慮的條件是該路由是否是標籤路由(是否存在LSP隧道)。重新配置路由策略,使RC向RA傳送路由的同時分發標籤,帶有標籤的路由優於非標籤路由,所以優選從RC收到的路由。

[RA]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

   Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3   0          100        0       200i

 * i                  192.168.100.2   0          150        0       200i

[RA]disp ip rout 20.1.1.1

Routing Table : Public

Summary Count : 1

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

20.1.1.0/24         BGP    255  0            192.168.100.3   GE0/1.112

[RA]display mpls lsp include 20.1.1.1 24

-------------------------------------------------------------------------

                 LSP Information: BGP LSP

-------------------------------------------------------------------------

FEC              In/Out Label  In/Out IF                       Vrf Name

20.1.1.0/24        NULL/1025     -/-             

[RA-route-policy]display bgp routing-table 20.1.1.0

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 Label information (Received/Applied): 1025/NULL

 From            : 192.168.100.3 (192.168.50.29)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 100, pref-val 0, pre 255

 State           : valid, internal, best,

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.2 (135.1.1.1)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 150, pref-val 0, pre 255

 State           : valid, internal,

 Not advertised to any peers yet          

步驟4Preferred-value值高的路由優先

解析取消上一步分發標籤的策略,RA從RB和RC收到的路由都沒有LSP隧道,所有前述條件無法選出最優路由,系統將進一步比較Preferred-value值優選路由。配置路由策略,使RA從RC收到的路由Preferred-value值較高,RA優選從RC收到的路由。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3      0          100        30      200i

 * i                  192.168.100.2                 150        0       200i

[RA-bgp]display bgp routing-table 20.1.1.0

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.2 (135.1.1.1)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : 200

 Origin          : igp

 Attribute value : localpref 150, pref-val 0, pre 255

 State           : valid, internal,

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.3 (192.168.50.29)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 100, pref-val 30, pre 255

 State           : valid, internal, best,

 Not advertised to any peers yet                       

步驟5Local_Preference值高的路由優先

解析:在Preferred-value值相同的情況,進一步比較Local_Preference值優選路由,取消上一步修改Preferred-value值的路由策略,RA從RB收到的路由Local_Preference值較高,所以優選從RB收到的路由。

[RA-route-policy]disp bgp ro

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 *>i 20.1.1.0/24        192.168.100.2        0          150        0       200i

 * i                  192.168.100.3        0          100        0       200i

[RA-route-policy]display bgp routing-table 20.1.1.0

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.3 (192.168.50.29)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 100, pref-val 0, pre 255

 State           : valid, internal,

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.2 (135.1.1.1)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 150, pref-val 0, pre 255

 State           : valid, internal, best,

 Not advertised to any peers yet 

步驟6:本地路由優先

解析:在RA上用路由聚合命令生成本地路由,並且使本地生成路由、IBGP路由、EBGP路由的路由優先順序都相等。這時其他先決條件都相等的情況下,本地生成的路由優先。

[RA-route-policy]display bgp routing-table

 Total Number of Routes: 3

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

   Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 *>  20.1.1.0/24        127.0.0.1                     100        0       i

 * i                   192.168.100.3                 100        0       i

[RA-route-policy]display bgp routing-table 20.1.1.0 24

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.3 (192.168.50.29)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : (null)

 Origin          : igp

 Attribute value : localpref 100, pref-val 0, pre 150

 State           : valid, internal,

 This route is an atomic-aggregated route

 Aggregator      : AS 100, Aggregator ID: 192.168.50.29

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 Imported route.

 From            : 0.0.0.0 (0.0.0.0)

 Original nexthop: 127.0.0.1

 AS-path         : (null)

 Origin          : igp

 Attribute value : localpref 100, pref-val 0, pre 150

 State           : valid, local, best,

 This route is an aggregated route

 Aggregator      : AS 100, Aggregator ID: 192.168.100.1

 Advertised to such 1 peers:

    192.168.100.3                                              

步驟7AS-Path較短的路由優先

解析:在前述條件都相同的情況下,將進一步比較AS-Path長度來優選路由。配置新增AS號的路由策略,RA從RC收到關於20.1.1.0/24的路由AS-path中包含兩個AS號,從RB收到的路由中包含三個AS號,在其它先決條件都相同的情況下,RA從RC收到的路由AS-path列表相對更短,所以優選從RC收到的路由。

按照AS-Path優選路由的規則可以細化為:AS_SEQ型別的AS-path長度為所包含的AS個數,AS_SET型別的AS-path長度為1,聯盟AS型別不計入AS-path長度。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 4

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop        MED       LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3      0          100        0       300 200i

 * i                  192.168.100.2                 100        0       400 300 200i     

步驟8:依次選擇Origin屬性值為IGPEGPIncomplete的路由

解析1:在AS-Path長度相同的情況下將進一步比較Origin屬性的值。

下表顯示RA從RB收到的路由origin屬性為incomplete,從RC收到的路由origin屬性為egp,在其他先決條件都相等的情況下,origin屬性egp優於incomplete,RA優選從RC收到的路由

[RA-bgp]display bgp routing-table

 Total Number of Routes: 4

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop         MED      LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3       0         100        0       320 200e

 * i                  192.168.100.2                 100        0       300 200?

解析2:下表顯示RA從RB收到的路由origin屬性被修改為igp,從RC收到的路由origin屬性仍然為egp,在其他先決條件都相等的情況下,origin屬性igp優於egp,所以最優路由發生變化,從RB收到的路由變成最優路由

[RA-route-policy]display bgp routing-table

 Total Number of Routes: 4

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network           NextHop       MED       LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.2               100        0       300 200i

 * i                  192.168.100.3    0          100        0       320 200e 

總結:IGP優於EGP,EGP優於incomplete

步驟9:優選MED值最低的路由

解析1:取消上一步修改Origin屬性的路由策略,在Origin屬性及其他先決條件都無法比較出最優路由的情況下,MED屬性值小的路由優先,下表RA從RC收到關於20.1.1.0/24的路由MED值更低所以更優。

[RA-route-policy]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network          NextHop       MED        LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3   15          100        0       320 200e

 * i                  192.168.100.2   20          100        0       320 200e

步驟10:依次優選EBGP路由、聯盟EBGP路由、IBGP路由

圖2說明:

RA和RB屬於聯盟子系統65001,RC屬於聯盟子系統65002;

RA與RB建立聯盟子系統內IBGP鄰居關係;

RA與RC建立聯盟子系統間EBGP鄰居關係;

RA與RE建立普通EBGP鄰居關係。

 

 

 

聯盟選路拓撲

解析1:在圖2中,RA分別從RB、RC、RE收到路由,在本步驟前的其他先決條件都相同的情況下優選來自EBGP的路由,EBGP路由優於聯盟EBGP和IBGP路由,所以RA優選來自RE的路由。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 3

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop       MED       LocPrf     PrefVal  Path/Ogn

 *>  20.1.1.0/24        10.1.0.2         5          160        0       200i

 * i                   192.168.100.3    5          160        0       (65002) 200i

 * i                   192.168.100.2    5          160        0       200i     

解析1:當EBGP路由被撤銷後,重新優選,由於聯盟EBGP路由優於IBGP路由,所以來自RC的路由優於來自RB的路由

[RA-GigabitEthernet0/1.110]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network           NextHop       MED       LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3     5          160        0       (65002) 200i

 * i                  192.168.100.2     5          160        0       200i     

步驟11:優選下一跳Cost值最低的路由;

解析:在其他先決條件都相等的情況下將比較下一跳的Cost值,RA從RC收到的路由下一跳為RC的環回地址192.168.100.3,到達該地址的IGP cost為13;RA從RB收到的路由下一跳為RB的環回地址192.168.100.2,到達該地址的IGP cost為15。因此優選從RC收到的路由。

[RA-GigabitEthernet0/1.112]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

 Network             NextHop         MED       LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3                100        0       200i

 * i                  192.168.100.2     0          100        0       200i

 

[RA-GigabitEthernet0/1.112]disp ip rout 192.168.100.2

Routing Table : Public

Summary Count : 1

Destination/Mask    Proto   Pre  Cost         NextHop         Interface

192.168.100.2/32    OSPF   10   15          10.1.1.2        GE0/1.111

[RA-GigabitEthernet0/1.112]disp ip rout 192.168.100.3

Routing Table : Public

Summary Count : 1

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

192.168.100.3/32    OSPF   10   13         10.1.2.2        GE0/1.112             

步驟12:優選Cluster_List長度最短的路由;

在圖3中,BGP會話關係用黑色鏈路表示,綠色鏈路表示RB向RA反射從RD收到的路由;紅色鏈路表示RD發出的路由經過兩個反射器(RE和RC)反射到RA。

RA從RB收到的路由Cluster_List中只有一個條目;RA從RC收到的路由Cluster_List中有兩個條目。所以從RB收到的路由更優。

 

 

 

[RA]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network          NextHop         MED     LocPrf     PrefVal  Path/Ogn

 *>i 40.1.1.0/24        192.168.100.2              100        0       ?

 * i                  192.168.100.3              100        0       ?

[RA]display bgp routing-table 40.1.1.0

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 40.1.1.0/24:

 From            : 30.1.1.3 (30.1.1.3)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : (null)

 Origin          : incomplete

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal, best,

 Originator      : 192.168.100.4

 Cluster list     : 192.168.100.2

 Not advertised to any peers yet

 BGP routing table entry information of 40.1.1.0/24:

 From            : 30.1.1.2 (30.1.1.2)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : (null)

 Origin          : incomplete

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal,

 Originator      : 192.168.100.4

 Cluster list    : 192.168.100.3, 192.168.100.5

 Not advertised to any peers yet         

步驟13:優選Originator_ID最小的路由;

在前述步驟未選出最優路由的情況下,進一步比較Originator_ID。

在圖4中,BGP會話關係用黑色鏈路表示,綠色鏈路表示RB向RA反射從RD收到的路由;紅色鏈路表示RC向RA反射從RE收到的路由。

解析:RA從RB收到的路由中Originator_ID相對更小,所以從RB收到的路由更優。

 

[RA]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network           NextHop         MED    LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.2              100        0       ?

 * i                  192.168.100.3              100        0       ?

 

[RA]display bgp routing-table 20.1.1.1

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 30.1.1.2 (30.1.1.2)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : (null)

 Origin          : incomplete

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal,

 Originator      : 192.168.100.5

 Cluster list    : 192.168.100.3

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 30.1.1.3 (30.1.1.3)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : (null)

 Origin          : incomplete

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal, best,

 Originator      : 192.168.100.4

 Cluster list    : 192.168.100.2

 Not advertised to any peers yet

步驟14Router ID值小者優先

RA從RB和RC收到的路由在前述步驟都無法優選出路由的情況下需要進一步比較Router ID來選出最優路由,在此步驟中Router ID值小的路由優先。

解析:RB的BGP Router ID為6.6.6.6;RC的BGP Router ID為5.5.5.5。所以在RA的BGP路由表中,從RC收到的路由優先。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop        MED        LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24        192.168.100.3                  100        0       200i

 * i                  192.168.100.2      0           100        0       200i

[RA-bgp]display bgp routing-table 20.1.1.1

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.3 (5.5.5.5)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : 200

 Origin          : igp

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal, best,

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.2 (6.6.6.6)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 100, pref-val 0, pre 255

 State           : valid, internal,

 Not advertised to any peers yet             

 

 

 步驟15:建立BGP會話的地址值小者優先

RA從RB和RC收到的路由在前述步驟都無法優選出路由的情況下(除其他先決條件外,兩條路由的Router ID也相同)需要進一步比較建立BGP會話的地址值來選出最優路由,在此步驟中BGP會話地址值小的路由優先。

解析:在圖1中RB的環回地址為192.168.100.2,RB與RA的BGP會話通過此地址建立;RC的環回地址為192.168.100.3,RC與RA的BGP會話通過此地址建立。因為RB與RA建立BGP會話的地址相對更小,所以在RA的BGP路由表中,從RB收到的路由優先。

[RA-bgp]display bgp routing-table

 Total Number of Routes: 2

 BGP Local Router ID is 192.168.100.1

 Status codes: * - valid, > - best, d - damped,

               h - history,  i - internal, s - suppressed, S - Stale

               Origin : i - IGP, e - EGP, ? - incomplete

    Network            NextHop         MED       LocPrf     PrefVal  Path/Ogn

 *>i 20.1.1.0/24          192.168.100.2     0          100        0       200i

 * i                    192.168.100.3                100        0       200i

[RA-bgp]display bgp routing-table 20.1.1.1

 BGP local Router ID : 192.168.100.1

 Local AS number : 100

 Paths:   2 available, 1 best

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.2 (6.6.6.6)

 Relay Nexthop   : 10.1.1.2

 Original nexthop: 192.168.100.2

 AS-path         : 200

 Origin          : igp

 Attribute value : MED 0, localpref 100, pref-val 0, pre 255

 State           : valid, internal, best,

 Not advertised to any peers yet

 BGP routing table entry information of 20.1.1.0/24:

 From            : 192.168.100.3 (6.6.6.6)

 Relay Nexthop   : 10.1.2.2

 Original nexthop: 192.168.100.3

 AS-path         : 200

 Origin          : igp

 Attribute value : localpref 100, pref-val 0, pre 255

 State           : valid, internal,

 Not advertised to any peers yet        

2.3        優選路由的策略
優選路由的策略方法有很多,簡單舉例如下:

l         影響某臺路由器本地選路結果

建議配置路由策略在本地修改Preferred-value來影響選路過程;由於Preferred-value值不屬於路由屬性,修改後只在本地生效,不會隨路由資訊傳播。但影響本地選路後,BGP只發送最優路由,對其他路由器也有一定的影響。

l         影響IBGP鄰居的選路

如果希望影響本AS內部的路由器優選自己發出的路由,建議通過修改Local_Preference屬性值來實現,在圖1中,RB向RA傳送的路由中Local_Preference屬性值為150,RC向RA傳送的路由中Local_Preference屬性值為預設值100,在RA上將優選從RB收到的路由,出AS的流量將通過RB發向AS200。

Local_Preference屬性可以向所有IBGP鄰居傳送,可以對本AS內部所有的IBGP鄰居選路產生影響。

l         影響EBGP鄰居的選路

如果希望EBGP鄰居優選自己發出的路由,建議通過修改MED屬性值來實現,在圖1中,RD向EBGP鄰居RB傳送的路由中MED屬性值為20,RE希望AS100中的路由器優選自己發出的路由,所以向EBGP鄰居RC傳送的路由中MED屬性值為15,低於RD向RB傳送路由的MED值,因為MED值低的路由更優,在AS100中將優選來自RE的路由。

在使用MED屬性時須注意,利用MED值進行優選是有一定條件的,來自不同AS的路由預設情況下不能根據MED值優選路由,需要使能來自不同AS的路由選路時考慮MED這個特性才可以進行比較。

2.4        優選過程總結
從以上選路方式可以看出,在選路過程中,人為干預的決策條件(如:Preferred-value)以及本自治系統內使用的管理屬性(如:Local_Preference)等條件都放在選路決策的前幾步,而隨機條件(如:Router ID和會話地址的決策)都在最後,目的是使路由優選的管理和控制更加方便,這樣可以在各自治系統內部按照統一的策略來管理和計算路由。

 

 

 

原文連結:http://www.h3c.com/cn/d_201010/922168_30005_0.htm