码迷,mamicode.com
首页 > 系统相关 > 详细

使用cisco的HRSP配置路由器主备冗余以及故障测试

时间:2019-12-25 22:27:11      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:address   hello   The   ESS   ethernet   pre   src   ima   可用性   

概述
  • HSRP能防止路由器单点失效从而提供网络的高可用性。双机冗余需要用到HSRP。
  • 在一个HSRP组内的多个路由器共用一个虛拟的物理地址和IP地址。HSRP协议决定na个路由器被激活,该被激活的路由器接收发过来的数据包并进行路由。
  • HSRP使用组播、基于UDP的呼叫信号包来实现与同一HSRP组内其它路由器之间的通信,组内的各路由器之间交換呼叫信号,如果当前路由器变得无法使用,备用路由器将进入激活状态,接管路由任务。

实验拓扑与说明

技术图片

  • 路由器R1和R2的e0/0接口IP设置为192.168.20.252和192.168.20.253,公用standby IP为192.168.20.254
  • R1为主,R1的优先级为200,R2为备,它的优先级为150
  • linux测试主机的IP为192.168.20.1

实验目标

  • 配置实现两台路由器双机冗余互备
  • 怎样查看冗余互备的情况

需要用到的命令

  • standby ip:用于激活HSRP
  • standby priority:用于设定端口的HSRP优先级,具有最高备份优先级的HSRP成员将成为激活路由器(假设设置为优先权方式)
  • standby timers:用于设定 hello包之间的时间间隔( hello time)以及路由器在多长一个时间段内没有从HSRP邻居收到 hello包就判定该邻居已关闭( hold time)。
  • standby preempt:表明当本地路由器的备份优先级超过当前激活路由器时,它就将接管控制权,成为激活路由器
  • standby track:用于设置允许路由器端口根据另一端口的可用性而修改自己的HSRP优先级值

配置步骤

R1的配置


Router>en
Router#configure terminal
Router(config)#hostname R1
R1(config)#interface e0/0
R1(config-if)#ip address 192.168.20.252 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#standby priority 200  //设置优先级
R1(config-if)#standby preempt
R1(config-if)#standby ip 192.168.20.254  //standby ip 为两台路由器共用

R2的配置

Router>en
Router#configure terminal
Router(config)#hostname R2
R2(config)#interface e0/0
R2(config-if)#ip address 192.168.20.253 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#standby priority 150
R2(config-if)#standby preempt
R2(config-if)#standby ip 192.168.20.254

至此,HRSP双机热备完成配置

测试

  • 在主机上ping standby IP,下图显示已经可以ping了
    技术图片

在路由器上检查设备状态

  • 在R1上,状态是State is Active

R1#show standby
Ethernet0/0 - Group 0
State is Active
2 state changes, last state change 04:07:11
Virtual IP address is 192.168.20.254
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 //3s相互发hello,10s接受不到边切换
Next hello sent in 1.792 secs
Preemption enabled
Active router is local
Standby router is 192.168.20.253, priority 150 (expires in 9.904 sec)
Priority 200 (configured 200)
Group name is "hsrp-Et0/0-0" (default)


- 在R2上,状态是`State is Standby`

R2#show standby
Ethernet0/0 - Group 0
State is Standby
1 state change, last state change 04:05:46
Virtual IP address is 192.168.20.254
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 2.848 secs
Preemption enabled
Active router is 192.168.20.252, priority 200 (expires in 8.912 sec)
Standby router is local
Priority 150 (configured 150)
Group name is "hsrp-Et0/0-0" (default)


### 通过debug来查看两设备之间的通信信息

- 在正常的情况下,在任一台路由器上`debug standby`,每隔3秒左右,就看两台设备互发信息

R1#debug standby
HSRP debugging is on
R1#
Jan 2 02:22:43.438: HSRP: Et0/0 Grp 0 Hello in 192.168.20.253 Standby pri 150 vIP 192.168.20.254
Jan 2 02:22:44.000: HSRP: Et0/0 Grp 0 Hello out 192.168.20.252 Active pri 200 vIP 192.168.20.254
R1#
R1#no debug standby
HSRP debugging is off


- 断掉R1的e0/0连线,测试R2是否接管

在R2 `debug standby`可以看到切换的信息

![](https://sharp-images.oss-cn-shenzhen.aliyuncs.com/picgo/20191225164115.png)

在R2上`show standby`可以R2已经变为Active了

R2#
*Jan 2 02:40:25.369: HSRP: Et0/0 Grp 0 Hello out 192.168.20.253 Active pri 15 R2#show standby
Ethernet0/0 - Group 0
State is Active //R2已经变为Active了
2 state changes, last state change 00:02:07
Virtual IP address is 192.168.20.254
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 1.200 secs
Preemption enabled
Active router is local
Standby router is unknown
Priority 150 (configured 150)
Group name is "hsrp-Et0/0-0" (default)
R2#



当R1恢复正常后,会变回主设备

使用cisco的HRSP配置路由器主备冗余以及故障测试

标签:address   hello   The   ESS   ethernet   pre   src   ima   可用性   

原文地址:https://blog.51cto.com/xingsi/2461775

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!