一、基础知识:

      虚拟路由冗余协议(VRRP)与热备份路由协议(HSRP)都是一种默认网关冗余方法,它们都是让一组路由器构成一台虚拟路由器。和HSRP不同的是,VRRP是开发的协议,而HSRP是思科专属的。
      使用VRRP创建的虚拟路由器被称为VRRP组,它代表一组路由器。
      在VRRP组中是通过优先级来决定主虚拟路由器的。
      优先级范围:1—255。如果优先级设置为0,那么主路由器和任何路由器将不再是VRRP组中的路由器。(通过将优先级设置为0来让主路由器自动辞职。)
二、VRRP的配置与验证:
      配置主要命令:
1.定义VRRP组
Vrrp group-number ip virtual-ip-address
2.配置指定VRRP路由器的优先级:
Vrrp group-number priority priority-value
3.允许主虚拟路由器失效的情况下切换到备用虚拟路由器:
Vrrp group-number preempt
      验证命令:
1.查看VRRP详细配置信息:
Show vrrp all
2.查看VRRP简要配置信息:
Show vrrp brief
3.查看VRRP接口配置信息:
Show vrrp interface FastEthernet*/*
三、实验:
      拓扑图:
VRRP在cisco中的配置_第1张图片
      实验目的:
在这个实验配置了两个VRRP组——vrrp 1和vrrp 2。在vrrp 1中,路由器R1为主虚拟路由器,R2为备用虚拟路由器;在vrrp 2中,路由器R1为备用虚拟路由器,路由器R1为主虚拟路由器。在两个路由器都正常工作的时候,PC1和PC2通过R1访问远端,PC3通过R2访问远端。
      具体配置:
      路由器R1的具体配置:
R1(config)#int f0/0
R1(config-if)#ip address 10.0.0.253 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#int s1/0
R1(config-if)#ip add 200.0.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#int f0/0
R1(config-if)#vrrp 1 ip 10.0.0.253
R1(config-if)#vrrp 1 priority 200
R1(config-if)#vrrp 1 preempt
R1(config-if)#vrrp 2 ip 10.0.0.254
R1(config-if)#vrrp 2 priority 100
R1(config-if)#vrrp 2 preempt
R1(config-if)#exit
R1(config)#router rip
R1(config)#ver 2
R1(config)#no auto-summary
R1(config)#network 10.0.0.0
R1(config)#network 200.0.1.0
      路由器R2的配置:
R2#sh run
Building configuration...
Current configuration : 1019 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!  
ip cef
!
no ftp-server write-enable
!
interface FastEthernet0/0
ip address 10.0.0.254 255.255.255.0
duplex auto
speed auto
vrrp 1 ip 10.0.0.253
vrrp 1 priority 150
vrrp 2 ip 10.0.0.254
vrrp 2 priority 200
!
interface Serial1/0
ip address 200.0.2.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router rip
version 2
network 10.0.0.0
network 200.0.2.0
no auto-summary
!
ip http server
ip classless
!
control-plane
!
line con 0
transport preferred all
transport output all
line aux 0
transport preferred all
transport output all
line vty 0 4
!
End
     路由器R3的配置:
R3#sh run
Building configuration...
Current configuration : 965 bytes
!
version 12.3
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R3
!
boot-start-marker
boot-end-marker
!
memory-size iomem 5
no aaa new-model
ip subnet-zero
!
ip cef
!
no ftp-server write-enable
!
interface Serial0/0
ip address 200.0.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial0/1
ip address 200.0.2.2 255.255.255.0
serial restart-delay 0
!
interface Serial0/2
no ip address
shutdown
serial restart-delay 0
!
interface Serial0/3
no ip address
shutdown
serial restart-delay 0
!
interface FastEthernet1/0
ip address 200.0.0.254 255.255.255.0
duplex auto
speed auto
!
router rip
version 2
network 200.0.0.0
network 200.0.1.0
network 200.0.2.0
no auto-summary
!
ip http server
ip classless
!
control-plane
!
line con 0
transport preferred all
transport output all
line aux 0
transport preferred all
transport output all
line vty 0 4
!
End
      在交换机上要记得将连接路由器、主机的接口用NO SHUTDOWN开启!
验证配置:
在路由器R1上:
clip_p_w_picpath004
VRRP在cisco中的配置_第2张图片
      在路由器R2上:
clip_p_w_picpath008
VRRP在cisco中的配置_第3张图片
实验做完了,当然,大家也可以通过关闭接口等方法来验证VRRP是否有效果~
Have fun!