CCIE试验备考之冗余备份HSRP

HRRP 热备份路由协议
         多台路由器组成一个“热备份组”,用来模拟为一个虚拟的路由器(拥有虚拟的IP 地址和虚拟的MAC地址),在一个备份组中,只有一台路由器作为活动路由器发送数据包,只有当活动路由器失效后,将选择一台备份路由器才能成为活动路由器转发数据包,但对于网络中的主机来说,虚拟路由器并没有发生任何改变。
HSRP有三种广播包:
1) Hello包,hello消息通知其他路由器发送路由器的HSRP优先级和状态信息,HSRP路由器,默认为每3秒钟发送一个hello消息;可以修改这个参数。
2) Coup包,当一个备用路由器变为一个主动路由器时发送一个coup消息。
3) Resign包,当主动路由器要宕机或者当有优先级更高的路由器发送hello消息时,主动路由器发送一个resign消息。

HSRP状态类型:
1) Initial初始化,HSRP启动时的状态,HSRP还没有运行,一般是在改变配置或端口刚启动时进入该状态。
2) Learn学习状态,路由器已经得到了虚拟IP地址,但是它既不是活动路由器也不是备份路由器。它一直监听从活动路由器和备份路由器发来的HELLO报文。
3) Listen监听状态,路由器正在监听hello消息。
4) Speak对话状态,在该状态下,路由器定期发送HELLO报文,并且积极参加活动路由器或等待路由器的竞选。
5) Standby被动状态,当主动路由器失效时路由器准备接包传输功能。
6) Active活动状态,路由器执行包传输功能。
HSRP路由器体系
1)活动路由器,负责转发发送到虚拟路由器的数据。它通过发送HELLO消息(基于UDP,端口号为1985的广播)来通告它的活跃状态
2)备份路由器,监视HSRP组中的运行状态,并且在当前活跃路由器不可用时,迅速承担起负责数据转发的任务。备份路由器也发送HELLO消息来通告组中其他的路由器它备份路由器的角色。
3) 虚拟路由器,向最终的用户来代表一台能持续工作的路由器设备。它有自己的MAC和IP地址。但是实际上它是不用来转发数据包,它的作用仅仅是代表一台可用的路由设备。
虚拟MAC地址组成:
Vendor ID:厂商ID,构成MAC地址的头3个字节
HSRP代码:表示该地址是HSRP虚拟路由器的。XX07.acxx
组ID:最后一个字节是组ID,由组号组成
如我们可以通过命令:show ip arp命令查看
       0000.0007.ac01
4)其他路由器,也监听HELLO消息,但是不作应答,这样它就不会在备份组有身份的概念,同时它也不参与发送到虚拟路由器的数据包,但是还是转发其他路由器发来的数据包。
选举过程
1) 默认情况下,优先级为100,这时MAC地址最小的成为活动路由器
2) 当活动路由器失效后,备份路由器替代成为活动路由器,当活动和备份路由器都失效后,其他路由器将参与活动和备份路由器的选举工作
a) 优先级高的成为活动路由器,默认为100,取值为0~255
b) 优先级别相同时,接口IP地址高的将成为活动路由器
 
HSRP的抢占Preempt技术
HRSP技术能够保证优先级高的路由器失效恢复后总能处于活动状态。活动路由器失效后,优先级最高的备用路由器处于活动状态,如果没有使用preempt技术,则当活动路由器恢复后,只能处于备用状态,先前的备用服务器代替其角色处于活动状态,直到下一次选举发生。
HSRP的端口跟踪track技术
如果所监测的端口出现故障,则也可以进行路由器的切换。如果主路由器上有多条线路被跟踪,则当一条线路出现故障时,就会切换到备份路由器上,即使其他都线路正常工作,直到主路由器该线路正常工作,才能重新切换回来。接口跟踪使得能够根据HSRP组路由器的接口是否可用,来自动调整该路由器的优先级。当被跟踪的接口不可用时,路由器的HSRP优先级将降低。HSRP跟踪特性确保当HSRP活跃路由器的重要入站接口不可用时,该路由器不再是活跃路由器。
多组HSRP
为了方便负载均衡,同一台路由器可以是同一个网段或VLAN中多个HSRP备用组的成员。配置多个备用组可进一步提高冗余性,在网络中均衡负载,提高冗余路由器的使用率。路由器在为一个HSRP组转发通信流的同时,可以在另一个HSRP组中处于备用或监听状态。每个备用组都模拟一个虚拟路由器。在VLAN或接口上,最多可以有255个备用组
   如下图,路由器A和路由器B都是HSRP组1和2的成员,然而,路由器A是HSRP组1的活跃路由器和HSRP组2的备用路由器;而路由器B是HSRP组2的活跃路由器和HSRP组1的备用路由器。
 
