您的位置:首页 > 理论基础 > 计算机网络

通过多组的HSRP实现网络的冗余和负载 推荐

2010-03-29 11:41 441 查看
[align=left] 今天分析了一下多组的HSRP(MHSRP)。搭了个拓扑,下面分享一下过程。我们知道HSRP能实现网络的冗余,那么HSRP能实现网络的负载吗?下面通过一个实验来分析并实践一下多组的HSRP(MHSRP)。[/align]
[align=left] [/align]
[align=left]一、拓扑图:[/align]



[align=left] [/align]
[align=left] [/align]
[align=left] [/align]

二、实验步骤与说明:

[align=left]1、R1的配置:[/align]

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 (同样配置抢占)
[align=left] [/align]
[align=left]2、根据R1组0的配置对应地配置R2:[/align]

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
[align=left] [/align]
[align=left]3、查看一下R1和R2的standby 摘要信息:[/align]

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
[align=left] [/align]
[align=left]4、配置客户端PC1和PC2,为了实现负载,我们把PC1的网关配置成0组的virtual ip。把PC2指向1组的virtual ip。[/align]

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)
[align=left] [/align]
三、验证一下效果:

[align=left]1、在PC1上traceroute目标地址,发现下一跳为R1,PC2上traceroute 目标地址,发现下一跳为R2。有效地实验了负载:[/align]

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
[align=left] [/align]
[align=left]2、在R1上把loopback 0 shutdown 并开启debug 查看一下standby 的信息,看一下冗余情况:[/align]

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
[align=left] [/align]
[align=left]3、在R2上把loopback0 shutdown 之后,再查看一下standby,发现也实现了冗余:[/align]

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)
[align=left] [/align]
[align=left]4、再在PC2上跟踪一下路径并检查是否能ping 通:[/align]

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#
[align=left] [/align]
[align=left]四、总结:通过上述的实验与分析,发现多组的HSRP(MHSRP),不但能实现网络的冗余,而且还能实现网络的负载。[/align]
[align=left] [/align]

[align=left] [/align]
[align=left] [/align]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息