• 產品與解決方案
  • 行業解決方案
  • 服務
  • 支持
  • 合作夥伴
  • 關於我們

H3C S6890係列以太網交換機 典型配置舉例-Release 27xx係列-6W100

目錄

57-BGP路由屬性控製路由選擇配置舉例

本章節下載 57-BGP路由屬性控製路由選擇配置舉例  (204.90 KB)

57-BGP路由屬性控製路由選擇配置舉例

H3C S6890產品 BGP路由屬性控製路由選擇配置舉例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

資料版本:6W100-20190628

 

Copyright © 2019 bobty下载软件 版權所有,保留一切權利。

非經本公司書麵許可,任何單位和個人不得擅自摘抄、複製本文檔內容的部分或全部,並不得以任何形式傳播。

除bobty下载软件 的商標外,本手冊中出現的其它公司的商標、產品標識及商品名稱,由各自權利人擁有。

本文檔中的信息可能變動,恕不另行通知。



1  簡介

本文檔介紹使用通過BGP路由屬性控製路由選擇的配置舉例。

2  配置前提

本文檔中的配置均是在實驗室環境下進行的配置和驗證,配置前設備的所有參數均采用出廠時的缺省配置。如果您已經對設備進行了配置,為了保證配置效果,請確認現有配置和以下舉例中的配置不衝突。

本文檔假設您已了解BGP特性和路由策略特性。

3  通過AS-Path屬性控製路由選擇配置舉例

3.1  組網需求

圖1所示,所有設備均運行BGP協議。AS 100和AS 400之間有兩條路徑可以通信,這兩條路徑分別經過AS 200和AS 300。現要求通過配置路由策略,實現AS 100內的設備訪問AS 400始發的路由時,優先選擇從Device D轉發。

圖1 AS-Path屬性控製路由選擇配置組網圖

 

3.2  配置思路

·     為了使AS 100內的設備能夠根據路由的始發AS號來選擇優先轉發路徑,需要在AS 100的邊緣設備上為特定AS始發的路由提高優先級,並將該路由擴散至AS 100內部:在Device C上配置路由策略,將從AS 400始發的路由的本地優先級設置為300。

·     使用AS路徑過濾列表來匹配由指定AS始發的路由。

3.3  使用版本

本舉例是在S6890-CMW710-R2712版本上進行配置和驗證的。

3.4  配置注意事項

缺省情況下,S6890係列交換機的接口處於ADM(Administratively Down)狀態,請根據實際需要在對應接口視圖下使用undo shutdown命令開啟接口。

3.5  配置步驟

3.5.1  配置各接口的IP地址

# 配置接口Vlan-interface 12的IP地址。

<DeviceA> system-view

[DeviceA] interface Vlan-interface 12

[DeviceA-Vlan-interface12] ip address 12.12.12.1 24

[DeviceA-Vlan-interface12] quit

# 請參考以上方法配置其它相關接口的IP地址,配置步驟這裏省略。

3.5.2  配置BGP連接

# 在Device A上創建本地AS號為100的BGP實例,指定對等體12.12.12.2和13.13.13.3。

[DeviceA] bgp 100

[DeviceA-bgp-default] router-id 1.1.1.1

[DeviceA-bgp-default] peer 12.12.12.2 as-number 100

[DeviceA-bgp-default] peer 13.13.13.3 as-number 100

[DeviceA-bgp-default] address-family ipv4 unicast

[DeviceA-bgp-default-ipv4] peer 12.12.12.2 enable

[DeviceA-bgp-default-ipv4] peer 13.13.13.3 enable

[DeviceA-bgp-default-ipv4] quit

[DeviceA-bgp-default] quit

# 在Device B上創建本地AS號為100的BGP實例,指定對等體12.12.12.1和24.24.24.4,並引入直連路由。

[DeviceB] bgp 100

[DeviceB-bgp-default] router-id 2.2.2.2

[DeviceB-bgp-default] peer 12.12.12.1 as-number 100

[DeviceB-bgp-default] peer 24.24.24.4 as-number 200

