电脑技术学习

双机热备经典案例之Cisco HSRP的配置

dn001

配置基本HSRP例子:

提问 "当主用路由器当掉以后备份路由器可以接管主用路由器的IP地址和MAC地址

回答

Router1:
Router1#configure terminal
Enter configuration commands, one per line.;End with CNTL/Z.
Router1(config)#interface FastEthernet 0/1
Router1(config-if)#ip address 172.22.1.3 255.255.255.0
Router1(config-if)#standby 1 ip 172.22.1.1
Router1(config-if)#standby 1 priority 120
Router1(config-if)#exit
Router1(config)#end
Router1#
Router2:
Router2#configure terminal
Enter configuration commands, one per line.;End with CNTL/Z.
Router2(config)#interface FastEthernet 1/0
Router2(config-if)#ip address 172.22.1.2 255.255.255.0
Router2(config-if)#standby 1 ip 172.22.1.1
Router2(config-if)#standby 1 priority 110 (默认priority is 100)
Router2(config-if)#exit
Router2(config)#end
Router2#

注释 由于HSRP虚拟出来的MAC地址跟组相关,所以可能会出现同一交换机收到多个相同的MAC地址的情况,这时候就需要用standby 1 mac-address 0000.0c07.ad01 命令来人工指定一个MAC地址

提问 强制某个路由器启动后一直在组中处于主用状态

回答

Router1#configure terminal
Enter configuration commands, one per line.;End with CNTL/Z.
Router1(config)#interface FastEthernet 0/1
Router1(config-if)#standby 1 ip 172.22.1.1
Router1(config-if)#standby 1 priority 120
Router1(config-if)#standby 1 preempt
Router1(config-if)#exit
Router1(config)#end
Router1#
Router2#configure terminal
Enter configuration commands, one per line.;End with CNTL/Z.
Router2(config)#interface FastEthernet 1/0
Router2(config-if)#standby 1 ip 172.22.1.1
Router2(config-if)#standby 1 priority 110
Router2(config-if)#standby 1 preempt;;;;delay 60 (最好有时延)
Router2(config-if)#exit
Router2(config)#end
Router2#

注释 正常情况下当LAN端口up后就会发生强占,而此时可能网络还没有收敛,所以建议配置强占延迟时间,让路由器启动后过一段时间再发起强占standby 1 preempt delay 60