305 lines
9.4 KiB
Markdown
305 lines
9.4 KiB
Markdown
|
# BFD
|
|||
|
|
|||
|
### 一、BFD概述
|
|||
|
|
|||
|
1. Bidirectional Forwarding Detection
|
|||
|
|
|||
|
> 双向转发检测
|
|||
|
|
|||
|
2. BFD技术背景
|
|||
|
|
|||
|
1. 现网中存在的问题
|
|||
|
- 不能快速有效的发现网络设备或链路出现的故障
|
|||
|
- 不能以毫秒级的速度发现网络问题
|
|||
|
- 协议自身的报文检测机制一般都大于1秒
|
|||
|
2. 解决方案:
|
|||
|
- 需要一种专门用于快速检测设备或链路的协议:BFD协议产生
|
|||
|
|
|||
|
3. BFD的作用
|
|||
|
|
|||
|
- 专门用于发送超小和超快的检测数据包,以毫秒级进行发送,快速检测链路的故障,改善网络性能
|
|||
|
- 当发现链路故障时,通知相关的设备和协议进行处理,快速恢复通信,保证网络可靠性
|
|||
|
|
|||
|
4. BFD的优点
|
|||
|
|
|||
|
- 对任何介质、任何协议层进行实时且快速的检测
|
|||
|
|
|||
|
5. BFD会话建立方式
|
|||
|
|
|||
|
- BFD会话的建立有:静态建立、动态建立两种方式
|
|||
|
- 静态建立BFD会话:手工配置BFD会话参数(手工配置:本地标识符和远端标识符)
|
|||
|
- 动态建立BFD会话:动态分配本地标识符、自学习远端标识符
|
|||
|
- 静态和动态的主要区别:本地标识符和远端标识符配置方式不同
|
|||
|
|
|||
|
6. BFD检测机制
|
|||
|
|
|||
|
- 两个设备建立BFD会话,链路两端周期性发送BFD控制报文,如果一端在既定的时间内没有收到BFD控制报文,则认为路径上发生了故障。
|
|||
|
|
|||
|
7. BFD会话常见参数的缺省配置
|
|||
|
|
|||
|
| 参数 | 缺省值 |
|
|||
|
| ------------ | -------- |
|
|||
|
| 发送间隔 | 1000毫秒 |
|
|||
|
| 接收间隔 | 1000毫秒 |
|
|||
|
| 本地检测倍数 | 3 |
|
|||
|
|
|||
|
### 二、BFD和静态路由联动
|
|||
|
|
|||
|
![image-20240831104707266](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831104707266.png)
|
|||
|
|
|||
|
- **需求**
|
|||
|
|
|||
|
- 实现PC1 和PC2的互联互通
|
|||
|
- 实现BFD和静态路由联动
|
|||
|
|
|||
|
- **配置步骤**
|
|||
|
|
|||
|
1. 配置PC的IP地址,掩码,网关
|
|||
|
2. 配置路由器的接口IP地址
|
|||
|
3. 配置静态路由和浮动路由
|
|||
|
4. 配置BFD
|
|||
|
5. 配置BFD和静态路由联动
|
|||
|
6. 验证与测试
|
|||
|
|
|||
|
- **配置命令**
|
|||
|
|
|||
|
- 第一步:配置PC的接口IP地址
|
|||
|
|
|||
|
- 第二步:配置路由器的接口IP地址
|
|||
|
|
|||
|
- 第三步:配置静态路由和浮动路由
|
|||
|
|
|||
|
- R1配置浮动路由
|
|||
|
|
|||
|
```
|
|||
|
[R1]ip route-static 192.168.2.0 24 192.168.12.2 :主路由
|
|||
|
[R1]ip route-static 192.168.2.0 24 192.168.13.3 preference 70 :浮动路由
|
|||
|
```
|
|||
|
|
|||
|
> R1去往24.0网段,要做BFD[R1]ip route-static 192.168.24.0 24 192.168.12.2
|
|||
|
|
|||
|
- R2配置静态路由
|
|||
|
|
|||
|
```
|
|||
|
[R2]ip route-static 192.168.1.0 24 192.168.12.1
|
|||
|
[R2]ip route-static 192.168.2.0 24 192.168.24.4
|
|||
|
```
|
|||
|
|
|||
|
- R3配置静态路由
|
|||
|
|
|||
|
```
|
|||
|
[R3]ip route-static 192.168.1.0 24 192.168.13.1
|
|||
|
[R3]ip route-static 192.168.2.0 24 192.168.34.4
|
|||
|
```
|
|||
|
|
|||
|
- R4配置浮动路由
|
|||
|
|
|||
|
```
|
|||
|
[R4]ip route-static 192.168.1.0 24 192.168.24.2
|
|||
|
[R4]ip route-static 192.168.1.0 24 192.168.34.3 preference 70
|
|||
|
```
|
|||
|
|
|||
|
> R4去往12.0网段,要做BFD[R4]ip route-static 192.168.12.0 24 192.168.24.2
|
|||
|
|
|||
|
- 第四步:配置BFD
|
|||
|
|
|||
|
- R1的配置
|
|||
|
|
|||
|
```
|
|||
|
[R1]bfd
|
|||
|
[R1-bfd]quit
|
|||
|
[R1]bfd ntd bind peer-ip 192.168.24.4
|
|||
|
[R1-bfd-session-ntd]discriminator local 1
|
|||
|
[R1-bfd-session-ntd]discriminator remote 4
|
|||
|
[R1-bfd-session-ntd]min-tx-interval 10
|
|||
|
[R1-bfd-session-ntd]min-rx-interval 10
|
|||
|
[R1-bfd-session-ntd]commit
|
|||
|
[R1-bfd-session-ntd]quit
|
|||
|
```
|
|||
|
|
|||
|
- R4的配置
|
|||
|
|
|||
|
```
|
|||
|
[R4]bfd
|
|||
|
[R4-bfd]quit
|
|||
|
[R4]bfd ntd bind peer-ip 192.168.12.1
|
|||
|
[R4-bfd-session-ntd]discriminator local 4
|
|||
|
[R4-bfd-session-ntd]discriminator remote 1
|
|||
|
[R4-bfd-session-ntd]min-tx-interval 10
|
|||
|
[R4-bfd-session-ntd]min-rx-interval 10
|
|||
|
[R4-bfd-session-ntd]commit
|
|||
|
```
|
|||
|
|
|||
|
- 第五步:配置BFD和静态路由联动
|
|||
|
|
|||
|
- R1
|
|||
|
|
|||
|
```
|
|||
|
[R1]ip route-static 192.168.2.0 24 192.168.12.2 track bfd-session ntd2308
|
|||
|
```
|
|||
|
|
|||
|
- 第六步:验证与测试
|
|||
|
|
|||
|
- R1
|
|||
|
|
|||
|
```
|
|||
|
<R1>display bfd session all
|
|||
|
```
|
|||
|
|
|||
|
> 将R2和R4之间的链路断开,验证浮动路由是否切换
|
|||
|
>
|
|||
|
> 确保PC1和PC2能够正常通信,不因链路中断,而导致网络不可达
|
|||
|
|
|||
|
### 三、VRRP和BFD联动实验
|
|||
|
|
|||
|
![image-20240831110337612](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831110337612.png)
|
|||
|
|
|||
|
- **需求**
|
|||
|
|
|||
|
- 部署VRRP,让SW1成为备份组10的-Master设备(vlan10的主网关)
|
|||
|
- 让SW2成为备份组10的-Backup设备(vlan10的备份网关)
|
|||
|
- 部署VRRP和BFD联动可以解决的问题:
|
|||
|
- 在VRRP中当SW1-主网关,出现故障的时候,备份网关SW2需要等待3秒后,才可以升级为新的主网关,承担流量转发任务。
|
|||
|
- 3秒对有些企业网络来说是不可以接受的,我们需要实现VRRP主备设备更加快速的切换(毫秒级故障切换)
|
|||
|
|
|||
|
- **解决方案**
|
|||
|
|
|||
|
- 在运行VRRP网络设备上(SW1/SW2)运行BFD协议
|
|||
|
- 在SW1和SW2之间建立BFD会话,通过BFD协议快速检测和感知设备或链路故障
|
|||
|
- 在SW2中配置VRRP和BFD联动,当SW1-主网关出现故障的时候,BFD会话会Down
|
|||
|
- 此时BFD协议会通知备份网关SW2,立即将VRRP优先级调高,已实现SW2快速成为主网关
|
|||
|
|
|||
|
- **配置步骤**
|
|||
|
|
|||
|
- 第一步:配置PC的IP地址,掩码,网关
|
|||
|
- 第二步:配置sw3交换机的vlan,端口加vlan 配trunk
|
|||
|
- 第三步:SW1和SW2配置vrrp-热备
|
|||
|
1. 创建vlan
|
|||
|
2. 配置vlanif接口地址
|
|||
|
3. 配置vrrp 备份组,配置虚拟IP
|
|||
|
4. 配置优先级
|
|||
|
5. 交换机互联接口配置trunk
|
|||
|
- 第四步:配置SW1和SW2的BFD会话
|
|||
|
1. 开启BFD功能
|
|||
|
2. 创建BFD会话
|
|||
|
3. 配置本地标识符
|
|||
|
4. 配置远端标识符
|
|||
|
5. 提交
|
|||
|
- 第五步:配置VRRP和BFD联动
|
|||
|
- 配置VRRP和BFD联动,跟踪BFD会话,一旦发现BFD会话down掉,SW2的VRRP的优先级会在原来的基础上增加60,让SW2快速的成为Master设备
|
|||
|
- 第六步:模拟故障,验证BFD
|
|||
|
|
|||
|
- **配置命令**
|
|||
|
|
|||
|
- 第一步:配置PC的IP地址,掩码,网关
|
|||
|
|
|||
|
- 第二步:配置sw3交换机的vlan,端口加vlan 配trunk
|
|||
|
|
|||
|
- SW3配置
|
|||
|
|
|||
|
```
|
|||
|
[SW3]vlan 10
|
|||
|
[SW3-vlan10]quit
|
|||
|
[SW3]port-group group-member g0/0/1 g0/0/2
|
|||
|
[SW3-port-group]port link-type access
|
|||
|
[SW3-port-group]port default vlan 10
|
|||
|
[SW3-port-group]quit
|
|||
|
[SW3]port-group group-member g0/0/3 g0/0/4
|
|||
|
[SW3-port-group]port link-type trunk
|
|||
|
[SW3-port-group]port trunk allow-pass vlan all
|
|||
|
```
|
|||
|
|
|||
|
- 第三步:SW1和SW2配置vrrp-热备
|
|||
|
|
|||
|
- SW1配置
|
|||
|
|
|||
|
```
|
|||
|
[SW1]vlan 10
|
|||
|
[SW1-vlan10]quit
|
|||
|
[SW1]int g0/0/1
|
|||
|
[SW1-G0/0/1]port link-type trunk
|
|||
|
[SW1-G0/0/1]port trunk allow-pass vlan all
|
|||
|
[SW1-G0/0/1]quit
|
|||
|
[SW1]int vlanif 10
|
|||
|
[SW1-Vlanif10]ip address 192.168.10.251 24
|
|||
|
[SW1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
|||
|
[SW1-Vlanif10]vrrp vrid 10 priority 130
|
|||
|
```
|
|||
|
|
|||
|
- SW2配置
|
|||
|
|
|||
|
```
|
|||
|
[SW2]vlan 10
|
|||
|
[SW2-vlan10]quit
|
|||
|
[SW2]int g0/0/1
|
|||
|
[SW2-G0/0/1]port link-type trunk
|
|||
|
[SW2-G0/0/1]port trunk allow-pass vlan all
|
|||
|
[SW2-G0/0/1]quit
|
|||
|
[SW2]int vlanif 10
|
|||
|
[SW2-Vlanif10]ip address 192.168.10.252 24
|
|||
|
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
|||
|
```
|
|||
|
|
|||
|
- 第四步:配置SW1和SW2的BFD会话
|
|||
|
|
|||
|
- SW1配置
|
|||
|
|
|||
|
```
|
|||
|
[SW1]bfd //开启BFD功能
|
|||
|
[SW1-bfd]quit //退出
|
|||
|
[SW1]bfd tedu bind peer-ip 192.168.10.252 //在系统视图下创建BFD会话,绑定对端IP地址
|
|||
|
[SW1-bfd-session-tedu]discriminator local 1 //配置本地标识符
|
|||
|
[SW1-bfd-session-tedu]discriminator remote 2 //配置远端标识符
|
|||
|
[SW1-bfd-session-tedu]min-rx-interval 100 //配置接收报文间隔时间(100毫秒)
|
|||
|
[SW1-bfd-session-tedu]min-tx-interval 100 //配置发送报文间隔时间(100毫秒)
|
|||
|
[SW1-bfd-session-tedu]commit //提交
|
|||
|
```
|
|||
|
|
|||
|
- SW2
|
|||
|
|
|||
|
```
|
|||
|
[SW2]bfd //开启BFD功能
|
|||
|
[SW2-bfd]quit
|
|||
|
[SW2]bfd tedu bind peer-ip 192.168.10.251 //创建BFD会话,绑定对端IP地址
|
|||
|
[SW2-bfd-session-tedu]discriminator local 2 //本地标识符为2
|
|||
|
[SW2-bfd-session-tedu]discriminator remote 1 //远端标识符为1
|
|||
|
[SW2-bfd-session-tedu]min-rx-interval 100 //接受报文间隔时间100毫秒
|
|||
|
[SW2-bfd-session-tedu]min-tx-interval 100 //发送报文间隔时间100毫秒
|
|||
|
[SW2-bfd-session-tedu]commit //提交
|
|||
|
```
|
|||
|
|
|||
|
- 第五步:在SW2上配置VRRP和BFD联动
|
|||
|
|
|||
|
```
|
|||
|
[SW2]int vlanif 10
|
|||
|
[SW2-Vlanif10]vrrp vrid 10 track bfd-session 2 increased 60
|
|||
|
```
|
|||
|
|
|||
|
> 配置VRRP和BFD联动,跟踪BFD会话,一旦发现BFD会话down掉,就让SW2的VRRP的优先级在原来的基础上增加60,让SW2快速的成为Master设备
|
|||
|
|
|||
|
- 第六步:模拟SW1故障,在SW2中验证BFD和VRRP联动
|
|||
|
|
|||
|
- SW2
|
|||
|
|
|||
|
```
|
|||
|
[SW2]display vrrp
|
|||
|
Vlanif10 | Virtual Router 10
|
|||
|
State : Master
|
|||
|
Virtual IP : 192.168.10.254
|
|||
|
Master IP : 192.168.10.252
|
|||
|
PriorityRun : 160
|
|||
|
PriorityConfig : 100
|
|||
|
MasterPriority : 160
|
|||
|
Preempt : YES Delay Time : 0 s
|
|||
|
TimerRun : 1 s
|
|||
|
TimerConfig : 1 s
|
|||
|
Auth type : NONE
|
|||
|
Virtual MAC : 0000-5e00-010a
|
|||
|
Check TTL : YES
|
|||
|
Config type : normal-vrrp
|
|||
|
Track BFD : 2 Priority increased : 60 BFD-session state : DOWN // 重点看这条
|
|||
|
Create time : 2022-12-29 17:32:15 UTC-08:00
|
|||
|
Last change time : 2022-12-29 17:50:00 UTC-08:00
|
|||
|
```
|
|||
|
|