[DeviceB-bgp-default] address-family ipv4 unicast

[DeviceB-bgp-default-ipv4] peer 12.12.12.1 enable

[DeviceB-bgp-default-ipv4] peer 24.24.24.4 enable

[DeviceB-bgp-default-ipv4] import-route direct

[DeviceB-bgp-default-ipv4] quit

[DeviceB-bgp-default] quit

# 在Device C上創建本地AS號為100的BGP實例,指定對等體13.13.13.1和35.35.35.5,並引入直連路由。

[DeviceC] bgp 100

[DeviceC-bgp-default] router-id 3.3.3.3

[DeviceC-bgp-default] peer 13.13.13.1 as-number 100

[DeviceC-bgp-default] peer 35.35.35.5 as-number 300

[DeviceC-bgp-default] address-family ipv4 unicast

[DeviceC-bgp-default-ipv4] peer 13.13.13.1 enable

[DeviceC-bgp-default-ipv4] peer 35.35.35.5 enable

[DeviceC-bgp-default-ipv4] import-route direct

[DeviceC-bgp-default-ipv4] quit

[DeviceC-bgp-default] quit

# 在Device D上創建本地AS號為200的BGP實例,指定對等體24.24.24.2和46.46.46.6,並發布路由4.4.4.4/32。

[DeviceD] bgp 200

[DeviceD-bgp-default] router-id 4.4.4.4

[DeviceD-bgp-default] peer 24.24.24.2 as-number 100

[DeviceD-bgp-default] peer 46.46.46.6 as-number 400

[DeviceD-bgp-default] address-family ipv4 unicast

[DeviceD-bgp-default-ipv4] peer 24.24.24.2 enable

[DeviceD-bgp-default-ipv4] peer 46.46.46.6 enable

[DeviceD-bgp-default-ipv4] network 4.4.4.4 32

[DeviceD-bgp-default-ipv4] quit

[DeviceD-bgp-default] quit

# 在Device E上創建本地AS號為300的BGP實例,指定對等體35.35.35.3和56.56.56.6,並發布路由5.5.5.5/32。

[DeviceE] bgp 300

[DeviceE-bgp-default] router-id 5.5.5.5

[DeviceE-bgp-default] peer 35.35.35.3 as-number 100

[DeviceE-bgp-default] peer 56.56.56.6 as-number 400

[DeviceE-bgp-default] address-family ipv4 unicast

[DeviceE-bgp-default-ipv4] peer 35.35.35.3 enable

[DeviceE-bgp-default-ipv4] peer 56.56.56.6 enable

[DeviceE-bgp-default-ipv4] network 5.5.5.5 32

[DeviceE-bgp-default-ipv4] quit

[DeviceE-bgp-default] quit

# 在Device F上創建本地AS號為400的BGP實例,指定對等體46.46.46.4和56.56.56.5,並發布路由6.6.6.6/32。

[DeviceF] bgp 400

[DeviceF-bgp-default] router-id 6.6.6.6

[DeviceF-bgp-default] peer 46.46.46.4 as-number 200

[DeviceF-bgp-default] peer 56.56.56.5 as-number 300

[DeviceF-bgp-default] address-family ipv4 unicast

[DeviceF-bgp-default-ipv4] peer 46.46.46.4 enable

[DeviceF-bgp-default-ipv4] peer 56.56.56.5 enable

[DeviceF-bgp-default-ipv4] network 6.6.6.6 32

[DeviceF-bgp-default-ipv4] quit

[DeviceF-bgp-default] quit

# 完成以上配置後,在Device A上查看BGP路由表,可以看到Device D、Device E和Device F發布的路由及其AS-Path屬性。

[DeviceA] display bgp routing-table ipv4

 

Total number of routes: 12

 

 BGP local router ID is 1.1.1.1

 Status codes: * - valid, > - best, d - dampened, h - history

               s - suppressed, S - stale, i - internal, e – external

               a - additional-path

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

 

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 

