今天分析了一下多组的HSRP(MHSRP)。搭了个拓扑,下面分享一下过程。我们知道HSRP能实现网络的冗余,那么HSRP能实现网络的负载吗?下面通过一个实验来分析并实践一下多组的HSRP(MHSRP)。
一、拓扑图:
二、实验步骤与说明:
1、
R1的配置:
R1(config-if)#int lo0
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-line)#int f0/0
R1(config-if)#no sh
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#standby ip 192.168.1.1
R1(config-if)#standby priority 120 (默认为0组,配置接口优先级为120)
R1(config-if)#standby preempt (配置抢占)
R1(config-if)#standby track lo0 30 (跟踪loopback0口,down后优先级降30)
R1(config-if)#standby 1 ip 192.168.1.254 (配置组1的虚拟网关地址,以备下游负载使用)
R1(config-if)#standby 1 priority 100(再设定组1接口优先级为100,100为默认,这步可省)
R1(config-if)#standby 1 preempt (同样配置抢占)
|
2、根据
R1组
0的配置对应地配置
R2:
R2(config-if)#int lo0
R2(config-if)#ip add 10.1.1.1 255.255.255.0
R2(config-if)#int f0/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.1.3 255.255.255.0
R2(config-if)#standby ip 192.168.1.1
R2(config-if)#standby priority 100
R2(config-if)#standby preempt
R2(config-if)#standby 1 ip 192.168.1.254
R2(config-if)#standby 1 priority 120
R2(config-if)#standby 1 preempt
R2(config-if)#standby 1 track lo0 30
|
3、查看一下
R1和
R2的
standby 摘要信息:
R1#sh standby bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 0 120 P Active local 192.168.1.3 192.168.1.1
Fa0/0 1 100 P Standby 192.168.1.3 local 192.168.1.254
R2#sh standby bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 0 100 P Standby 192.168.1.2 local 192.168.1.1
Fa0/0 1 120 P Active local 192.168.1.2 192.168.1.254
|
4、配置客户端
PC1和
PC2,为了实现负载,我们把
PC1的网关配置成
0组的
virtual ip。把
PC2指向
1组的
virtual ip。
PC1(config)#no ip routing
PC1(config)#ip default-gateway 192.168.1.1 (指定PC1默认网关为组0的虚拟IP)
PC1(config)#int f0/0
PC1(config-if)#no sh
PC1(config-if)#ip add 192.168.1.10 255.255.255.0
PC2(config)#no ip routing
PC2(config)#ip default-gateway 192.168.1.254
PC2(config)#int f0/0
PC2(config-if)#no sh
PC2(config-if)#ip add 192.168.1.20 255.255.255.0 (指定PC2默认网关为组1的虚拟IP)
|
三、验证一下效果:
1、在
PC1上
traceroute目标地址,发现下一跳为
R1,PC2上
traceroute 目标地址,发现下一跳为
R2。有效地实验了负载:
PC1#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.2 28 msec * 24 msec
PC2#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.3 28 msec * 44 msec
|
2、在
R1上把
loopback 0 shutdown 并开启
debug 查看一下
standby 的信息,看一下冗余情况:
R1#debug standby events
HSRP Events debugging is on
R1#config t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int lo0
R1(config-if)#shut
R1(config-if)#
*Mar 1 00:39:25.323: %TRACKING-5-STATE: 1 interface Lo0 line-protocol Up->Down
R1(config-if)#
*Mar 1 00:39:25.327: HSRP: Fa0/0 Grp 0 Track 1 object changed, state Up -> Down
*Mar 1 00:39:25.331: HSRP: Fa0/0 Grp 0 Priority 120 -> 90
R1(config-if)#
*Mar 1 00:39:27.323: %LINK-5-CHANGED: Interface Loopback0, changed state to administratively down
*Mar 1 00:39:28.011: HSRP: Fa0/0 Grp 0 Ignoring Coup (100/192.168.1.3 < 120/192.168.1.2)
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Hello in 192.168.1.3 Active pri 100 vIP 192.168.1.1
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active router is 192.168.1.3, was local
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Standby router is unknown, was 192.168.1.3
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active: g/Hello rcvd from higher pri Active router (100/192.168.1.3)
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Active -> Speak
*Mar 1 00:39:28.051: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Active -> Speak
*Mar 1 00:39:28.051: HSRP: Fa0/0 Grp 0 Redundancy "hsrp-Fa0/0-0" state Active -> Speak
*Mar 1 00:39:28.067: HSRP: Fa0/0 API MAC address update
R1(config-if)#
*Mar 1 00:39:28.323: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to down
R1(config-if)#
*Mar 1 00:39:38.051: HSRP: Fa0/0 Grp 0 Speak: d/Standby timer expired (unknown)
*Mar 1 00:39:38.055: HSRP: Fa0/0 Grp 0 Standby router is local (马上变成standby)
*Mar 1 00:39:38.055: HSRP: Fa0/0 Grp 0 Speak -> Standby
*Mar 1 00:39:38.059: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 0 state Speak -> Standby
R1(config-if)#
*Mar 1 00:39:38.059: HSRP: Fa0/0 Grp 0 Redundancy "hsrp-Fa0/0-0" state Speak -> Standby
|
3、在
R2上把
loopback0 shutdown 之后,再查看一下
standby,发现也实现了冗余:
R2(config)#int lo0
R2(config-if)#shut
R2(config-if)#do sh standby
FastEthernet0/0 - Group 0
State is Standby
6 state changes, last state change 00:00:05
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.636 secs
Preemption enabled
Active router is 192.168.1.2, priority 120 (expires in 9.864 sec)
Standby router is local
Priority 100 (default 100)
IP redundancy name is "hsrp-Fa0/0-0" (default)
FastEthernet0/0 - Group 1
State is Standby
5 state changes, last state change 00:00:03
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 2.228 secs
Preemption enabled
Active router is 192.168.1.2, priority 100 (expires in 8.304 sec)
Standby router is local
Priority 90 (configured 120)
Track interface Loopback0 state Down decrement 30
IP redundancy name is "hsrp-Fa0/0-1" (default)
|
4、再在
PC2上跟踪一下路径并检查是否能
ping 通:
PC2#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
1 192.168.1.2 40 msec * 40 msec
PC2#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:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/20/40 ms
PC2#
|
四、总结:通过上述的实验与分析,发现多组的
HSRP(
MHSRP),不但能实现网络的冗余,而且还能实现网络的负载。
本文转自wxs-163 51CTO博客,原文链接:http://blog.51cto.com/supercisco/289010