IE-LAB网络实验室:HSRP协议简介和配置

HSRP(Hot Standby Router Protocol):热备份路由器协议,设计目标是支持特定情况下 IP 流量失败转移不会引起混乱、并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情形下仍能维护路由器间的连通性。换句话说,当源主机不能动态知道第一跳路由器的 IP 地址时,HSRP 协议能够保护第一跳路由器不出故障。该协议中含有多种路由器,对应一个虚拟路由器。HSRP 协议只支持一个路由器代表虚拟路由器实现数据包转发过程。终端主机将它们各自的数据包转发到该虚拟路由器上。
负责转发数据包的路由器称之为活动路由器(Active Router)。一旦主动路由器出现故障,HSRP 将激活备份路由器(Standby Routers)取代主动路由器。HSRP 协议提供了一种决定使用主动路由器还是备份路由器的机制,并指定一个虚拟的 IP 地址作为网络系统的缺省网关地址。如果主动路由器出现故障,备份路由器(Standby Routers)承接主动路由器的所有任务,并且不会导致主机连通中断现象。

HSRP配置

1、实验目的
通过本实验可以掌握
HSRP的工作原理
HSRP的配置
2、拓扑:
在这里插入图片描述
在路由器上和三层交换机上配置HSRP。使用路由器模拟PC。
3、实验步骤

Router(config)#hostname R1
R1(config)#line console 0
R1(config-line)#exec-timeout 0 0
R1(config-line)#logging synchronous
R1(config-line)#exit
R1(config)#no ip domain-lookup
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.13.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface s2/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#router rip
R1(config-router)version 2
R1(config-router)no auto-summary
R1(config-router)#network 192.168.12.0
R1(config-router)#network 192.16.13.0
R1(config-router)#passive-interface f0/0 //把f0/0接口设置为被动接口,防止从此接口发送RIP信息给R3。
R1(config-router)#exit

Router>enable
Router#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#line console 0
Router(config-line)#exec-timeout 0 0
Router(config-line)#logging synchronous
Router(config-line)#exit
Router(config)#no ip domain-lookup
Router(config)#hostname R2
R2(config)#interface lo0
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#interface s2/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface s2/1
R2(config-if)#ip address 192.168.23.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#router rip
*Aug 20 19:55:10.071: %LINK-3-UPDOWN: Interface Serial2/1, changed state to up
R2(config)#router rip
R2(config-router)version 2
R2(config-router)no auto-summary
R2(config-router)#network 192.168.12.0
R2(config-router)#network 192.168.23.0
R2(config-router)#network 192.168.2.0
R2(config-router)#exit

Router>enable
Router#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#line console 0
Router(config-line)#exec-timeout 0 0
Router(config-line)#logging synchronous
Router(config-line)#exit
Router(config)#no ip domain-lookup
Router(config)#hostname R3
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip address 192.168.13.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface s2/1
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#router rip
R3(config-router)#network 192.168.13.0
R3(config-router)#network 192.168.23.0
R3(config-router)#passive-interface fastEthernet 0/0
R3(config-router)#exit

配置HSRP
R1(config)#int
R1(config)#interface f0/0
R1(config-if)#standby 1 ip 192.168.13.254
//启用HSRP功能,并设置虚拟IP地址,1 为standby的组号。相同组号的路由器属于同一个HSRP组,同一个组的HSRP路由器虚拟地址必须一致
R1(config-if)#standby 1 priority 120
//配置HSRP的优先级,默认100.值大的路由器为活动路由器
R1(config-if)#standby 1 preempt
//开启抢占功能,如果不开启,就算优先级权值再高,也不会成为活动路由器
R1(config-if)#standby 1 timers 3 10
//每隔3s发送一次hello信息 ,10s没有收到活动路由器的信息,则认为活动路由器发生故障。默认值为3和10 ,相同组的该设置必须一致
R1(config-if)#standby 1 authentication md5 key-string cisco
//配置认证密码,防止非法设备加入到HSRP组,同一个组密码必须一致。
R1(config-if)#exit

R3(config)#interface f0/0
R3(config-if)#standby 1 ip 192.168.13.254
R3(config-if)#standby 1 preempt
R3(config-if)#standby 1 timers 3 10
R3(config-if)#standby 1 authentication md5 key-string cisco
R3(config-if)#exit
//没有设置优先级,默认100

4、检测
PC ping 192.168.2.2
在这里插入图片描述
是R1接口断开,查看现象。
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值