* >i 2.2.2.2/32         12.12.12.2      0          100        0       ?

* >i 3.3.3.3/32         13.13.13.3      0          100        0       ?

* >i 4.4.4.4/32         24.24.24.4      0          100        0       200i

*  i                    35.35.35.5                 100        0       300 400

                                                                      200i

* >i 5.5.5.5/32         35.35.35.5      0          100        0       300i

*  i                    24.24.24.4                 100        0       200 400

                                                                      300i

* >i 6.6.6.6/32         24.24.24.4                 100        0       200 400i

*  i                    35.35.35.5                 100        0       300 400i

* >i 12.12.12.0/24      12.12.12.2      0          100        0       ?

* >i 13.13.13.0/24      13.13.13.3      0          100        0       ?

* >i 24.24.24.0/24      12.12.12.2      0          100        0       ?

* >i 35.35.35.0/24      13.13.13.3      0          100        0       ?

3.5.3  配置路由策略

# 在Device C上創建路由策略aspath,將AS-Path以400結尾的路由的本地優先級設置為300。

[DeviceC] ip as-path 1 permit 400$

[DeviceC] route-policy aspath permit node 20

[DeviceC-route-policy-aspath-20] if-match as-path 1

[DeviceC-route-policy-aspath-20] apply local-preference 300

[DeviceC-route-policy-aspath-20] quit

[DeviceC] route-policy aspath permit node 25

# 在Device C上配置對從對等體35.35.35.5接收的路由應用路由策略aspath。

[DeviceC] bgp 100

[DeviceC-bgp-default] address-family ipv4

[DeviceC-bgp-default-ipv4] peer 35.35.35.5 route-policy aspath import

3.6  驗證配置

# 在Device A上再次查看BGP路由表,可以看到到達AS 400路由的下一跳發生變化。

[DeviceA] display bgp routing-table ipv4

 

Total number of routes: 11

 

 BGP local router ID is 1.1.1.1

 Status codes: * - valid, > - best, d - dampened, h - history

               s - suppressed, S - stale, i - internal, e – external

               a - additional-path

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

 

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 

* >i 2.2.2.2/32         12.12.12.2      0          100        0       ?

* >i 3.3.3.3/32         13.13.13.3      0          100        0       ?

* >i 4.4.4.4/32         24.24.24.4      0          100        0       200i

*  i                    35.35.35.5                 100        0       300 400

                                                                      200i

* >i 5.5.5.5/32         35.35.35.5      0          100        0       300i

*  i                    24.24.24.4                 100        0       200 400

                                                                      300i

* >i 6.6.6.6/32         35.35.35.5                 300        0       300 400i

*  i                    24.24.24.4                 100        0       200 400i

* >i 12.12.12.0/24      12.12.12.2      0          100        0       ?

* >i 13.13.13.0/24      13.13.13.3      0          100        0       ?

* >i 24.24.24.0/24      12.12.12.2      0          100        0       ?

* >i 35.35.35.0/24      13.13.13.3      0          100        0       ?

# 從Device A查看到達6.6.6.6的報文所經過的路徑。可以看出,報文通過Device D轉發。

[DeviceA] tracert 6.6.6.6

traceroute to 6.6.6.6 (6.6.6.6), 30 hops at most, 52 bytes each packet, press CT

RL_C to break

 1  12.12.12.2 (12.12.12.2)  2.417 ms  1.887 ms  1.773 ms

 2  35.35.35.5 (35.35.35.5)  4.057 ms  2.293 ms  2.739 ms

 3  6.6.6.6 (6.6.6.6)  5.145 ms  4.205 ms  4.402 ms

3.7  配置文件

·     Device A:

#

vlan 12

#

vlan 13

#

interface LoopBack0

 ip address 1.1.1.1 255.255.255.255

#

interface Vlan-interface12

 ip address 12.12.12.1 255.255.255.0

#

interface Vlan-interface13

 ip address 13.13.13.1 255.255.255.0

#

