Cyber_Security_Notes/B. 第二阶段/拓扑练习/0828_BFD和VRRP.md
2024-08-28 16:42:00 +08:00

202 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# BFD和VRRP
![image-20240828162230655](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828162230655.png)
### 一、PC`s IP
### 二、VLAN
- **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
```
### 三、VRRP
- **SW1**
```
[SW1]vlan 10
[SW1-vlan10]quit
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]quit
[SW1]int vlan 10
[SW1-Vlanif10]ip add 192.168.10.254 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-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/1]quit
[SW2]int vlan 10
[SW2-Vlanif10]ip add 192.168.10.252 24
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
```
### 四、BFD
- **SW1**
```
[SW1]bfd
[SW1-bfd]quit
[SW1]bfd ntd2407 bind peer-ip 192.168.10.252
[SW1-bfd-session-ntd2407]discriminator local 1
[SW1-bfd-session-ntd2407]discriminator remote 2
[SW1-bfd-session-ntd2407]min-tx-interval 100
[SW1-bfd-session-ntd2407]min-rx-interval 100
[SW1-bfd-session-ntd2407]commit
```
- **SW2**
```
[SW2]bfd
[SW2-bfd]quit
[SW2]bfd ntd2407 bind peer-ip 192.168.10.251
[SW2-bfd-session-ntd2407]discriminator local 2
[SW2-bfd-session-ntd2407]discriminator remote 1
[SW2-bfd-session-ntd2407]min-tx-interval 100
[SW2-bfd-session-ntd2407]min-rx-interval 100
[SW2-bfd-session-ntd2407]commit
```
### 五、BFD与VRRP联动
- **SW2**
```
[SW2]int vlan 10
[SW2-Vlanif10]vrrp vrid 10 track bfd-session 2 increased 60
```
*解释:*
1. `[SW2]int vlan 10`
- 进入交换机的VLAN接口配置模式针对VLAN 10。
2. `[SW2-Vlanif10]vrrp vrid 10 track bfd-session 2 increased 60`
- 在VLAN接口10上配置VRRP虚拟路由器ID为10并设置对BFD会话2的跟踪。
- `track bfd-session 2`指定跟踪的BFD会话这里的会话ID是2。
- `increased 60`当BFD会话2的状态变为Down时VRRP的优先级将增加60。这通常用于确保当主链路出现问题时备份链路能够接管提高其VRRP优先级从而成为新的主路由器。
> 这个配置的作用是当BFD会话2检测到链路故障时VRRP的优先级会增加这有助于VRRP组中的备用路由器成为新的主路由器从而保证网络的连续性和可靠性。
>
> 请注意这个配置假设BFD会话2已经正确配置并且与VRRP虚拟路由器关联的接口是VLAN 10。如果BFD会话状态变为DownVRRP优先级的增加将触发VRRP主备切换。
### 六、完备性测试
- **SW1**
```
[SW1]dis vrrp
Vlanif10 | Virtual Router 10
State : Master
Virtual IP : 192.168.10.254
Master IP : 192.168.10.254
PriorityRun : 255
PriorityConfig : 130
MasterPriority : 255
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
Create time : 2024-08-28 15:57:41 UTC-08:00
Last change time : 2024-08-28 16:13:44 UTC-08:00
```
- **SW2**
```
[SW2]dis vrrp
Vlanif10 | Virtual Router 10
State : Backup
Virtual IP : 192.168.10.254
Master IP : 192.168.10.254
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 255
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 : INITIALIZE
Create time : 2024-08-28 15:55:20 UTC-08:00
Last change time : 2024-08-28 16:28:55 UTC-08:00
```
### 七、功能性测试
![image-20240828163927888](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828163927888.png)
- **SW1**
```
[SW1]dis vrrp
Vlanif10 | Virtual Router 10
State : Initialize
Virtual IP : 192.168.10.254
Master IP : 0.0.0.0
PriorityRun : 255
PriorityConfig : 130
MasterPriority : 0
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
Create time : 2024-08-28 15:57:41 UTC-08:00
Last change time : 2024-08-28 16:39:16 UTC-08:00
```
- **SW2**
```
[SW2]dis vrrp
Vlanif10 | Virtual Router 10
State : Master
Virtual IP : 192.168.10.254
Master IP : 192.168.10.252
PriorityRun : 100
PriorityConfig : 100
MasterPriority : 100
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 : INITIALIZE
Create time : 2024-08-28 15:55:20 UTC-08:00
Last change time : 2024-08-28 16:39:17 UTC-08:00
```