一、拓扑图:

二、单组的
HSRP配置及说明:
1、用路由器模拟三层交换机,同时
R1和
R2中的回环接口模拟某主机与
R1、
R2直连。
R1(config-line)#int lo0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#int f0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R2(config-line)#int lo0
R2(config-if)#ip add 10.1.1.1 255.255.255.0
R2(config-if)#int f0/0
R2(config-if)#ip add 192.168.1.3 255.255.255.0
PC1(config)#no ip routing
PC1(config)#ip default-gateway 192.168.1.1 (网关配置为HSRP虚拟的网关地址)
PC1(config)#int f0/0
PC1(config-if)#no sh
PC1(config-if)#ip add 192.168.1.10 255.255.255.0
|
2、为了有效的确保网关的冗余,我们在
R1和
R2上配置
HSRP协议:
R1(config-if)#standby ip 192.168.1.1(设置组0虚拟IP,在standby后面不跟组时,默认为0组)
R2(config-if)#standby ip 192.168.1.1
|
3、启用
HSRP组
0之后,
IOS指出当前
R1为
active路由器,负责
arp响应和三层路由任务:
*Mar 1 00:33:23.963: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Standby -> Active
|
4、查看一下
R1和
R2的
standby 信息:
R1(config-if)#do sh standby
FastEthernet0/0 - Group 0 (指出为组)
State is Active (指出当前为活动状态)
2 state changes, last state change 00:11:49
Virtual IP address is 192.168.1.1(指出虚拟路由器IP为192.168.1.1,也为客户端指定的网关)
Active virtual MAC address is 0000.0c07.ac00(虚拟路由器的MAC地址)
Local virtual MAC address is 0000.0c07.ac00 (v1 default)
Hello time 3 sec, hold time 10 sec(HSRP的HELLO发送周期和保持时间用于监测ACTIVE路由器状态)
Next hello sent in 1.672 secs
Preemption disabled (强占没有开启)
Active router is local
Standby router is 192.168.1.3, priority 100 (expires in 8.864 sec)(指出备份路由器IP和优先级)
Priority 100 (default 100) (在没有指定优先级的情况下,都为100)
IP redundancy name is "hsrp-Fa0/0-0" (default)
R2#sh standby
FastEthernet0/0 - Group 0
State is Standby (状态为备份)
1 state change, last state change 00:00:29
Virtual IP address is 192.168.1.1
Active virtual MAC address is 0000.0c07.ac00
Local virtual MAC address is 0000.0c07.ac00 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.668 secs
Preemption disabled
Active router is 192.168.1.2, priority 100 (expires in 9.656 sec)(指出活动路由器IP和优先级)
Standby router is local
Priority 100 (default 100)
IP redundancy name is "hsrp-Fa0/0-0" (default)
|
5、
HSRP组中的每台路由器均会带有一个优先级。优先级会影响哪一台路由器成为
active路由器,用于响应客户端的
ARP请求。如果在
HSRP刚启动,而且每台路由器的优先级均相同,则会优先选择接口
IP较高的为
ACTIVE路由器。但如果在一台路由器配置好之后再去配置另一台,且是优先级相同
,那么会选择先配置的那台路由器成为
active路由器。这里路由器就选择了
R1成为
active。
6、在
PC1上
traceroute一下
10.1.1.1,并查一下
ARP信息:
PC1#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.2 32 msec * 32 msec (因为R1为active,所以它选择了走R1)
PC1#sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 192.168.1.10 - cc00.0a88.0000 ARPA FastEthernet0/0
Internet 192.168.1.1 29 0000.0c07.ac00 ARPA FastEthernet0/0(看到虚拟网关的IP地址和MAC地址,其中MAC含义:0000.0c为cisco厂商标识,07.ac为HSRP组标识,01为HSRP组号)
|
7、为了查看
HSRP的冗余作用我们使用扩展
ping 向
10.1.1.1/24发送较多的包,并且把
R1的
F0/0 down掉,我们发现丢了两个包之后转向冗余路由器了:
PC1#ping
Protocol [ip]:
Target IP address: 10.1.1.1
Repeat count [5]: 100000
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 100000, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!..!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(丢了两个包后又起来了)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.(这里还有一个包)
Success rate is 99 percent (2142/2145), round-trip min/avg/max = 1/9/64 ms
PC1#
R1(config)#int f0/0
R1(config-if)#shut (手动down掉f0/0)
PC1#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.3 40 msec * 40 msec (跟踪命令发现下一跳为R2了)
|
8、下面我们把
R1的
F0/0置为
up后,过一段时间后发现
R1还是
standby角色:
R1(config)#int f0/0
R1(config-if)#no sh
R1#
*Mar 1 01:44:39.779: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Speak -> Standby
R1#sh standby
FastEthernet0/0 - Group 0
State is Standby
4 state changes, last state change 00:04:35
Virtual IP address is 192.168.1.1
Active virtual MAC address is 0000.0c07.ac00
Local virtual MAC address is 0000.0c07.ac00 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.464 secs
Preemption disabled
Active router is 192.168.1.3, priority 100 (expires in 8.172 sec) (指出活动路由器为R2)
Standby router is local
Priority 100 (default 100)
IP redundancy name is "hsrp-Fa0/0-0" (default)
|
9、但如果
R1这台性能比较好,
R2只想让它在
R1出问题的情况下顶替上来,因此更希望当
R1恢复时,能够负责
ARP的响应和三层路由任务。那么我们要为
R1配置较高的优先级,并且配置
HSRP抢占功能:
R1(config)#int f0/0
R1(config-if)#standby priority 120 (设置R1的HSRP优先级为120)
R1(config-if)#standby preempt (开启HSRP的抢占功能)
*Mar 1 09:37:03.313: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Standby -> Active
(配置完之后,提示信息马上就显示了状态从standby变成active)
|
10、如果
R1的上行链路
lo0 down的话,而
PC1将不会意识到走
R1将会不通。会继续把
R1当作下一跳,但
HSRP除了能够对下行链路实施冗余,同时也可以对上行链路进行监测。所以为了确保万无一失,我们需要对上行链路进行跟踪:
R1(config-if)#standby track lo0 30
(对loopback0跟踪,如果发现有问题,优先级将会降30,那么将是120-30=90,比R2的100低,这样R2将会成为active。)
|
11、把
R1上的
loopback0 down掉之后
,看到
HSRP的显示
R1状态变成
standby:
R1(config-if)#do sh standby
FastEthernet0/0 - Group 0
State is Standby (跟踪端口down后,接口优先级降30。Hello包接收到更高的优先级,新状态standby)
15 state changes, last state change 00:00:42
Virtual IP address is 192.168.1.1
Active virtual MAC address is 0000.0c07.ac00
Local virtual MAC address is 0000.0c07.ac00 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.580 secs
Preemption enabled
Active router is 192.168.1.3, priority 100 (expires in 8.604 sec)
Standby router is local
Priority 90 (configured 120)
Track interface Loopback0 state Down decrement 30 (配置的跟踪)
IP redundancy name is "hsrp-Fa0/0-0" (default)
|
本文转自wxs-163 51CTO博客,原文链接:
http://blog.51cto.com/supercisco/288456