实验目标
配置BFD实现对设备间链路故障的快速检测,通过BFD与OSPF协议联动、静态路由联动来测试验证链路可靠性。测试环境用到LSW1、LSW2、LSW6(傻瓜交换机)、LSW7(傻瓜交换机)、AR1、AR2、PC2、PC3。配置好基本网络地址及路由协议。
实验拓扑图

实验一(ospf联动bfd)

实验二(静态路由+BFD)
实验配置
1.BFD+OSPF的联动配置(实验一)
OSPF联动BFD的配置十分简单,只需要全局启用BFD功能,在OSPF进程下使能BFD功能即完成配置。
LSW2:
bfd(全局启用bfd功能)
ospf 1 router-id 1.1.1.1
bfd all-interfaces enable
AR2:
bfd(全局启用bfd功能)
ospf 1 router-id 2.2.2.2
bfd all-interfaces enable
AR1:
bfd(全局启用bfd功能)
ospf 1 router-id 3.3.3.3
bfd all-interfaces enable
LSW1:
bfd(全局启用bfd功能)
ospf 1 router-id 4.4.4.4
bfd all-interfaces enable
查看BFD会话:

LSW2 BFD 会话

AR2 BFD会话

AR1 BFD Session

LSW1 BFD Session
在LSW2到AR1间的链路未断开时,PC2的路径是走LSW2-->AR1--->PC3

PC2 PING PC3
断开AR1的G2/0/0口,测试效果如下:

BFD立马检测到故障链路

PC2 PING PC3
可以发现,在LSW2到AR1间的链路断开时,PC2的路径是走LSW2-->AR2--->AR1-->PC3,且链路发生故障后,ospf的收敛速度会加快。
2.BFD+静态路由的联动配置(实验二)
实验二拓扑中,将LSW2与AR1、AR2的链路改造为通过静态路由实现的2条链路。LSW6、LSW7为傻瓜交换机。LSW2配置了两条静态浮动路由,
ip route-static 0.0.0.0 0.0.0.0 192.168.30.1 preference 100
ip route-static 0.0.0.0 0.0.0.0 192.168.80.1 preference 120

LSW6和LSW7物理链路故障

LSW2的默认路由未发生切换

PC2无法PING通PC3
可知,当LSW2到AR2物理链路和逻辑正常时,LSW2的默认路由走AR2,不走AR1。但是LSW6和LSW7是傻瓜交换机,当LSW6和LSW7中的物理链路发生故障,此时LSW2的默认路由下一条仍然不会发生改变,因为LSW2无法感知到LSW2到AR2的逻辑链路发生了故障。因此必须结合其它路由协议进行联动探测,然后自动选择备份路径。
BFD联动静态路由的配置:
LSW2:
#全局开启bfd
bfd
#创建bfd会话
bfd LSW2toAR2 bind peer-ip 192.168.30.1 source-ip 192.168.30.254 auto
bfd LSW2toAR1 bind peer-ip 192.168.80.1 source-ip 192.168.80.254 auto
#bfd联动静态路由
ip route-static 0.0.0.0 0.0.0.0 192.168.30.1 preference 100 track bfd-session lsw2toar2
ip route-static 0.0.0.0 0.0.0.0 192.168.80.1 preference 120 track bfd-session lsw2toar1
AR1:
#全局开启bfd
bfd(全局开启bfd功能)
#创建bfd会话
bfd AR1toLSW2 bind peer-ip 192.168.80.254 source-ip 192.168.80.1 auto
#bfd联动静态路由
ip route-static 192.168.10.0 255.255.255.0 192.168.80.254 track bfd-session ar1tolsw2
ip route-static 192.168.20.0 255.255.255.0 192.168.80.254 track bfd-session ar1tolsw2
ip route-static 192.168.30.0 255.255.255.0 192.168.80.254 track bfd-session ar1tolsw2
AR2:
#全局开启bfd
bfd(全局开启bfd功能)
#创建bfd会话
bfd AR2toLSW2 bind peer-ip 192.168.30.254 source-ip 192.168.30.1 auto
#bfd联动静态路由
ip route-static 192.168.10.0 255.255.255.0 192.168.30.254 track bfd-session ar2tolsw2
ip route-static 192.168.20.0 255.255.255.0 192.168.30.254 track bfd-session ar2tolsw2
配置完成后测试结果:

LSW1、2、3 BFD会话表

LSW2默认路由正确切换备用路径

PC2正常PING通PC3
恢复傻瓜交换机后,我们再验证下LSW2的BFD会话表及路由表,以及PC2 PING PC3的情况:

恢复故障链路

LSW2 BFD会话表

LSW2切换为最优路径

PC2验证了配置结果
实验总结
- BFD联动OSPF在实际网络工程项目中应用十分广泛,配置并不复杂,但是却能极大的提高网络的可靠性。
- BFD联动静态路由也是应用非常广泛,也是网络工程师必备的技能。
关键词:华为交换机BFD设置图文教程(华为设置交换机详细图文教程)