配置OSPF與BFD聯動

組網圖形

    

OSPF與BFD聯動簡介

  • 雙向轉發檢測BFD(Bidirectional Forwarding Detection)是一種用於檢測轉發引擎之間通訊故障的檢測機制。BFD對兩個系統間的、同一路徑上的同一種數據協議的連通性進行檢測,這條路徑可以是物理鏈路或邏輯鏈路。OSPF與BFD聯動就是將BFD和OSPF協議關聯起來,將BFD對鏈路故障的快速感應通知OSPF協議,從而加快OSPF協議對於網路拓撲變化的響應。
  • 網路上的鏈路故障或拓撲變化都會導致設備重新進行路由計算,如果僅依靠OSPF協議本身的檢測機制,那麼路由的重新計算時間就是協議本身收斂的時間,這種情況下協議感知到故障所需時間為秒級。然而對於高速數據傳輸,例如吉比特速率級,超過1秒的檢測時間將導致大量數據丟失;對於時延敏感的業務,例如語音業務,超過1秒的延遲是不能接受的。當OSPF網路對可靠性要求較高,或者所承載的業務對時延比較敏感時,可以考慮配置OSPF與BFD聯動,這樣一旦鄰居之間的鏈路出現故障,BFD的快速性能夠加快OSPF的收斂速度,達到毫秒級的故障檢測。

 組網需求

  • 如圖1所示,SwitchA、SwitchB和SwitchC之間運行OSPF,SwitchA和SwitchB之間的交換機僅作透傳功能。現在需要SwitchA和SwitchB能快速感應它們之間的鏈路狀態,當鏈路SwitchA-SwitchB發生故障時,業務能快速切換到備份鏈路SwitchA-SwitchC-SwitchB上。
說明:
    BFD報文雙向檢測,需要建立OSPF鄰居的兩端設備均進行BFD配置。
    創建BFD會話的通訊雙方必須處於同一個OSPF區域的同一網段。
    ospf bfd enable命令和ospf bfd block命令是兩條互斥命令,不能同時使能。

配置思路

  • 1.在SwitchA、SwitchB和SwitchC上配置OSPF基本功能,實現整個OSPF網路的互通。
  • 2.在SwitchA、SwitchB和SwitchC上配置OSPF與BFD聯動功能,實現當SwitchA和SwitchB之間的鏈路出現故障時快速的切換到備份鏈路。

操作步驟

  • 1.配置各介面所屬的VLAN

  # 配置SwitchA。SwitchB和SwitchC的配置與SwitchA類似,不再贅述。

<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 30
[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] port link-type trunk
[SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet1/0/1] quit
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] port link-type trunk
[SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 30
[SwitchA-GigabitEthernet1/0/2] quit
  •  2.配置各VLANIF介面的IP地址

  # 配置SwitchA。SwitchB和SwitchC的配置與SwitchA類似,不再贅述。

[SwitchA] interface vlanif 10
[SwitchA-Vlanif10] ip address 10.1.1.1 24
[SwitchA-Vlanif10] quit
[SwitchA] interface vlanif 30
[SwitchA-Vlanif30] ip address 10.3.3.1 24
[SwitchA-Vlanif30] quit
  •  3.配置OSPF基本功能

  # 配置SwitchA。

[SwitchA] ospf 1 router-id 10.10.10.1
[SwitchA-ospf-1] area 0
[SwitchA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] network 10.3.3.0 0.0.0.255
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] quit

   # 配置SwitchB。

[SwitchB] ospf 1 router-id 10.10.10.2
[SwitchB-ospf-1] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 10.2.2.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] network 10.3.3.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] quit
[SwitchB-ospf-1] quit

   # 配置SwitchC。

[SwitchC] ospf 1 router-id 10.10.10.3
[SwitchC-ospf-1] area 0
[SwitchC-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] network 10.2.2.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] quit
[SwitchC-ospf-1] quit

   # 配置完成後,執行命令display ospf peer,可以看到SwitchA,SwitchB和SwitchC之間互相建立了鄰接關係。以SwitchA的顯示結果為例。

