HSRP(热备份路由器协议)的详细介绍
Part I: Fundamental<br />HSRP(Hot Standby Router Protocol):Cisco私有的第3层协议。<br />HSRP为IP网络提供网络冗余,确保用户流量能立即并透明地恢复网络边界设备或接入电路中的第一跳故障。<br />在LAN中,多个router组成一个HSRP组,其中一个router代表这个HSRP转发这个LAN中的数据流,其它所有router只发送HSRP hello来维持这种HSRP组关系。<br />一个HSRP组共享一个IP和一个MAC地址。每个router可以加入多个组。<br />一个HSRP组由一台active router,一台standby router及other routers。<br />1>active router转发指向VIP的数据流,并发送HSRP hello包给所有其它HSRP组成员。(最终处于active state)<br />2>standby router不转发指向VIP的数据流,发送HSRP hello包给所有其它HSRP组成员,并监控active router的状态。(最终处于standby state)<br />3>other routers不转发指向VIP的数据流,只监控HSRP hello包,不发送。它们执行普通router的工作,只转发目标为他们自己的分组,不转发目标为VIP的地址。(最终处于listen state)<br /><br />Part II: HSRP Operation<br />当standby router在一定时间内没有收到active router的hello包时,它就认为active router出现故障了,并取代它的active router的角色。因为host设备使用VIP及VMAC来标识它们的网关设备,所有它们不会发现这种变更,也不会感觉到服务的中断。<br /><br />active router的选择:<br />1>优选priority大的HSRP router,默认的priority值为100<br />2>优选lowest mac地址<br /><br />为了方便进行负载均衡,一个router可以属于多个HSRP组的成员,每个HSRP组有一个VIP及VMAC。<br />一个LAN最多支持255个HSRP组。<br /><br />如果host设备发送数据分组给VIP的VMAC地址,由active router来进行相应的数据流转发。<br />如果host设备发送一个对VIP的ARP请求,由active router用相应的VMAC来应答。<br /><br /><br />Part III: VMAC Format<br />VMAC地址由3部分组成:<br />1>Vendor ID:MAC地址的前3个字节<br />2>HSRP code:2个字节,一般为07.ac,指示此地址为HSRP router。<br />3>Group ID:MAC地址的最后一个字节,为HSRP的组号。<br /><img border="0" alt="\" width="650" udp="" ttl="1,源IP为接口IP地址,非VIP。<br" standby="" part="" img="" hsrp="" active="" src="https://img.jbzj.com/file_images/article/201205/2012051414253310.jpg" /> <img border="0" alt="\" width="650" part="" img="" hsrp="" interval="" hold="" hello="" src="https://img.jbzj.com/file_images/article/201205/2012051414253311.jpg" /> Part Ⅶ:HSRP Command Reference<br />1> standby {group-number} ip {virtual-ip-address}<br />group-number:缺省为0,可配置范围0-255<br />注:使用HSRP时,host设备不能发现HSRP router的真实MAC地址,所以在配置了HSRP时,cisco设备自动禁用了ICMP重定向:no ip redirects<br /><br />2> standby {group-number} priority {priority-value}<br />priority:缺省为100,可配置范围0-255<br />priority最高的router成为active router,priority相同,则最高ip地址的router为active router<br /><br />3> standby {group-number} preempt<br />允许一台router只要有高的priority就可以立即强占成为active router<br /><br />4> standby {group-number} {hellotime} {holdtime}<br />group-number:缺省为0,可配置范围0-255<br />hellotime:缺省为3,可配置范围1-255<br />holdtime:缺省为10,可配置范围1-255<br /><br />5> standby {group-number} track {type number} {interface-priority}<br />type number:使HSRP监控此接口,如果此接口down掉,则接口的HSRP priority值减去interface-priority<br />interface-priority:接口down掉的惩罚值。<br /><br />6> show standby {type number} {group} {brief}<br />Switch#show standby Vlan11 11<br />Vlan11 - Group 11<br />Local state is Active, priority 110<br />Hellotime 3 holdtime 10<br />Next hello sent in 00:00:02.944<br />Hot standby IP address is 172.16.11.115 configured<br />Active router is local<br />Standby router is 172.16.11.114 expires in 00:00:08<br />Standby virtual mac address is 0000.0c07.ac01<br /><br />7> debug standby <br />监控HSRP所有的状态改变及hello包的发送。<br /><br />8> debug standby terse<br />监控HSRP所有的errors,events和packets信息(不包括hello及advertisement packets)<br /><br /><br /><br />Part Ⅷ: HSRP Configuration<br />RouterA:<br />!<br />interface Vlan10<br />ip address 172.16.10.32 255.255.255.0<br />no ip redirects<br />standby 1 priority 150<br />standby 1 ip 172.16.10.110<br />standby 2 priority 50<br />standby 2 ip 172.16.10.120<br />RouterB:<br />!<br />interface Vlan10<br />ip address 172.16.10.33 255.255.255.0<br />no ip redirects<br />standby 1 priority 50<br />standby 1 ip 172.16.10.110<br />standby 2 priority 150<br />standby 2 ip 172.16.10.120<br />RouterA#show standby brief<br />P indicates configured to preempt.<br />Interface Grp Prio P State Active Standby Virtual IP<br />Vl10 1 150 Active local 172.16.10.33 172.16.10.110<br />Vl10 2 50 Standby 172.16.10.33 local 172.16.10.120<br /><br /><br />Part Ⅸ: Tuning HSRP Operations<br />Subsecond Failover:<br />HSRP hellotime及holdtime可以配置为millisecond级别,进而将HSRP故障检测时间减少到1秒内。<br />switch(config-if)#standby 1 timers msec 200 msec 750<br /><br />Preempt Time Aligned with Router Boot Time:<br />preempt是HSRP很重要的一个特性,它允许主router在经历failover后再次成为active router。<br />当主router重启后,HSRP应该等待此router与其它相连的设备建立好相应的通信连接后再preempt HSRP。否则有可能会导致packets不可达。<br />这时就需要在preempt之前有一个延迟,以等待router完成它的通信连接或路由信息收集。这个延迟要根据不同设备不同的启动时间来设定,一般这个延迟应该比启动时间大一倍,以确保主router有能力成为active router。<br />switch(config-if)#standby 1 preempt<br />switch(config-if)#standby 1 preempt delay minimum 180
頁:
[1]