bgp 100

 router-id 1.1.1.1

 peer 12.12.12.2 as-number 100

 peer 13.13.13.3 as-number 100

 #

 address-family ipv4 unicast

  peer 12.12.12.2 enable

  peer 13.13.13.3 enable

#

·     Device B:

#

vlan 12

#

vlan 24

#

interface LoopBack0

 ip address 2.2.2.2 255.255.255.255

#

interface Vlan-interface12

 ip address 12.12.12.2 255.255.255.0

#

interface Vlan-interface24

 ip address 24 24.24.2 255.255.255.0

#

bgp 100

 router-id 2.2.2.2

 peer 12.12.12.1 as-number 100

 peer 24.24.24.4 as-number 200

 #

 address-family ipv4 unicast

  import-route direct

  peer 12.12.12.1 enable

  peer 24.24.24.4 enable

#

·     Device C:

#

vlan 13

#

vlan 35

#

interface LoopBack0

 ip address 3.3.3.3 255.255.255.255

#

interface Vlan-interface13

 ip address 13.13.13.3 255.255.255.0

#

interface Vlan-interface35

 ip address 35.35.35.3 255.255.255.0

#

bgp 100

 router-id 3.3.3.3

 peer 13.13.13.1 as-number 100

 peer 35.35.35.5 as-number 300

 #

 address-family ipv4 unicast

  import-route direct

  peer 13.13.13.1 enable

  peer 35.35.35.5 enable

  peer 35.35.35.5 route-policy aspath import

#

route-policy aspath permit node 20

 if-match as-path 1

 apply local-preference 300

route-policy aspath permit node 25

#

 ip as-path 1 permit 400$

#

·     Device D:

#

vlan 24

#

vlan 46

#

interface LoopBack0

 ip address 4.4.4.4 255.255.255.255

#

interface Vlan-interface24

 ip address 24.24.24.4 255.255.255.0

#

interface Vlan-interface46

 ip address 46.46.46.4 255.255.255.0

#

bgp 200

 router-id 4.4.4.4

 peer 24.24.24.2 as-number 100

 peer 46.46.46.6 as-number 400

 #

 address-family ipv4 unicast

  network 4.4.4.4 255.255.255.255

  peer 24.24.24.2 enable

  peer 46.46.46.6 enable

#

·     Device E:

#

vlan 35

#

vlan 56

#

interface LoopBack0

 ip address 5.5.5.5 255.255.255.255

#

interface Vlan-interface35

 ip address 35.35.35.5 255.255.255.0

#

interface Vlan-interface56

 ip address 56.56.56.5 255.255.255.0

#

bgp 300

 router-id 5.5.5.5

 peer 35.35.35.3 as-number 100

 peer 56.56.56.6 as-number 400

 #

 address-family ipv4 unicast

  network 5.5.5.5 255.255.255.255

  peer 35.35.35.3 enable

  peer 56.56.56.6 enable

#

·     Device F:

#

vlan 46

#

vlan 56

#

interface LoopBack0

 ip address 6.6.6.6 255.255.255.255

#

interface Vlan-interface46

 ip address 46.46.46.6 255.255.255.0

#

interface Vlan-interface56

 ip address 56.56.56.6 255.255.255.0

#

bgp 400

 router-id 6.6.6.6

 peer 46.46.46.4 as-number 200

 peer 56.56.56.5 as-number 300

 #

 address-family ipv4 unicast

  network 6.6.6.6 255.255.255.255

  peer 46.46.46.4 enable

  peer 56.56.56.5 enable

#

4  通過MED屬性控製路由選擇配置舉例

4.1  組網需求

圖2所示,所有設備均運行BGP協議。Device A與Device B、Device C之間運行EBGP,Device B、Device C之間運行IBGP。由於Device B的Router ID小於Device C的Router ID,所以當AS 100訪問AS 200時,流量優先選擇從Device B轉發。現要求通過配置路由策略,實現AS 100訪問AS 200的流量優先選擇通過Device C轉發。

圖2 MED屬性控製路由選擇配置組網圖

 

4.2  配置思路

