网关冗余之HSPR的配置和应用

         所谓的热备份路由协议(HSRP)主要是向我们提供了这样一种机制,它的设计目的主要在于支持IP传输失败情况下的不中断服务。具体说,就是本协议用于在源主机无法动态地学习到首跳路由器IP地址的情况下防止首跳路由的失败。它主要用于多接入,多播和广播局域网(例如以太网)。
      下面做个实验来理解HSPR
 
 
 
 
  按照实验拓扑图配置好基础配置,在 PC ping 10.1.1 .1
PC#
PC#ping 192.168.1.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
 
此时在 R1 R2 中没有运行 HSPR PC 上的网管 192.168.1.1 并不存在。所以 ping 不通
 
R1 R2 间运行 HSRP ,构建虚拟网关
R1(config-if)#standby 1 ip 192.168.1.1
R1(config-if)#
*Mar  1 00:07:04.299: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby    // 配置成功, R1 处于 Standby 状态
R2(config-if)#standby 1 ip 192.168.1.1
R2(config-if)#
*Mar  1 00:10:23.579: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
*Mar  1 00:10:24.079: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active  // 配置成功, R2 处于 Active 状态
 
此时 PC ping 10.1.1 .1
PC#ping 10.1.1 .1     
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1 .1, timeout is 2 seconds:
!!!!!  // 通了
 
查看路径
PC#traceroute 10.1.1 .1
 
Type escape sequence to abort.
Tracing the route to 10.1.1 .1
 
  1  *  *
    192.168.1.3 52 msec   // 是通过 R2 路由器 ping 通的,即 R2 处于 Active 状态,一般说来,在其他因素都相同的情况下, IP 最大的那个路由器将处于 Active 状态
 
查看路由器 R1 和路由器 R2 Standby 信息
R1(config-if)#do sh standby
FastEthernet0/0 - Group 1
  State is Standby          // 此路由器处于 Standy 状态
    1 state change, last state change 00:00:15
  Virtual IP address is 192.168.1.1
  Active virtual MAC address is 0000.0c 07.ac01
    Local virtual MAC address is 0000.0c 07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 2.484 secs
  Preemption disabled
  Active router is 192.168.1.3, priority 100 (expires in 8.804 sec)
  Standby router is local
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Fa0/0-1" (default)
 
 
R2(config-if)#do sh standby
FastEthernet0/0 - Group 1
  State is Active   // 此路由器处于 Standy 状态
    2 state changes, last state change 00:00:59
  Virtual IP address is 192.168.1.1
  Active virtual MAC address is 0000.0c 07.ac01
    Local virtual MAC address is 0000.0c 07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.948 secs
  Preemption disabled
  Active router is local
  Standby router is 192.168.1.2, priority 100 (expires in 4.628 sec)
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Fa0/0-1" (default)
HSRP 组中的每台路由器均会带有一个优先级。优先级会影响哪一台路由器成为 ACTIVE 路由器,用于响应客户端的 ARP 请求。如果在 HSRP 刚启动,而且每台路由器的优先级均相同,则会优先选择接口 IP 较高的为 ACTIVE 路由器
 
 
 
PC ping 10.1.1 .1 多个数据包, ping 中手工 down R2 上的 f0/0 接口
R2(config-if)#shut
R2(config-if)#
*Mar  1 00:11:53.051: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Active -> Init
 
PC#ping 10.1.1 .1 repeat 100
 
R1(config-if)#
*Mar  1 00:12:57.255: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active
 
Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 10.1.1 .1, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
可见在 R2 down 掉后, R1 上的接口已经起作用了
 
R2 f0/0 接口处于 UP 状态
 
此时路由器处于非抢占状态,我们要想让比较强的 R2 在接口起来时继续处于 Active 状态,就应该修改 priority 值,和启动抢占状态
R2(config-if)#standby 1 priority 200
R2(config-if)#standby 1 preempt
R2(config-if)#
*Mar  1 00:16:55.823: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active         // R2 又处于 Active 状态
 
 
R2 的下行线路断后,要想让 R1 马上起用,要有如下配置:
R1(config-if)#standby 1 preempt
 
