某公司通过一台二层交换机作为中继将两个相距较远的部门连接。Device A、Device B、Device C上运行OSPF,建立OSPF邻居关系,保证网络层相互可达。
已知Device A和Device C都支持BFD功能,要求使用OSPF与BFD联动技术,采用BFD控制报文方式实现当Device A或Device C与二层交换机之间的链路出现故障(如链路down)时,BFD能够快速感知并通告OSPF协议。
现要求通过在Device A和Device C上配置OSPF与BFD联动功能,实现:
监测通过L2 Switch通信的链路;
当链路出现故障时设备能够快速感知并通告OSPF协议,快速切换到Device B链路进行通信。
Device A和Device C都支持BFD,可以使用BFD控制报文方式,通信双方至少要有一方运行在主动模式才能成功建立起BFD会话。
1.1.1 配置各接口的IP地址
(1) 配置Device A各接口的IP地址
system-view
[DeviceA] interface ten-gigabitethernet 3/0/1
[DeviceA-Ten-GigabitEthernet3/0/1] undo shutdown
[DeviceA-Ten-GigabitEthernet3/0/1] ip address 10.1.0.101 24
[DeviceA-Ten-GigabitEthernet3/0/1] quit
(2) 请参考以上方法配置图中其它接口的IP地址,配置步骤这里省略
1.1.2 配置OSPF基本功能
(1) 配置Device A
# 配置Device A的OSPF基本功能,并使能OSPF的BFD功能。
[DeviceA] ospf
[DeviceA-ospf-1] area 0
[DeviceA-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.0] network 120.1.1.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.0] quit
[DeviceA-ospf-1] quit
[DeviceA] interface ten-gigabitethernet 3/0/1
[DeviceA-Ten-GigabitEthernet3/0/1] ospf bfd enable
[DeviceA-Ten-GigabitEthernet3/0/1] quit
(2) 配置Device B
# 配置Device B的OSPF基本功能。
[DeviceB] ospf
[DeviceB-ospf-1] area 0
[DeviceB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] network 13.1.1.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] quit
[DeviceB-ospf-1] quit
(3) 配置Device C
# 配置Device C的OSPF基本功能,并使能OSPF的BFD功能。
[DeviceC] ospf
[DeviceC-ospf-1] area 0
[DeviceC-ospf-1-area-0.0.0.0] network 10.1.0.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.0] network 13.1.1.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.0] network 121.1.1.0 0.0.0.255
[DeviceC-ospf-1-area-0.0.0.0] quit
[DeviceC-ospf-1] quit
[DeviceC] interface vlan-interface 10
[DeviceC-Vlan-interface10] ospf bfd enable
[DeviceC-Vlan-interface10] quit
[DeviceC] interface ten-gigabitethernet 3/0/1
[DeviceC-Ten-GigabitEthernet3/0/1] ospf bfd enable
[DeviceC-Ten-GigabitEthernet3/0/1] quit
1.1.3 配置BFD功能
(1) 配置Device A
# 配置BFD会话建立前的运行模式为主动模式(缺省为主动模式)。
[DeviceA] bfd session init-mode active
# 配置发送和接收单跳BFD控制报文的最小时间间隔都为100ms,单跳BFD检测时间倍数为3。
[DeviceA] interface ten-gigabitethernet 3/0/1
[DeviceA-Ten-GigabitEthernet3/0/1] bfd min-transmit-interval 100
[DeviceA-Ten-GigabitEthernet3/0/1] bfd min-receive-interval 100
[DeviceA-Ten-GigabitEthernet3/0/1] bfd detect-multiplier 3
[DeviceA-Ten-GigabitEthernet3/0/1] quit
(2) 配置Device C
# 配置BFD会话建立前的运行模式为主动模式(缺省为主动模式)。
[DeviceC] bfd session init-mode active
# 配置发送和接收单跳BFD控制报文的最小时间间隔都为100ms,单跳BFD检测时间倍数为3。
[DeviceC] interface ten-gigabitethernet 3/0/1
[DeviceC-Ten-GigabitEthernet3/0/1] bfd min-transmit-interval 100
[DeviceC-Ten-GigabitEthernet3/0/1] bfd min-receive-interval 100
[DeviceC-Ten-GigabitEthernet3/0/1] bfd detect-multiplier 3
[DeviceC-Ten-GigabitEthernet3/0/1] quit
1.2 验证配置
# 检查Device A连接的主机host A(120.1.1.2)到Device C连接的主机host C(121.1.1.2)是否可达。
ping 121.1.1.2
PING 121.1.1.2 (121.1.1.2): 56 data bytes
56 bytes from 121.1.1.2: seq=0 ttl=128 time=22.43 ms
56 bytes from 121.1.1.2: seq=1 ttl=128 time=7.17 ms
56 bytes from 121.1.1.2: seq=2 ttl=128 time=8.91 ms
56 bytes from 121.1.1.2: seq=3 ttl=128 time=7.45 ms
56 bytes from 121.1.1.2: seq=4 ttl=128 time=9.11 ms
--- 121.1.1.2 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 7.17/11.01/22.43 ms
# 查看Device A 上OSPF邻居信息,显示Device A和Device C已建立OSPF邻居关系。
[DeviceA] display ospf peer verbose
OSPF Process 1 with Router ID 2.2.2.2
Neighbors
Area 0.0.0.0 interface 10.1.0.101(Vlan-interface10)'s neighbors
Router ID: 1.1.1.1 Address: 10.1.0.102 GR State: Normal
State: Full Mode: Nbr is Slave Priority: 1
DR: 10.1.0.101 BDR: 10.1.0.102 MTU: 0
Options is 0x42 (-|O|-|-|-|-|E|-)
Dead timer due in 39 sec
Neighbor is up for 00:09:01
Authentication Sequence: [ 0 ]
Neighbor state change count: 5
BFD status: Enabled(Control mode)
# BFD会话已被创建,且状态为UP。
[DeviceA] display bfd session verbose
Total session number: 1 Up session number: 1 Init mode: Active
IPv4 session working under Ctrl mode:
Local Discr: 10 Remote Discr: 1
Source IP: 10.1.0.101 Destination IP: 10.1.0.102
Session State: Up Interface: Ten-GigabitEthernet3/0/1
Min Trans Inter: 100ms Act Trans Inter: 1000ms
Min Recv Inter: 100ms Act Detect Inter: 5000ms
Rx Count: 3971 Tx Count: 3776
Connect Type: Direct Running Up for: 00:06:52
Hold Time: 214ms Auth mode: None
Detect Mode: Async Slot: 0
Protocol: OSPF
Diag Info: No Diagnostic
[DeviceC] display bfd session verbose
Total session number: 1 Up session number: 1 Init mode: Active
IPv4 session working under Ctrl mode:
Local Discr: 1 Remote Discr: 10
Source IP: 10.1.0.102 Destination IP: 10.1.0.101
Session State: Up Interface: Ten-GigabitEthernet3/0/1
Min Trans Inter: 100ms Act Trans Inter: 1000ms
Min Recv Inter: 100ms Act Detect Inter: 5000ms
Min Trans Inter: 100ms Act Trans Inter: 1000ms
Min Recv Inter: 100ms Act Detect Inter: 5000ms
Rx Count: 3971 Tx Count: 3776
Connect Type: Direct Running Up for: 00:06:52
Hold Time: 214ms Auth mode: None
Detect Mode: Async Slot: 0
Protocol: OSPF
Diag Info: No Diagnostic
在Device A上查看121.1.1.0/24的路由信息,可以看出Device A和Device C是通过L2 Switch进行通信的。
display ip routing-table 121.1.1.0 verbose
Summary Count : 1
Destination: 120.1.1.0/24
Protocol: OSPF Process ID: 1
SubProtID: 0x1 Age: 04h20m37s
Cost: 1 Preference: 10
Tag: 0 State: Active Adv
OrigTblID: 0x0 OrigVrf: default-vrf
TableID: 0x2 OrigAs: 0
NBRID: 0x26000002 LastAs: 0
AttrID: 0xffffffff Neighbor: 0.0.0.0
Flags: 0x1008c OrigNextHop: 10.1.0.102
Label: NULL RealNextHop: 10.1.0.102
BkLabel: NULL BkNextHop: N/A
Tunnel ID: Invalid Interface: GigabitEthernet3/0/1
BkTunnel ID: Invalid BkInterface: N/A
# 当Device C和二层交换机之间的链路状态变为Down,BFD快速检测到链路发生变化立刻通告OSPF。
%Apr 2 11:34:26:880 2014 DeviceA BFD/5/BFD_CHANGE_FSM: Sess[10.1.0.101/10.1.0.102,1026/1026
,Ten-GigabitEthernet3/0/1,Ctrl] , Sta: UP-> DOWN, Diag: 5
%Apr 2 11:34:27:011 2014 DeviceA OSPF/5/OSPF_NBR_CHG: OSPF 1 Neighbor 10.1.0.102 Ten-GigabitEthernet3/0/1) from Full to Down.
查看121.1.1.0/24的路由信息,可以看出Device A和Device C已经切换到Device B进行通信。
display ip routing-table 121.1.1.0 verbose
Summary Count : 1
Destination: 121.1.1.0/24
Protocol: OSPF Process ID: 1
SubProtID: 0x1 Age: 04h20m37s
Cost: 2 Preference: 10
Tag: 0 State: Active Adv
OrigTblID: 0x0 OrigVrf: default-vrf
TableID: 0x2 OrigAs: 0
NBRID: 0x26000002 LastAs: 0
AttrID: 0xffffffff Neighbor: 0.0.0.0
Flags: 0x1008c OrigNextHop: 192.168.0.102
Label: NULL RealNextHop: 192.168.0.102
BkLabel: NULL BkNextHop: N/A
Tunnel ID: Invalid Interface: GigabitEthernet3/0/2
BkTunnel ID: Invalid BkInterface: N/A