為了實現AS 100訪問AS 200的流量優先選擇通過Device C轉發,需要通過路由策略修改Device B發送給Device A的MED值,使其大於缺省MED值0。

4.3  使用版本

本舉例是在S6890-CMW710-R2712版本上進行配置和驗證的。

4.4  配置注意事項

缺省情況下,S6890係列交換機的接口處於ADM(Administratively Down)狀態,請根據實際需要在對應接口視圖下使用undo shutdown命令開啟接口。

4.5  配置步驟

4.5.1  基礎配置

# 配置接口Vlan-interface 12的IP地址。

<DeviceA> system-view

[DeviceA] interface Vlan-interface 12

[DeviceA-Vlan-interface12] ip address 12.12.12.1 24

[DeviceA-Vlan-interface12] quit

# 請參考以上方法配置其它相關接口的IP地址,配置步驟這裏省略。

# 在Device A上創建本地AS號為100的BGP實例,指定對等體12.12.12.2和13.13.13.3。

[DeviceA] bgp 100

[DeviceA-bgp-default] router-id 1.1.1.1

[DeviceA-bgp-default] peer 12.12.12.2 as-number 200

[DeviceA-bgp-default] peer 13.13.13.3 as-number 200

[DeviceA-bgp-default] address-family ipv4 unicast

[DeviceA-bgp-default-ipv4] peer 12.12.12.2 enable

[DeviceA-bgp-default-ipv4] peer 13.13.13.3 enable

[DeviceA-bgp-default-ipv4] quit

[DeviceA-bgp-default] quit

# 在Device B上創建本地AS號為200的BGP實例,指定對等體12.12.12.1和3.3.3.3。

[DeviceB] bgp 200

[DeviceB-bgp-default] router-id 2.2.2.2

[DeviceB-bgp-default] peer 12.12.12.1 as-number 100

[DeviceB-bgp-default] peer 3.3.3.3 as-number 200

[DeviceB-bgp-default] peer 3.3.3.3 connect-interface LoopBack0

[DeviceB-bgp-default] address-family ipv4 unicast

[DeviceB-bgp-default-ipv4] peer 12.12.12.1 enable

[DeviceB-bgp-default-ipv4] peer 3.3.3.3 enable

[DeviceB-bgp-default-ipv4] network 23.23.23.0 24

[DeviceB-bgp-default-ipv4] quit

[DeviceB-bgp-default] quit

# 在Device B上配置目的地址為3.3.3.3/32的靜態路由,以保證對等體3.3.3.3可達。

[DeviceB] ip route-static 3.3.3.3 32 23.23.23.3

# 在Device C上創建本地AS號為200的BGP實例,指定對等體13.13.13.1和2.2.2.2。

[DeviceC] bgp 200

[DeviceC-bgp-default] router-id 3.3.3.3

[DeviceC-bgp-default] peer 13.13.13.1 as-number 100

[DeviceC-bgp-default] peer 2.2.2.2 as-number 200

[DeviceC-bgp-default] peer 2.2.2.2 connect-interface LoopBack0

[DeviceC-bgp-default] address-family ipv4 unicast

[DeviceC-bgp-default-ipv4] peer 13.13.13.1 enable

[DeviceC-bgp-default-ipv4] peer 2.2.2.2 enable

[DeviceC-bgp-default-ipv4] network 23.23.23.0 24

[DeviceC-bgp-default-ipv4] quit

[DeviceC-bgp-default] quit

# 在Device C上配置目的地址為2.2.2.2/32的靜態路由,以保證對等體2.2.2.2可達。

[DeviceC] ip route-static 2.2.2.2 32 23.23.23.2

# 完成以上配置後,在Device A上查看BGP路由表,可以看到前往23.23.23.0/24網段的兩條有效路由,其中下一跳為12.12.12.2的路由為最優路由,這是由於Device B的Router ID較小。

[DeviceA] display bgp routing-table ipv4

 

 Total number of routes: 2

 

 BGP local router ID is 1.1.1.1

 Status codes: * - valid, > - best, d - dampened, h - history

               s - suppressed, S - stale, i - internal, e – external

               a - additional-path

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

 

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 

