美文网首页数通之路
HSRP概念及配置实例

HSRP概念及配置实例

作者: 凯凯凯瑞斯 | 来源:发表于2019-05-20 12:00 被阅读0次

HSRP

HSRP(Hot Standby Router Protocol

热备份路由器协议)是Cisco的专有协议。HSRP把多台路由器组成一个“热备份组”,形成一个虚拟路由器。这个组内只有一个路由器是Active(活动)的,并由它来转发数据包,如果活动路由器发生了故障,备份路由器将成为活动路由器。从网络内的主机来看,网关并没有改变。

HSRP的工作过程:

HSRP路由器利用Hello包来互相监听各自的存在。当路由器长时间没有接收到Hello包时,就认为活动路由器故障,备份路由器就会成为活动路由器。HSRP协议利用优先级决定哪个路由器成为活动路由器。如果一个路由器的优先级比其它路由器的优先级高,则该路由器成为活动路由器。路由器的默认优先级是100。在一个组中,最多有一个活动路由器和一个备份路由器。HSRP路由器发送的组播(224.0.0.2)消息有以下三种:

Hello:通知其它路由器发送者的HSRP优先级和状态信息,HSRP路由器默认每3秒发送一个Hello消息。

Coup:当一个备用路由器变为一个活动路由器时发送一个Coup消息。

Resign:当活动路由器要当机或者当有优先级更高的路由器发送Hello消息时,主动发送一个Resign消息。

HSRP路由器的6中状态:

1.Initial:

HSRP启动时的状态,HSRP还没有运行,一般是在改变配置或端口刚刚启动时进入该状态。

2.Learn:

在该状态下,路由器还没有决定虚拟IP地址,也没有看到认证的、来自活动路由器的Hello报文。路由器仍在等待活动路由器发来的Hello报文。

3.Listen:

路由器已经得到了虚拟IP地址,但是它既不是活动路由器也不是等待路由器。它一直监听从活动路由器和等待路由器发来的Hello报文。

4.Speak:

在该状态下,路由器定期发送Hello报文,并且积极参加活动路由器或等待路由器的竞选。如果选出活动路由和等待路由,则变成监听状态(Listen)。而此时只有活动路由器和等待路由处于说话状态。

5.Standby:

处于该状态的路由器是下一个候选的活动路由器,它定时发送Hello报文。

6.Active:

处于活动状态的路由器承担转发数据包的任务,这些数据包是发给该组的虚拟MAC地址的。它定时发出Hello报文。

HSRP的2个定时器:

HSRP使用2个定时器:Hello间隔Hold时间。默认Hello间隔是3秒,默认的Hold间隔是10秒。Hello间隔定义了两组路由器之间交换信息的频率。Hlod间隔定义了经过多长时间后,没有收到其它路由器的信息,则活动路由器或者备用路由器就会被宣告为失败。配置计时器并不是越小越好,虽然计时器越小则切换时间越短。计时器的配置需要和STP等的切换时间相一致。另外,Hold间隔最少应该是Hello间隔的3倍。

基础配置命令

standby 1 ip A.B.C.D      # 配置hsrp组1的虚拟网关ip地址

standby 1 priority X     #配置设备的优先级

standby 1 preempt  #配置抢占性

standby 1 timers 3 10  #配置hello时间3秒和hold时间10秒

standby 1 authentication md5 key-string Cisco  #配置md5认证密码为Cisco

standby 1 track 1 decrement 30    #监测1若是链路down了 则降低优先级30(例如track 1 interface ethernet 0/0 line-protocol)

实验

HSRP


结果现象

R2 R3 R4网关通了 外网也全部ping通


答案

R1的配置

!

! Last configuration change at 01:55:13 EET Tue Jan 1 2008

!

version 15.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R1

!

boot-start-marker

boot-end-marker

!

aqm-register-fnf

!

!

no aaa new-model

clock timezone EET 2 0

mmi polling-interval 60

no mmi auto-configure

no mmi pvc

mmi snmp-timeout 180

!

!

!

!

!

!

!

!

!

!

ip cef

no ipv6 cef

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

redundancy

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

interface Loopback0

no shutdown

ip address 1.1.1.1 255.255.255.0

!

interface Ethernet0/0

no shutdown

ip address 192.168.2.1 255.255.255.0

!

interface Ethernet0/1

no shutdown

ip address 192.168.3.1 255.255.255.0

!

interface Ethernet0/2

no shutdown

no ip address

shutdown

!

interface Ethernet0/3

no shutdown

no ip address

shutdown

!

router rip

version 2

network 1.0.0.0

network 192.168.2.0

network 192.168.3.0

no auto-summary

!

ip forward-protocol nd

!

!

no ip http server

no ip http secure-server

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

line con 0

logging synchronous

line aux 0

line vty 0 4

login

transport input none

!

!

end

R2的配置

!

! Last configuration change at 02:25:10 EET Tue Jan 1 2008

!

version 15.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R2

!

boot-start-marker

boot-end-marker

!

aqm-register-fnf

!

!

no aaa new-model

clock timezone EET 2 0

mmi polling-interval 60

no mmi auto-configure