配置过程:
默认配置
特性      默认配置
--------------------------------
HSRP组                未定义
备用组编号         0
备用组MAC地址         0000.0c07.acXX, XX是HSRP组号
优先级                 100
延时                 0(没有延时)
跟踪端口的优先级 10
HELLO时间         3秒
HOLD时间         10秒
配置要求:
1. HSRP最多可以配置32个VLAN或路由接口
2. 配置接口必须是3层接口
路由接口:接口使用no switchport,并且配置ip地址
SVI(交换虚拟接口):使用命令interface vlan vlan号
3层以太网通道(EtherChannel)
3. 所有3层接口都必须配置IP地址
配置HSRP
1) 进入全局模式   configure terminal
2) 进入接口模式   interface 接口
3) 使能HSRP,指定热备份组的组号和虚拟IP 地址
    standby 组号 ip IP地址
    组号:取值为0-255,如果是一个备用组,可以不输入组号,默认为0
    ip地址:是虚拟的Ip地址,不能为接口上的地址
4) 指定备用组的优先级别
    standby 组号 priority 优先级别
    优先级:取值为1-255,默认为100,数值越大级别越高
5) 指定抢占模式,当活动路由器失效后,备份路由器马上替换为活动路由器,不需要时间等待(hold time)
     standby 组号 preempt [delay 秒数]
  d  elay:取值为0-3600(1小时)
6) 设置端口跟踪(可选)
    standby 组号 track 端口号 降低的优先级别
    降低的优先级别:默认为10
7) 人工指定虚拟mac地址(可选)
    standby 组号 mac mac地址
8) 使用实际接口的mac地址(可选,只有25系列路由器使用)
    standby 组号 use-bia
9) 配置认证(可选)
    standby 组号 authentication mode text 密码
    密码:密码是明文,默认为cisco
    注意:对于IOS12.3以上的版本中,HSRP支持MD5的认证,具体配置命令为
    standby 组号 authentication md5 key-string 密码
10)配置HSRP时间(可选)
    standby 组号 timers hello秒数 hold秒数
    hello秒数:取值为1-255,默认为3秒
    hold秒数:取值为1-255,默认为10秒,hold time= 3*hello time
检验和调试:
检验:
    show standby [接口 [组]][active|init|listen|standby][brief]
如:
    show standby Ethernet0 init brief
调试:
    debug standby:显示所有的HSRP错误、事件和数据包
    debug standby terse :显示除hello和通告以外的所有HSRP错误、事件和数据包
    debug standby events detail:显示HSRP事件
    debug standby error:显示HSRP错误
    debug standby packets [advertise|coup|hello|resign][detail]
案例:
sw1(config)#int vlan 10
sw1(config-if)#ip address 192.168.1.1 255.255.255.0
sw1(config-if)#standby 1 ip 192.168.1.254
sw1(config-if)#standby 1 priority 110
-----------------------------------------------------
sw2(config)#int vlan 10
sw2(config-if)#ip address 192.168.1.2 255.255.255.0
sw2(config-if)#standby 1 ip 192.168.1.254
sw2(config-if)#standby 1 priority 100
------------------------------------------------------
SW1#show standby
Vlan10 - Group 1
  State is Active
    2 state changes, last state change 00:02:38
  Virtual IP address is 192.168.1.254
  Active virtual MAC address is 0000.0c07.ac01
    Local virtual MAC address is 0000.0c07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.124 secs
  Preemption enabled
  Active router is local
  Standby router is 192.168.1.2, priority 100 (expires in 7.992 sec)
  Priority 110 (configured 110)
  IP redundancy name is "hsrp-Vl10-1" (default)
---------------------------------------------------------
SW2#show standy
Vlan10 - Group 1
  State is Standby
    1 state change, last state change 00:02:32
  Virtual IP address is 192.168.1.254
  Active virtual MAC address is 0000.0c07.ac01
    Local virtual MAC address is 0000.0c07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.328 secs
  Preemption enabled
  Active router is 192.168.1.1, priority 110 (expires in 9.456 sec)
  Standby router is local
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Vl10-1" (default)
SW1#show stan brie
                     P indicates configured to preempt.
                     |
Interface   Grp Prio P State    Active          Standby         Virtual IP    
V10           1   110  P Active   local           192.168.1.2     192.168.1.254 
多组HSRP备用组
 
