赞
踩
HSRP:热备份路由器协议(HSRP:Hot Standby Router Protocol),是cisco平台一种特有的技术,是cisco的私有协议。
该协议中含有多台路由器,对应一个HSRP组。该组中只有一个路由器承担转发用户流量的职责,这就是活动路由器。当活动路由器失效后,备份路由器将承担该职责,成为新的活动路由器。这就是热备份的原理。百度百科
备份的是网关。
两台PC IP配置
两个网关配置IP+开启端口
R1-GW
Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ho R1-GW R1-GW(config)# R1-GW(config)# R1-GW(config)#int f0/0 R1-GW(config-if)#ip add 192.168.1.252 255.255.255.0 R1-GW(config-if)#no shut R1-GW(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R1-GW(config-if)#exit R1-GW(config)#int f0/1 R1-GW(config-if)#ip add 10.1.1.1 255.255.255.0 R1-GW(config-if)#no shut R1-GW(config-if)#exit R1-GW(config)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.1.252 YES manual up up FastEthernet0/1 10.1.1.1 YES manual up up Vlan1 unassigned YES unset administratively down down
R2-GW
Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ho R2-GW R2-GW(config)#int f0/0 R2-GW(config-if)#ip add 192.168.1.253 255.255.255.0 R2-GW(config-if)#no shut R2-GW(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R2-GW(config-if)# R2-GW(config-if)#exit R2-GW(config)#int f0/1 R2-GW(config-if)#ip add 20.1.1.1 255.255.255.0 R2-GW(config-if)#no shut R2-GW(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up R2-GW(config-if)#exit R2-GW(config)# %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R2-GW(config)# R2-GW(config)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.1.253 YES manual up up FastEthernet0/1 20.1.1.1 YES manual up up Vlan1 unassigned YES unset administratively down down
R-waiwang
Router> Router>en Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ho R-waiwang R-waiwang(config)#int f0/0 R-waiwang(config-if)#ip add 10.1.1.2 255.255.255.0 R-waiwang(config-if)#no shut R-waiwang(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R-waiwang(config-if)#exit R-waiwang(config)#int f0/1 R-waiwang(config-if)#ip add 20.1.1.2 255.255.255.0 R-waiwang(config-if)#no shut R-waiwang(config-if)# %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R-waiwang(config-if)#exit R-waiwang(config)#int f0/3 %Invalid interface type and number R-waiwang(config)#int f1/0 R-waiwang(config-if)#ip add 30.1.1.254 255.255.255.0 R-waiwang(config-if)#no shut R-waiwang(config-if)# %LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up R-waiwang(config-if)#exit R-waiwang(config)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 10.1.1.2 YES manual up up FastEthernet0/1 20.1.1.2 YES manual up up FastEthernet1/0 30.1.1.254 YES manual up up FastEthernet1/1 unassigned YES unset administratively down down Vlan1 unassigned YES unset administratively down down
外网PC
R1-GW
R1-GW(config)#ip route 0.0.0.0 0.0.0.0 10.1.1.2
R2-GW
R1-GW(config)#ip route 0.0.0.0 0.0.0.0 20.1.1.2
R-waiwang
为了体现实验,我们如果将R1接口down掉,PC可以使用备份路由上网,所以我们要将外网路由的下一跳IP指向R2的F0/1的IP
R-waiwang(config)#ip route 0.0.0.0 0.0.0.0 20.1.1.1
R-waiwang(config)#do show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is 20.1.1.1 to network 0.0.0.0 10.0.0.0/24 is subnetted, 1 subnets C 10.1.1.0 is directly connected, FastEthernet0/0 20.0.0.0/24 is subnetted, 1 subnets C 20.1.1.0 is directly connected, FastEthernet0/1 30.0.0.0/24 is subnetted, 1 subnets C 30.1.1.0 is directly connected, FastEthernet1/0 S* 0.0.0.0/0 [1/0] via 20.1.1.1
R1-活跃路由器
R1-GW(config)#int f0/0
R1-GW(config-if)#standby 1 ip 192.168.1.254 创建热备份组号为1,虚拟网关IP为192.168.1.254
%HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
%HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active
R1-GW(config-if)#standby 1 priority 200 设置优先级为200
R1-GW(config-if)#standby 1 preempt 设置占先权
R1-GW(config-if)#standby 1 track f0/1 跟踪f0/1接口
查看热备份配置信息
R1-GW#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Fa0/0 1 200 Active local 192.168.1.253 192.168.1.254
R2-备份路由器
R2-GW(config)#int f0/0
R2-GW(config-if)#standby 1 ip 192.168.1.254
R2-GW(config-if)#standby 1 priority
%HSRP-6-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby
R2-GW(config-if)#standby 1 priority 195
R2-GW(config-if)#standby 1 preempt
查看热备份配置信息
R2-GW#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Fa0/0 1 195 P Standby 192.168.1.252 local 192.168.1.254
R2-GW#
我们进入活跃路由器将网关接口f0/0,down掉,备份路由器每隔一段时间会与活跃路由器进行通信(检测端口是否正常),当检测到活跃路由器异常时会自动升级为活跃路由器,如果活跃路由器的故障修复重新启动,那么会重新接管活跃路由器的身份,备份路由器会自动降级。
也就是说活跃路由器故障那么会由备份路由器接管,故障修复后备份路由器会回到原来的位置。
备份路由器的身份转变取决于活跃路由器是否出现异常。
C:\>ping -t 30.1.1.1 Pinging 30.1.1.1 with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Reply from 30.1.1.1: bytes=32 time=15ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time=12ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Request timed out. Request timed out. Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time=1ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time=1ms TTL=126 Reply from 30.1.1.1: bytes=32 time<1ms TTL=126 Reply from 30.1.1.1: bytes=32 time=1ms TTL=126 Reply from 30.1.1.1: bytes=32 time=1ms TTL=126
将f0/1接口down掉
查看活跃路由器的热备份信息
R1-GW#sh standby brief P indicates configured to preempt. | Interface Grp Pri P State Active Standby Virtual IP Fa0/0 1 190 Standby 192.168.1.253 local 192.168.1.254 R1-GW#sh standby FastEthernet0/0 - Group 1 State is Standby 16 state changes, last state change 03:33:02 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.035 secs Preemption disabled Active router is 192.168.1.253, priority 195 (expires in 9 sec) MAC address is 0000.0C07.AC01 Standby router is local Priority 190 (configured 200) Track interface FastEthernet0/1 state Down decrement 10 Group name is hsrp-Fa0/0-1 (default) R1-GW#
查看备份路由器的热备份信息
R2-GW#sh standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Fa0/0 1 195 P Active local 192.168.1.252 192.168.1.254
R2-GW#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。