* >e 23.23.23.0/24      12.12.12.2      0                     0       200i

*  e                    13.13.13.3      0                     0       200i

4.5.2  配置路由策略

# 在Device B上創建路由策略10,將路由開銷修改為100。

[DeviceB] route-policy 10 permit node 10

[DeviceB-route-policy-10-10] apply cost 100

[DeviceB-route-policy-10-10] quit

# 在Device B上配置對向對等體12.12.12.1發送的路由應用路由策略10,即修改Device B發送給Device A的MED值為100。

[DeviceB] bgp 200

[DeviceB-bgp-default] address-family ipv4 unicast

[DeviceB-bgp-default-ipv4] peer 12.12.12.1 route-policy 10 export

[DeviceB-bgp-default-ipv4] quit

[DeviceB-bgp-default] quit

4.6  驗證配置

# 查看Device A的BGP路由表,可以看到下一跳為12.12.12.2的路由的MED值變為100,下一跳為13.13.13.3的路由成為了最優路由。

[DeviceA] display bgp routing-table ipv4

 

 Total number of routes: 2

 

 BGP local router ID is 1.1.1.1

 Status codes: * - valid, > - best, d - dampened, h - history

               s - suppressed, S - stale, i - internal, e – external

               a - additional-path

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

 

     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn

 

* >e 23.23.23.0/24      13.13.13.3      0                     0       200i

*  e                    12.12.12.2      100                   0       200i

4.7  配置文件

·     Device A:

#

vlan 12

#

vlan 13

#

interface LoopBack0

 ip address 1.1.1.1 255.255.255.255

#

interface Vlan-interface12

 ip address 12.12.12.1 255.255.255.0

#

interface Vlan-interface13

 ip address 13.13.13.1 255.255.255.0

#

bgp 100

 router-id 1.1.1.1

 peer 12.12.12.2 as-number 200

 peer 13.13.13.3 as-number 200

 #

 address-family ipv4 unicast

  peer 12.12.12.2 enable

  peer 13.13.13.3 enable

#

·     Device B:

#

vlan 12

#

vlan 23

#

interface LoopBack0

 ip address 2.2.2.2 255.255.255.255

#

interface Vlan-interface12

 ip address 12.12.12.2 255.255.255.0

#

interface Vlan-interface23

 ip address 23.23.23.2 255.255.255.0

#

bgp 200

 router-id 2.2.2.2

 peer 3.3.3.3 as-number 200

 peer 3.3.3.3 connect-interface LoopBack0

 peer 12.12.12.1 as-number 100

 #

 address-family ipv4 unicast

  network 23.23.23.0 255.255.255.0

  peer 3.3.3.3 enable

  peer 12.12.12.1 enable

  peer 12.12.12.1 route-policy 10 export

#

route-policy 10 permit node 10

 apply cost 100

#

 ip route-static 3.3.3.3 32 23.23.23.3

#

·     Device C:

#

vlan 13

#

vlan 23

#

interface LoopBack0

 ip address 3.3.3.3 255.255.255.255

#

interface Vlan-interface13

 ip address 13.13.13.3 255.255.255.0

#

interface Vlan-interface23

 ip address 23.23.23.3 255.255.255.0

#

bgp 200

 router-id 3.3.3.3

 peer 2.2.2.2 as-number 200

 peer 2.2.2.2 connect-interface LoopBack0

 peer 13.13.13.1 as-number 100

 #

 address-family ipv4 unicast

  network 23.23.23.0 255.255.255.0

  peer 2.2.2.2 enable

  peer 13.13.13.1 enable

#

 ip route-static 2.2.2.2 32 23.23.23.2

#

5  相關資料

·     H3C S6890係列交換機 三層技術-IP路由配置指導(R27xx)

·     H3C S6890係列交換機 三層技術-IP路由命令參考(R27xx)

不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!

BOB登陆
官網
聯係我們