当Router A和Router B之间的链路出现故障时,Router A选择经过Router D到达Router C。
(1) 配置各接口的IP地址(略)
(2) 配置BFD和静态路由
# 在Router A上配置静态路由,并使能BFD检测功能,通过BFD echo报文方式实现BFD功能。
<RouterA> system-view
[RouterA] bfd echo-source-ip 123.1.1.1
[RouterA] interface ethernet 1/2
[RouterA-Ethernet1/2] bfd min-echo-receive-interval 300
[RouterA-Ethernet1/2] bfd detect-multiplier 7
[RouterA-Ethernet1/2] quit
[RouterA] ip route-static 120.1.1.1 24 ethernet 1/2 10.1.1.100 bfd echo-packet
[RouterA] ip route-static 13.1.1.2 24 ethernet 1/1 12.1.1.2 preference 65
[RouterA] quit
(3) 检查配置结果
# 显示Router A使能BFD信息。
<RouterA> display bfd Session
Total Session Num: 1 Init Mode: Active
Session Working Under Echo Mode:
LD SourceAddr DestAddr State Holdtime Interface
7 10.1.1.102 10.1.1.100 Up 1700ms Ethernet1/2
# 显示Router A路由表详细信息。
<RouterA> display ip routing-table protocol static
Public Routing Table : Static
Summary Count : 2
Static Routing table Status : <Active>
Summary Count : 1
Destination/Mask Proto Pre Cost NextHop Interface
120.1.1.1/24 Static 60 0 10.1.1.100 Ethernet1/2
Direct Routing table Status : <Inactive>
Summary Count : 1
Destination/Mask Proto Pre Cost NextHop Interface
13.1.1.2/24 Static 65 0 12.1.1.2 Ethernet1/1
# 在Router A上打开BFD功能调试信息开关。
<RouterA> debugging bfd event
<RouterA> debugging bfd scm
<RouterA> terminal debugging
# Router B和二层交换机之间链路发生故障时,可以看到Router A能够快速感知Router B的变化。
%Nov 12 19:28:28:592 2005 RouterA BFD/5/LOG:Sess[123.1.1.1/10.1.1.100, Eth1/2], Sta: UP->DOWN, Diag: 1
*0.53892593 RouterA BFD/8/SCM:Sess[123.1.1.1/10.1.1.100, Eth1/2], Oper: Reset
*0.53892593 RouterA BFD/8/EVENT:Send sess-down Msg, [Src:123.1.1.1, Dst:10.1.1.100, Eth1/2] Protocol: STATIC
*0.53892595 RouterA RM/7/LOG:static route [Dest:120.1.1.1/24,Nexthop:10.1.1.100,ExitIf:Eth1/2] became invalid
# 当Router A到Router B链路发生故障时,通过display ip routing-table protocol static命令查看路表信息。Router A选择经过Router D静态路由到达Router C。
<RouterA> display ip routing-table protocol static
Public Routing Table : Static
Summary Count : 2
Static Routing table Status : < Active>
Summary Count : 1
Destination/Mask Proto Pre Cost NextHop Interface
13.1.1.2/24 Static 65 0 12.1.1.2 Ethernet1/1
Static Routing table Status : < Inactive>
Summary Count : 1
Destination/Mask Proto Pre Cost NextHop Interface
120.1.1.1/24 Static 60 0 10.1.1.100 Ethernet1/2
在Router A上配置静态路由可以到达14.1.1.0/24网段路由,在Router B上配置静态路由可以到达13.1.1.0/24网段路由,并使能BFD检测功能;
当Router A和Router B链路出现故障时BFD能够快速感知。
(1) 配置BFD
# 配置Router A。
<RouterA> system-view
[RouterA] interface ethernet 1/1
[RouterA-Ethernet1/1] ip address 12.1.1.1 24
[RouterA-Ethernet1/1] bfd min-transmit-interval 500
[RouterA-Ethernet1/1] bfd min-receive-interval 500
[RouterA-Ethernet1/1] bfd detect-multiplier 9
[RouterA-Ethernet1/1] quit
[RouterA] ip route-static 14.1.1.0 24 ethernet 1/1 12.1.1.2 bfd control-packet
[RouterA] quit
# 配置Router B。
<RouterB> system-view
[RouterB] interface ethernet 1/1
[RouterB-Ethernet1/1] ip address 12.1.1.2 24
[RouterB-Ethernet1/1] bfd min-transmit-interval 500
[RouterB-Ethernet1/1] bfd min-receive-interval 500
[RouterB-Ethernet1/1] bfd detect-multiplier 9
[RouterB-Ethernet1/1] quit
[RouterB] ip route-static 13.1.1.0 24 ethernet 1/1 12.1.1.1 bfd control-packet
[RouterB] quit
(2) 检查配置结果
<RouterA> display bfd session
Total Session Num: 1 Init Mode: Active
Session Working Under Ctrl Mode:
LD/RD SourceAddr DestAddr State Holdtime Interface
4/7 12.1.1.1 12.1.1.2 Up 2000ms Ethernet1/1
# 在Router A上打开BFD功能调试信息开关。
<RouterA> debugging bfd event
<RouterA> debugging bfd scm
<RouterA> terminal debugging
# Router A和交换机之间链路发生故障时,可以看到Router A能够快速感知Router B的变化。
%Jul 27 10:18:18:672 2007 RouterA BFD/4/LOG:Sess[12.1.1.1/12.1.1.2, Ethernet1/1,Ctrl],
Sta: UP->DOWN, Diag: 1
*Jul 27 10:18:18:672 2007 RouterA BFD/7/EVENT:Send sess-down Msg, [Src:12.1.1.1,
Dst:12.1.1.2,Ethernet1/1,Ctrl], instance:0, protocol:STATIC
*Jul 27 10:18:19:172 2007 RouterA BFD/7/EVENT:Receive Delete-sess, [Src:12.1.1.1
,Dst:12.1.1.2,Ethernet1/1,Ctrl], Direct, Instance:0x0, Proto:STATIC
*Jul 27 10:18:19:172 2007 RouterA BFD/7/EVENT:Notify driver to stop receiving bf
单向检测与双向检测区别:
1)单向检测时没有建立BFD的连接,此时配置BFD的设备会发送目的地址为出接口源地址为指定地址的报文。对端又会将此报文根据直连路由转发发送回来。所以单向必须配置BFD的发送源地址(bfd echo-source-ip x.x.x.x此地址为任意地址)
2)双向检测则是建立了BFD的连接,所以BFD的源地址不用配置,建立连接的地址为双发静态路由的下一跳地址。如果一段没有配置以邻居为下一跳的静态路由,则连接没有建立,该静态路由失效。