no mmi pvc

mmi snmp-timeout 180

!

!

!

!

!

!

!

!

!

!

ip cef

no ipv6 cef

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

redundancy

!

!

track 1 interface Ethernet0/1 line-protocol

!

!

!

!

!

!

!

!

!

!

!

!

!

!

interface Ethernet0/0

no shutdown

ip address 192.168.1.2 255.255.255.0

standby 1 ip 192.168.1.254

standby 1 priority 120

standby 1 preempt

!

interface Ethernet0/1

no shutdown

ip address 192.168.2.2 255.255.255.0

!

interface Ethernet0/2

no shutdown

no ip address

shutdown

!

interface Ethernet0/3

no shutdown

no ip address

shutdown

!

router rip

version 2

network 192.168.1.0

network 192.168.2.0

no auto-summary

!

ip forward-protocol nd

!

!

no ip http server

no ip http secure-server

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

line con 0

logging synchronous

line aux 0

line vty 0 4

login

transport input none

!

!

end

R3的配置

!

! Last configuration change at 02:41:46 EET Tue Jan 1 2008

!

version 15.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R3

!

boot-start-marker

boot-end-marker

!

aqm-register-fnf

!

!

no aaa new-model

clock timezone EET 2 0

mmi polling-interval 60

no mmi auto-configure

no mmi pvc

mmi snmp-timeout 180

!

!

!

!

!

!

!

!

!

!

ip cef

no ipv6 cef

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

redundancy

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

interface Ethernet0/0

no shutdown

ip address 192.168.1.3 255.255.255.0

standby 1 ip 192.168.1.254

standby 1 priority 80

standby 1 preempt

!

interface Ethernet0/1

no shutdown

ip address 192.168.3.3 255.255.255.0

!

interface Ethernet0/2

no shutdown

no ip address

shutdown

!

interface Ethernet0/3

no shutdown

no ip address

shutdown

!

router rip

version 2

network 192.168.3.0

no auto-summary

!

ip forward-protocol nd

!

!

no ip http server

no ip http secure-server

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

line con 0

logging synchronous

line aux 0

line vty 0 4

login

transport input none

!

!

end

R4的配置

!

! Last configuration change at 02:36:45 EET Tue Jan 1 2008

!

version 15.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname R4

!

boot-start-marker

boot-end-marker

!

aqm-register-fnf

!

!

no aaa new-model

clock timezone EET 2 0

mmi polling-interval 60

no mmi auto-configure

no mmi pvc

mmi snmp-timeout 180

no ip routing

!

!

!

!

!

!

!

!

!

!

no ip cef

no ipv6 cef

!

multilink bundle-name authenticated

!

!

!

!

!

!

!

!

!

redundancy

!

!

!

!

!

!

!

!

!

!

!

!

!

!

!

interface Ethernet0/0

no shutdown

ip address 192.168.1.4 255.255.255.0

no ip route-cache

!

interface Ethernet0/1

no shutdown

no ip address

no ip route-cache

shutdown

!

interface Ethernet0/2

no shutdown

no ip address

no ip route-cache

shutdown

!

interface Ethernet0/3

no shutdown

no ip address

no ip route-cache

shutdown

!

ip forward-protocol nd

!

!

no ip http server

no ip http secure-server

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

line con 0

logging synchronous

line aux 0

line vty 0 4

login

transport input none

!

!

end

相关文章

  • HSRP概念及配置实例

    HSRP HSRP(Hot Standby Router Protocol 热备份路由器协议)是Cisco的专有协...

  • 三个情景实验帮你更好的理解HSRP协议

    HSRP协议简介: HSRP(Hot Standby Router Protocol 热备份路由器协议)是Cisc...

  • 思科设备VRRP/HSRP配置

    基础知识:环回接口 环回接口习惯上被称为loopback接口,是路由器上的一个逻辑、虚拟接口。路由器默认没有任何环...

  • HSRP

    一、概念 HSRP是一种网关冗余协议,它通过在冗余网关之间共享协议和MAC,提供不间断的IP路径冗余。 HSRP在...

  • cisco Routing-Routing-HSRP配置

    问题 在企业网络到外部的连接方案中,要求不高的条件下可以是单出口。一旦该出口线路出现问题,整个企业网络就不能连接到...

  • 太阁实验栈 虚拟路由器冗余协议

    VRRP与HSRP非常相似;如果您了解HSRP,那么您可以毫不费力地使用VRRP,这是IETF在RFC 3768中...

  • 玩转nginx

    本文内容包括: nginx配置实例之反向代理; nginx配置实例之动静分离; nginx配置实例之负载均衡; n...

  • fly-请求配置&拦截器

    请求配置 实例级配置:对fly实例发起的所有请求都有效 单次请求配置:只对当次请求有效 可配置项 通用项:所有环境...

  • nginx.conf配置

    实例1: 实例2:nginx支持php网页 实例3:nginx配置静态网页 实例4:nginx负载 实例5:实现同...

  • VRRP /HSRP实战

网友评论

    本文标题:HSRP概念及配置实例

    本文链接:https://www.haomeiwen.com/subject/kfsczqtx.html