Router A Configuration
Switch# configure terminal
Switch(config)# interface gigabitethernet0/1
Switch(config-if)# no switchport
Switch(config-if)# ip address 10.0.0.1 255.255.255.0
Switch(config-if)# standby 1 ip 10.0.0.3
Switch(config-if)# standby 1 priority 110
Switch(config-if)# standby 1 preempt
Switch(config-if)# standby 2 ip 10.0.0.4
Switch(config-if)# standby 2 preempt
Switch(config-if)# end
Router B Configuration
Switch# configure terminal
Switch(config)# interface gigabitethernet0/1
Switch(config-if)# no switchport
Switch(config-if)# ip address 10.0.0.2 255.255.255.0
Switch(config-if)# standby 1 ip 10.0.0.3
Switch(config-if)# standby 1 preempt
Switch(config-if)# standby 2 ip 10.0.0.4
Switch(config-if)# standby 2 priority 110
Switch(config-if)# standby 2 preempt
Switch(config-if)# end
案例:
CCIE-LAB(V160)
题目要求:
Configure HSRP on R3 and R4 for hosts on VLAN A:Carefully read the requirements:
There are 10 hosts on VLAN A。5 Windows PC’s and 5 Unix workstations
The Windows PC’s are configured to use 160.YY.10.50 as their default gateway
The UNIX workstations are configured to use 160.YY.10.100 as their default gateway
R3 is the preferred router for Windows users.
R4 is the prefered router for Unix users.
If the frame relay connection on R3 goes down,then R4 becomes the preferred router for all users。
If the frame relay connection on R4 goes down,then R3 becomes the preferred router for all users。
Once either R3 or R4 recover from a failure then the network must operate as outined
above,I.e Each router must resume their original role。
 
配置:
R3
   config termi
   interface f0/0
   standby 1 ip 160.11.10.50
   standby 1 priority 110
   standby 1 track s0/0  20
   standby 1 preempt
   standby 2 ip 160.11.10.100
   standby 2 preempt
R4
   config termi
   interface f0/0
   standby 1 ip 160.11.10.50
   standby 1 preempt
   standby 2 ip 160.11.10.100
   standby 2 priority 110
   standby 2 track s0/0  20
   standby 2 preempt
Trunk链路上的HSRP
此项功能能通过在子网和VLAN间提供负载均衡和冗余能力提高整个网络的韧性。我们可以实现通过两个路由器来实现在干道上的互为活跃/备份路由器。我们只要设置一下他们在HSRP中的优先级就可以实现。
配置步骤:
1. 定义封装类型和vlan
如:
interface f0/0.10
encapaulation isl 10
interface f0/0.20
encapaulation isl 20
        2.分配IP地址
          如:
interface f0/0.10
ip address 10.10.10.2 255.255.255.0
interface f0/0.20
ip address 10.10.20.2 255.255.255.0
        3.启动HSRP
          如:
inteface f0/0.10
standby 1 ip 10.10.10.254
standby 1 priority 105
standby 1 preempt
interface f0/0.20
standby 2 ip 10.10.20.254
standby 2 priority 90
新:HSRP2
在CISCO IOS 12.3以上的版本中,HSRP支持V2的版本。HSRP V2和HSRP V1命令上没有什么不同,只是HSRP V2所支持的组号进行了扩展,HSRP V1只支持0-255个组,而HSRP V2可以支持0-4095个组,主要是应用在它可以支持匹配在子接口上的VLAN号(扩展的VLAN可以支持到4094个)
HSRP V1和HSRP V2不能同时在一个接口上启用,但是在同一台路由器上的不同接口上,可以应用不同版本的HSRP
配置过程:
1) 进入全局模式   configure terminal
2) 进入接口模式   interface 接口
3) 启用HSRP版本2
  standby version 2
4) 配置HSRP
  standby 组号 ip ip地址
  组号:取值范围0-4095
案例:
RouterA#configure terminal
RouterA(config)#interface f0/0        
RouterA(config-if)#standby version 2                 
RouterA(config-if)#standby 4095 ip 10.1.1.1          
RouterA(config-if)#standby 4095 timers msec 15 msec 50
RouterA(config-if)#standby 4095 priority 200         
RouterA(config-if)#standby 4095 preempt              
-----------------------------------------------------------
RouterB#configure terminal
RouterB(config)#interface f0/0        
RouterB(config-if)#standby version 2                 
RouterB(config-if)#standby 4095 ip 10.1.1.1          
RouterB(config-if)#standby 4095 timers msec 15 msec 50
RouterB(config-if)#standby 4095 preempt              
------------------------------------------------------------
RouterA#show standby
FastEthernet0/0 - Group 4095 (version 2)
  State is Active
    2 state changes, last state change 00:11:47
  Virtual IP address is 10.1.1.1
  Active virtual MAC address is 0000.0c9f.ffff
    Local virtual MAC address is 0000.0c9f.ffff (v2 default)
  Hello time 15 msec, hold time 50 msec
    Next hello sent in 0.007 secs
  Preemption enabled
  Active router is local
  Standby router is 10.1.1.3, priority 100 (expires in 0.030 sec)
  Priority 200 (configured 200)
  IP redundancy name is "hsrp-Fa0/0-4095" (default)
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章