[SwitchA] display ospf peer

          OSPF Process 1 with Router ID 10.10.10.1
                  Neighbors

 Area 0.0.0.0 interface 10.1.1.1(Vlanif10)'s neighbors
 Router ID: 10.10.10.3       Address: 10.1.1.2          
   State: Full  Mode:Nbr is  Master  Priority: 1
   DR: 10.1.1.2  BDR: 10.1.1.1  MTU: 0
   Dead timer due in 38  sec
   Retrans timer interval: 5
   Neighbor is up for 00:00:15
   Authentication Sequence: [ 0 ]

                  Neighbors

 Area 0.0.0.0 interface 10.3.3.1(Vlanif30)'s neighbors
 Router ID: 10.10.10.2       Address: 10.3.3.2
   State: Full  Mode:Nbr is   Master  Priority: 1
   DR: 10.3.3.2  BDR: 10.3.3.1  MTU: 0
   Dead timer due in 25  sec
   Retrans timer interval: 5
   Neighbor is up for 00:00:59
   Authentication Sequence: [ 0 ]

   # 查看SwitchA的OSPF路由表的資訊,可以看到去往SwitchB和SwitchC的路由表項。而去往目的網段172.16.1.0/24的路由下一跳地址為10.3.3.2,說明流量在鏈路SwitchA→SwitchB上傳輸。

[SwitchA] display ospf routing

          OSPF Process 1 with Router ID 10.10.10.1
                   Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 10.1.1.0/24        1     Transit    10.1.1.1        10.10.10.1      0.0.0.0
 10.3.3.0/24        1     Transit    10.3.3.1        10.10.10.1      0.0.0.0
 10.2.2.0/24        2     Transit    10.1.1.2        10.10.10.3      0.0.0.0
 10.2.2.0/24        2     Transit    10.3.3.2        10.10.10.3      0.0.0.0
 172.16.1.0/24      2     Stub       10.3.3.2        10.10.10.2      0.0.0.0

 Total Nets: 5
 Intra Area: 5  Inter Area: 0  ASE: 0  NSSA: 0
  •  4.配置OSPF與BFD聯動

  # 在SwitchA上配置OSPF與BFD聯動功能。

[SwitchA] bfd   //全局使能BFD功能
[SwitchA-bfd] quit
[SwitchA] ospf 1
[SwitchA-ospf-1] bfd all-interfaces enable   //在OSPF進程下使能BFD特性
[SwitchA-ospf-1] quit

   # 在SwitchB上配置OSPF與BFD聯動功能。

[SwitchB] bfd   //全局使能BFD功能
[SwitchB-bfd] quit
[SwitchB] ospf 1
[SwitchB-ospf-1] bfd all-interfaces enable   //在OSPF進程下使能BFD特性
[SwitchB-ospf-1] quit

   # 在SwitchC上配置OSPF與BFD聯動功能。

[SwitchC] bfd   //全局使能BFD功能
[SwitchC-bfd] quit
[SwitchC] ospf 1
[SwitchC-ospf-1] bfd all-interfaces enable   //在OSPF進程下使能BFD特性
[SwitchC-ospf-1] quit

   # 配置完成後,在SwitchA或SwitchB、SwitchC上執行display ospf bfd session all命令,可以看到BFD會話的狀態為Up。以SwitchA的顯示為例。

[SwitchA] display ospf bfd session all

          OSPF Process 1 with Router ID 10.10.10.1
  Area 0.0.0.0 interface 10.1.1.1(Vlanif10)'s BFD Sessions

 NeighborId:10.10.10.3       AreaId:0.0.0.0          Interface:Vlanif10
 BFDState:up                 rx    :1000             tx       :1000
 Multiplier:3                BFD Local Dis:8195      LocalIpAdd:10.1.1.1
 RemoteIpAdd:10.1.1.2        Diagnostic Info:No diagnostic information

  Area 0.0.0.0 interface 10.3.3.1(Vlanif30)'s BFD Sessions

 NeighborId:10.10.10.2       AreaId:0.0.0.0          Interface:Vlanif30
 BFDState:up                 rx    :1000             tx       :1000
 Multiplier:3                BFD Local Dis:8194      LocalIpAdd:10.3.3.1
 RemoteIpAdd:10.3.3.2         Diagnostic Info:No diagnostic information
  •  5.檢查配置結果

  # 對SwitchB的GE1/0/1介面執行shutdown命令,模擬鏈路故障。

[SwitchB] interface gigabitethernet 1/0/1
[SwitchB-GigabitEthernet1/0/1] shutdown

   # 在SwitchA上查看OSPF路由表。

[SwitchA] display ospf routing

          OSPF Process 1 with Router ID 10.10.10.1
                   Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 10.1.1.0/24        1     Transit    10.1.1.1        10.10.10.1      0.0.0.0
 10.2.2.0/24        2     Transit    10.1.1.2        10.10.10.3      0.0.0.0
 172.16.1.0/24      3     Stub       10.1.1.2        10.10.10.2      0.0.0.0

 Total Nets: 3
 Intra Area: 3  Inter Area: 0  ASE: 0  NSSA: 0

   可以看出在鏈路SwitchA-SwitchB出現故障後,備份鏈路SwitchA-SwitchC-SwitchB開始生效,即去往目的網段172.16.1.0/24的路由下一跳地址變成了10.1.1.2。