组网需求
如图一所示,switchA、switchB和switchC之间运行OSPF,switchA和switchB之间的交换仅
作透传功能,现在需要switchA和switchB能快速感应他们之间的链路状态,当链路switchA-switchB
发送故障时,业务能快速切换到备份链路SWitchA-switchC-switchB上
采用如下思路配置OSPF与BFD联动:
操作步骤
1、配置各接口所属的VLAN
SW1的配置,剩下两台类似配置
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10
[SW1-GigabitEthernet0/0/1]quit
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type trunk
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 30
2.配置各vlanif接口的IP地址
配置SW1、SW2和SW3的配置与SW1类似
[SW1]interface Vlanif 10
[SW1-Vlanif10]ip address 10.0.13.1 24
[SW1-Vlanif10]quit
[SW1]interface Vlanif 30
[SW1-Vlanif30]ip address 10.0.12.1 24
3.配置ospf基本功能
配置SW1
[SW1]ospf 1 router-id 1.1.1.1
[SW1-ospf-1]area 0
[SW1-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[SW1-ospf-1-area-0.0.0.0]quit
配置SW2
[SW2]ospf 1 router-id 2.2.2.2
[SW2-ospf-1]area 0
[SW2-ospf-1-area-0.0.0.0]network 10.0.23.0 0.0.0.255
[SW2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[SW2-ospf-1-area-0.0.0.0]quit
[SW2-ospf-1]quit
配置SW3
[SW3]ospf 1 router-id 3.3.3.3
[SW3-ospf-1]area
[SW3-ospf-1]area 0
[SW3-ospf-1-area-0.0.0.0]net
[SW3-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255
[SW3-ospf-1-area-0.0.0.0]net
[SW3-ospf-1-area-0.0.0.0]network 10.0.23.0 0.0.0.255
[SW3-ospf-1-area-0.0.0.0]quit
[SW3-ospf-1]quit
配置完成后,执行命令display ospf peer,可以看到SW1、SW2和SW3之间互相建立了邻接关系,以SW1的显示结果为例
[SW1]display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
Neighbors
Area 0.0.0.0 interface 10.0.13.1(Vlanif10)'s neighbors
Router ID: 3.3.3.3 Address: 10.0.13.3
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0
Dead timer due in 37 sec
Retrans timer interval: 5
Neighbor is up for 00:01:05
Authentication Sequence: [ 0 ]
[SW1]
# 查看SW1的OSPF路由表的信息,可以看到去往SW2和SW3的路由表选项,而去往目的网段172.16.1.0/24的路由下一跳地址为10.0.12.2,说明流量在链路SW1——SW2上传输
[SW1]display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.12.0/24 1 Transit 10.0.12.1 1.1.1.1 0.0.0.0
10.0.13.0/24 1 Transit 10.0.13.1 1.1.1.1 0.0.0.0
10.0.23.0/24 2 Stub 10.0.13.3 3.3.3.3 0.0.0.0
10.0.23.0/24 2 Stub 10.0.12.2 2.2.2.2 0.0.0.0
Total Nets: 4
Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0
[SW1]
(4)配置ospf与BFD联动
在SW1上配置OSPF与BFD联动
[SW1]bfd
[SW1-bfd]quit
[SW1]ospf 1
[SW1-ospf-1]bfd all-interfaces enable
[SW1-ospf-1]quit
[SW1]
在SW2上配置OSPF与BFD联动
[SW2]bfd
[SW2-bfd]quit
[SW2]ospf 1
[SW2-ospf-1]bfd all-interfaces enable
[SW2-ospf-1]quit
[SW2]
在SW3上也配置
[SW3]bfd
[SW3-bfd]quit
[SW3]ospf 1
[SW3-ospf-1]bfd all-interfaces enable
[SW3-ospf-1]
#配置完成后在SW1上或SW2、SW3上执行display ospf bfd session all命令可以看到状态为up
[SW1]display ospf bfd session all
NeighborId:2.2.2.2 AreaId:0.0.0.0 Interface:Vlanif30
BFDState:up 状态 rx :1000 tx :1000
Multiplier:3 BFD Local Dis:8192 LocalIpAdd:10.0.12.1
RemoteIpAdd:10.0.12.2 Diagnostic Info:No diagnostic information
[SW1]
(5)检验配置结果
在对SW2的g0/0/2接口执行shutdown命令模块链路故障
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2]shutdown
[SW2-GigabitEthernet0/0/2]
在SW1中查看路由表
SW1]display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.12.0/24 1 Stub 10.0.12.1 1.1.1.1 0.0.0.0
10.0.13.0/24 1 Transit 10.0.13.1 1.1.1.1 0.0.0.0
10.0.23.0/24 2 Transit 10.0.13.3 2.2.2.2 0.0.0.0