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