一、概述
????????在前面的文章我們學習了VRRP與BFD協議,VRRP(虛擬路由冗余協議)的主要特點是當Master(主)設備出現故障時,Backup(備用)設備能夠快速接替Master的轉發工作,盡量縮短數據流的中斷時間。
? ? ? ? 在沒有采用BFD與VRRP聯動機制前,當Master出現故障時,VRRP依靠Backup設置的超時時間來判斷是否應該搶占,切換速度在1s以上。將BFD應用于Backup對Master的檢測后,可以實現對Master故障的快速檢測,如果通信不正常,可在50ms以內自動升級成Master,實現快速的主、備切換,縮短用戶流量的中斷時間。
? ? ? ? 如下圖所示,RouterA和RouterB之間配置VRRP備份組建立主備關系,RouterA為主用設備,RouterB為備用設備,用戶過來的流量從RouterA出去。當在RouterA和RouterB之間建立BFD會話后,VRRP備份組監視該BFD會話,當BFD會話狀態變為Down時,系統會自動通過修改備份組優先級實現主備快速切換。
? ? ? ? 例如,當BFD檢測到RouterA和RouterB之間的鏈路故障時,上報給VRRP一個BFD檢測Down事件,RouterB上VRRP備份組的優先級增加,增加后的優先級大于RouterA上的VRRP備份組的優先級,于是RouterB立即升為Master,后繼的用戶流量就會通過RouterB轉發,從而實現VRRP的主備快速切換。
二、實驗
拓撲
1、基本配置思路分析
? ? ? ? 本拓撲要監控的是RouterA和RouterB之間的下行鏈路狀態,故可采用VRRP和BFD聯動實現主備網關間的快速切換。其配置思路如下。
- 配置各設備接口的IP地址及路由協議(假設為OSPF),使網絡層路由可達。
- 在RouterA和RouterB上配置VRRP備份組,其中RouterA的優先級為120,搶占延時為20s,作為Master設備;RouterB的優先級為缺省值,作為Backup設備。
- 在RouterA和RouterB上配置靜態BFD會話,監測備份組之間的鏈路。
- 在RouterB上配置VRRP與BFD聯動,實現鏈路故障時VRRP備份組的快速切換。
基礎配置
RouterA
system
sysname RouterA
int g 0/0/0
ip add 10.1.1.1 24RouterB
system
sysname RouterB
int g 0/0/0
ip add 10.1.1.2 24
路由配置
RouterA
ospf 1 router-id 1.1.1.1
area 0
netw 10.1.1.1 0.0.0.0RouterB
ospf 1 router-id 2.2.2.2
area 0
netw 10.1.1.2 0.0.0.0
查看OSPF鄰居狀態
[RouterA-ospf-1]dis ospf peer briefOSPF Process 1 with Router ID 1.1.1.1Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full ----------------------------------------------------------------------------
[RouterB]dis ospf peer brief OSPF Process 1 with Router ID 2.2.2.2Peer Statistic Information----------------------------------------------------------------------------Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full ----------------------------------------------------------------------------
VRRP配置
RouterA
int g 0/0/0
vrrp vrid 1 vir 10.1.1.3
vrrp vrid 1 pri 120
vrrp vrid 1 preempt-mode timer delay 0RouterB
int g 0/0/0
vrrp vrid 1 vir 10.1.1.3
查看VRRP狀態
[RouterA]dis vrrp GigabitEthernet0/0/0 | Virtual Router 1State : MasterVirtual IP : 10.1.1.3Master IP : 10.1.1.1PriorityRun : 120PriorityConfig : 120MasterPriority : 120Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledCreate time : 2025-05-15 15:53:17 UTC-08:00Last change time : 2025-05-15 15:53:20 UTC-08:00
[RouterB]dis vrrpGigabitEthernet0/0/0 | Virtual Router 1State : BackupVirtual IP : 10.1.1.3Master IP : 10.1.1.1PriorityRun : 100PriorityConfig : 100MasterPriority : 120Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledCreate time : 2025-05-15 15:53:35 UTC-08:00Last change time : 2025-05-15 15:53:35 UTC-08:00
BFD配置
RouterA
bfd
q
bfd 1 bind peer-ip 10.1.1.2 interface GigabitEthernet 0/0/0
discriminator local 1
discriminator remote 2
commitRouterB
bfd
q
bfd 1 bind peer-ip 10.1.1.1 interface GigabitEthernet 0/0/0
discriminator local 2
discriminator remote 1
commit
查看BFD狀態
[RouterA]dis bfd ses all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------1 2 10.1.1.2 Up S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------Total UP/DOWN Session Number : 1/0
[RouterB]dis bfd session all
--------------------------------------------------------------------------------
Local Remote PeerIpAddr State Type InterfaceName
--------------------------------------------------------------------------------2 1 10.1.1.1 Up S_IP_IF GigabitEthernet0/0/0
--------------------------------------------------------------------------------Total UP/DOWN Session Number : 1/0
配置VRRP與BFD聯動
RouterB
int g 0/0/0
vrrp vrid 1 track bfd 2 increased 40
?此時我們將RouterA的下行接口down掉
[RouterB]dis vrrpGigabitEthernet0/0/0 | Virtual Router 1State : MasterVirtual IP : 10.1.1.3Master IP : 10.1.1.2PriorityRun : 140PriorityConfig : 100MasterPriority : 140Preempt : YES Delay Time : 0 sTimerRun : 1 sTimerConfig : 1 sAuth type : NONEVirtual MAC : 0000-5e00-0101Check TTL : YESConfig type : normal-vrrpBackup-forward : disabledTrack BFD : 2 Priority increased : 40BFD-session state : DOWNCreate time : 2025-05-15 15:53:35 UTC-08:00Last change time : 2025-05-15 16:03:20 UTC-08:00
可以看到RouterB很快就會切換至Master設備并開始傳輸數據。
以上就是本章的全部內容了,感謝大家的瀏覽觀看!文章若有錯誤或疑問可聯系博主刪除更改。