vrrp

簡介

VRRP(Virtual Router Redundancy Protocol 虛擬路由器冗餘協議)的工作原理和HSRP非常類似,不過VRRP是國際標準,允許在不同廠商的設備之間的運行。VRRP中虛擬網關的地址可以和接口上的 地址相同,VRRP中接口只有3個狀態:初始狀態(Initial)、主狀態(Master)和備份狀態(Backup)。

VRRP和HSRP比較:

和HSRP一樣,VRRP根據優先級來確定備份組中每臺路由器的角色(Master路由器或Backup路由器)。優先級越高,則越有可能成爲 Master路由器。VRRP優先級的取值範圍爲0-255(數值越大表明優先級越高),可配置的範圍是1-254,優先級0爲系統保留給特殊用途來使 用,優先級255則是系統保留給IP地址擁有者使用。當路由器爲IP地址擁有者時,其優先級始終爲255。因此,當備份組內存在IP地址擁有者時,只要其 工作正常就爲Master路由器。
VRRP的報文格式:


①Version 版本:指示VRRP的版本信息。Cisco默認支持的是Version2。

②Type 包類型:只有一種類型,即Advertisement(VRRP通告報文),該字段取值爲1。

③Virtual Rtr ID 虛擬路由ID:虛擬路由器號(即備份組號),取值範圍爲1-255。

④Priority 優先級:路由器在備份組中的優先級,取值範圍爲0-255,數值越大表明優先級越高。

⑤Count IP Addrs IP地址數:備份組虛擬IP地址的個數。1個備份組可對應多個虛擬IP地址。

⑥Auth Type 認證碼:該值爲0表示無認證,爲1表示簡單字符認證,爲2表示MD5認證。

⑦Adver Int 通告時間間隔:發送通告報文的時間間隔。在VRRP Version2中單位爲秒,默認值爲1秒。

⑧Checksum 校驗和:16位校驗和,用於檢測VRRP報文中的數據破壞情況。

⑨IP address 虛擬IP地址:備份組虛擬IP地址表項。

⑩Authentication data 認證數據:驗證字,目前只用於簡單字符認證,對於其它認證方式一律填0。

VRRP的3個定時器:

通告時間間隔定時器(Advertisement Interval):VRRP備份組中的Master路由器會定時發送VRRP通告報文,通知

備份組內的路由器自己工作正常。用戶可以通過設置VRRP定時器來調整Master路由器發送VRRP通告報文的時間

間隔。默認值爲1秒。

時滯時間定時器:該值的計算方式爲(256 - 優先級)/256,單位爲秒。

主用失效時間間隔定時器(Master Down Interval):如果Backup路由器在等待了3個間隔時間後,依然沒有收到

VRRP通告報文,則認爲自己是Master路由器,並對外發送VRRP通告報文,重新進行Master路由器選舉。Backup

路由器並不會立即搶佔成爲Master,而是等待一定時間(時滯時間)後,纔會對外發送VRRP通告報文取代原來的

Master路由器。因此該定時器值 = 3 × 通告時間間隔 + (256 - 優先級)/256秒。


實驗

命令:

R1(config)#track 100 int s0/0 line-protocol //定義跟蹤的目標100爲s0/0接口的二層故障
R1(config-if)#vrrp 1 ip 192.168.13.254

R1(config-if)#vrrp 1 priority 120
R1(config-if)#vrrp 1 preempt
R1(config-if)#vrrp 1 authentication md5 key-string cisco
R1(config-if)#vrrp 1 track 100 decrement 30 //配置跟蹤的目標

說明:VRRP端口跟蹤和HSRP有些不同,它需要在全局配置模式下先定義跟蹤目標,再配置VRRP中跟蹤該目標。我們試驗中路由器R1定義了目標100爲跟蹤s0/0接口的二層故障;R3定義了目標100爲跟蹤s0/1接口的二層故障。

配置IP地址及路由:

R1(config)#int f1/0
R1(config-if)#ip add 192.168.13.1 255.255.255.0
R1(config-if)#no sh
R1(config)#int s0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1(config)#router rip
R1(config-router)#network 192.168.12.0
R1(config-router)#network 192.168.13.0
R1(config-router)#passive-interface f1/0  //防止從該接口發送RIP信息給R3
R2(config)#int lo0
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config)#int s0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#clock rate 128000
R2(config-if)#no sh
R2(config)#int s0/1
R2(config-if)#ip add 192.168.23.2 255.255.255.0
R2(config-if)#clock rate 128000
R2(config-if)#no sh
R2(config)#router rip
R2(config-router)#network 192.168.2.0
R2(config-router)#network 192.168.12.0
R2(config-router)#network 192.168.23.0
R3(config)#int f1/0
R3(config-if)#ip add 192.168.13.3 255.255.255.0
R3(config-if)#no sh
R3(config)#int s0/1
R3(config-if)#ip add 192.168.23.3 255.255.255.0
R3(config-if)#no sh
R3(config)#router rip
R3(config-router)#network 192.168.23.0
R3(config-router)#network 192.168.13.0
R3(config-router)#passive-interface f1/0
配置多個VRRP組:
R1(config)#track 100 int s0/0 line-protocol
R1(config)#int f1/0
R1(config-if)#vrrp 1 ip 192.168.13.254
R1(config-if)#vrrp 1 priority 120
R1(config-if)#vrrp 1 preempt
R1(config-if)#vrrp 1 authentication md5 key-string cisco
R1(config-if)#vrrp 1 track 100 decrement 30
R1(config-if)#vrrp 2 ip 192.168.13.253
R1(config-if)#vrrp 2 preempt
R1(config-if)#vrrp 2 authentication md5 key-string cisco
R3(config)#track 100 int s0/1 line-protocol
R3(config)#int f1/0
R3(config-if)#vrrp 1 ip 192.168.1.254
R3(config-if)#vrrp 1 preempt
R3(config-if)#vrrp 1 authentication md5 key-string cisco
R3(config-if)#vrrp 2 ip 192.168.1.253
R3(config-if)#vrrp 2 priority 120
R3(config-if)#vrrp 2 preempt
R3(config-if)#vrrp 2 authentication md5 key-string cisco
R3(config-if)#vrrp 2 track 100 decrement 30

實驗調試

R1#show vrrp brief


R1#show vrrp
<img src="https://s3.51cto.com/wyfs02/M01/54/17/wKioL1R373Cg6VknAANg

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章