R2(config-if)#standby 1 track lo0 160 
 
R2 上打开 debug 消息,手工 down Lo0 口查看
R2#debug standby events
HSRP Events debugging is on
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int lo0
R2(config-if)#shut
R2(config-if)#
*Mar  1 00:21:07.647: HSRP: Fa0/0 Grp 1 Track 1 object changed, state Up -> Down
*Mar  1 00:21:07.647: HSRP: Fa0/0 Grp 1 Priority 200 -> 40
*Mar  1 00:21:08.019: HSRP: Fa0/0 Grp 1 Ignoring Coup (100/192.168.1.2 < 200/192.168.1.3)
*Mar  1 00:21:08.031: HSRP: Fa0/0 API arp proto filter, 0000.0c 07.ac01 is active vMAC for grp 1 - filter
*Mar  1 00:21:08.031: HSRP: Fa0/0 Grp 1 Hello  in  192.168.1.2 Active  pri 100 vIP 192.168.1.1
*Mar  1 00:21:08.035: HSRP: Fa0/0 Grp 1 Active router is 192.168.1.2, was local
*Mar  1 00:21:08.035: HSRP: Fa0/0 Grp 1 Standby router is unknown, was 192.168.1.2
*Mar  1 00:21:08.035: HSRP: Fa0/0 Grp 1 Active: g/Hello rcvd from higher pri Active router (100/192.168.1.2)
*Mar  1 00:21:08.035: HSRP: Fa0/0 Grp 1 Active -> Speak
*Mar  1 00:21:08.039: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Active -> Speak
R2(config-if)#
*Mar  1 00:21:08.039: HSRP: Fa0/0 Grp 1 Redundancy "hsrp-Fa0/0-1" state Active -> Speak
*Mar  1 00:21:08.043: HSRP: Fa0/0 API MAC address update
R2(config-if)#
*Mar  1 00:21:09.643: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
*Mar  1 00:21:10.643: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down
R2(config-if)#
*Mar  1 00:21:18.035: HSRP: Fa0/0 Grp 1 Speak: d/Standby timer expired (unknown)
*Mar  1 00:21:18.035: HSRP: Fa0/0 Grp 1 Standby router is local
*Mar  1 00:21:18.035: HSRP: Fa0/0 Grp 1 Speak -> Standby
*Mar  1 00:21:18.035: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
R2(config-if)#
*Mar  1 00:21:18.039: HSRP: Fa0/0 Grp 1 Redundancy "hsrp-Fa0/0-1" state Speak -> Standby
 
 
  R1(config-if)#
*Mar  1 00:12:57.255: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active   // 此时 R1 处于 Active   状态
 
查看 R1 R2 standy 的信心
R1(config-if)#do sh standby          
FastEthernet0/0 - Group 1
  State is Active
    8 state changes, last state change 00:00:26
  Virtual IP address is 192.168.1.1
  Active virtual MAC address is 0000.0c 07.ac01
    Local virtual MAC address is 0000.0c 07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 0.732 secs
  Preemption enabled
  Active router is local  // 处于 Active 状态
  Standby router is 192.168.1.3, priority 40 (expires in 9.216 sec)
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Fa0/0-1" (default)
 
R2(config-if)#do sh standby
FastEthernet0/0 - Group 1
  State is Standby  // 此时处于 Standby 状态
    10 state changes, last state change 00:00:19
  Virtual IP address is 192.168.1.1
  Active virtual MAC address is 0000.0c 07.ac01
    Local virtual MAC address is 0000.0c 07.ac01 (v1 default)
  Hello time 3 sec, hold time 10 sec
    Next hello sent in 1.252 secs
  Preemption enabled
  Active router is 192.168.1.2, priority 100 (expires in 8.088 sec)
  Standby router is local
  Priority 40 (configured 200)  // Priority 变成 40
    Track interface Loopback0 state Down decrement 160
  IP redundancy name is "hsrp-Fa0/0-1" (default)
 

你可能感兴趣的:(职场,休闲,HSRP)