FHRPs(第一跳冗余协议):
第一跳冗余协议FHRP(first hop redundancy protocol):
主要是用来解决网关问题,提高了默认网关的冗余性和负载均衡;其方法是让多台路由器组成一个组并虚拟出一个网关,让其中的一台路由器充当活跃的网关路由器,而另一台或多台其它路由器则处于备用模式;PC通过连接虚拟网关访问外网,当主备路由器进行切换时,由于虚拟路由器没有改变,所以主机仍然保持连接,没有受到故障的影响;当然也可以实现基于多台路由器的冗余备份或负载均衡;在可以使用第一跳冗余协议之前,网关的冗余性依赖于静态网关配置和代理ARP。
在思科的网络设备上,有三种解决方案,包括热备用路由器协议HSRP、虚拟路由器冗余协议VRRP和网关负载均衡协议GLBP。
HSRP,VRRP,GLBP:
协议 | 名称 | 标准 |
---|---|---|
HSRP | 热备用路由器协议 | 思科私有协议 |
VRRP | 虚拟路由器冗余协议 | 标准协议 |
GLBG | 网关负载均衡协议 | 思科私有协议 |
HSRP协议配置:
R1:
Router(config)#int g0/0/1
Router(config-if)#standby version 2 #设置HSRP版本为版本2
Router(config-if)#standby 10 ip 192.168.0.254 #设置虚拟ip
Router(config-if)#
%HSRP-6-STATECHANGE: GigabitEthernet0/0/1 Grp 10 state Init -> Init
Router(config-if)#standby 10 priority 109 #设置standby 10组的优先级是109,默认值为100
Router(config-if)#standby 10 preempt #设置占先权,如果
Router(config-if)#standby 10 timers 1 3 #设置hello time计时器为1s,hold time为3s
Router(config-if)#standby 10 track g0/0/0 #设置端口追踪,但这个端口故障时,则这个组的standby
优先级降低10,变为99,小于另一个R2的优先级,R1就会变为备份路由,这样就实现了切换功能
PT模拟器不支持standby 10 track g0/0/0 [10]自定义降低的数值
Router(config-if)#do show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Gig0/0/1 10 109 P Active local 192.168.0.5 192.168.0.254
Router(config-if)#int g0/0/0
Router(config-if)#standby version 2
Router(config-if)#standby 20 ip 1.1.1.254
Router(config-if)#
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 20 state Init -> Init
Router(config-if)#standby 20 priority 109
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 20 state Speak -> Standby
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 20 state Standby -> Active
Router(config-if)#standby 20 priority 109
Router(config-if)#standby 20 preempt
Router(config-if)#standby 20 timers 1 3
Router(config-if)#standby 20 track g0/0/1
Router(config-if)#do show standby br #显示HSRP状态
Router(config-if)#do show standby br
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Gig0/0/0 20 109 P Active local 1.1.1.2 1.1.1.254
Gig0/0/1 10 109 P Active local 192.168.0.5 192.168.0.254
Router(config-if)#
R2:
Router(config)#int g0/0/1
Router(config-if)#standby version 2
Router(config-if)#standby 10 ip 192.168.0.254
Router(config-if)#
%HSRP-6-STATECHANGE: GigabitEthernet0/0/1 Grp 10 state Init -> Init
Router(config-if)#standby 10 priority
%HSRP-6-STATECHANGE: GigabitEthernet0/0/1 Grp 10 state Speak -> Standby
Router(config-if)#standby 10 priority 100
Router(config-if)#standby 10 preempt
Router(config-if)#standby 10 timers 1 3
Router(config-if)#do show stand
GigabitEthernet0/0/1 - Group 10 (version 2)
State is Standby
5 state changes, last state change 03:25:52
Virtual IP address is 192.168.0.254
Active virtual MAC address is 0000.0C9F.F00A
Local virtual MAC address is 0000.0C9F.F00A (v2 default)
Hello time 1 sec, hold time 3 sec
Next hello sent in 0.052 secs
Preemption enabled
Active router is 192.168.0.1
Standby router is local
Priority 100 (default 100)
Group name is hsrp-Gig0/0/1-10 (default)
Router(config-if)#do show standby bri
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Gig0/0/1 10 100 P Standby 192.168.0.1 local 192.168.0.254
Router(config-if)#int g0/0/0
Router(config-if)#standby version 2
Router(config-if)#standby 20 ip 1.1.1.254
Router(config-if)#
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 20 state Init -> Init
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 20 state Speak -> Standby
Router(config-if)#standby 20 priority 100
Router(config-if)#standby 20 preempt
Router(config-if)#standby 20 timers 1 3
Router(config-if)#do show stand brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Gig0/0/0 20 100 P Standby 1.1.1.1 local 1.1.1.254
Gig0/0/1 10 100 P Standby 192.168.0.1 local 192.168.0.254
R3:
Router(config)#ip route 192.168.0.0 255.255.255.0 1.1.1.254 #添加一条静态路由
配置完成:
把R1的g0/0/1的端口关闭: