设为首页收藏本站language 语言切换
查看: 3265|回复: 9
收起左侧

[分享] 网关冗余(HSRP)

[复制链接]
发表于 2012-8-29 15:47:29 | 显示全部楼层 |阅读模式
本帖最后由 whzlj 于 2012-8-29 16:50 编辑

拓扑.jpg (34.46 KB, 下载次数: 16)

最近学习cisco技术,看到一个网关冗余的实验挺不错了,自己做了一遍,成功完成实验,下面给大家分享一下
实验拓扑:




实验配置:


路由器配置
===========
R1
===========
Router>en
Router#conf t
Router(config)#enable secret cisco
Router(config)#int f0/0
Router(config-if)#ip address 192.168.13.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#int s1/0
Router(config-if)#ip address 192.168.12.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#router rip
Router(config-router)#network 192.168.13.0
Router(config-router)#network 192.168.12.0
Router(config-router)#passive-interface f0/0   //设为被动接口
Router(config-router)#exit
Router(config)#exit
Router#
Router(config-if)#standby 1 ip 192.168.13.254    //启用 HSRP 功能,并设置虚拟IP ,组号为 1
Router(config-if)#standby 1 preempt    //设置该路由器在优先级最高时成为活动路由器。如果不设置,即使该路由器权值
再高,也不会成为活动路由器
Router(config-if)#standby 1 priority 120  //设置优先级,默认为100
Router(config-if)#standby 1 timers 3 10   //设置Hello time 和 Hold time  ,即每隔3秒发Hello包,超过10秒没收到Hello宣告该路由器故障
Router(config-if)#standby 1 authentication cisco   //配置认证密码,防止非法设备加入到HSRP中,同一组密码必须一致
Router(config-if)#exit
Router(config)#exit
Router#
Router#conf t
Router(config)#hostname R1
R1(config)#exit
R1#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, su - IS-IS summary, 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 not set
C    192.168.12.0/24 is directly connected, Serial1/0
C    192.168.13.0/24 is directly connected, FastEthernet0/0
R    192.168.20.0/24 [120/1] via 192.168.12.2, 00:00:28, Serial1/0
R    192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:28, Serial1/0
R1#

=============
R2
=============

Router>en
Router#conf t
Router(config)#enable secret cisco
Router(config)#int s1/0
Router(config-if)#ip address 192.168.12.2 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#
Router(config)#router rip
Router(config-router)#network 192.168.12.0
Router(config-router)#network 192.168.23.0
Router(config-router)#network 192.168.20.0
Router(config-router)#passive-interface f0/0
Router(config-router)#exit
Router(config)#int s1/1
Router(config-if)#ip address 192.168.23.2 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#int f0/0
Router(config-if)#ip address 192.168.20.2 255.255.255.0
Router(config-if)#exit
Router(config)#exit
Router#
Router#conf t
Router(config)#hostname R2
R2(config)#exit
R2#

=============
R3
=============

Router>en
Router#conf t
Router(config)#enable secret cisco
Router(config)#int f0/0
Router(config-if)#ip address 192.168.13.3 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#int s1/1
Router(config-if)#ip address 192.168.23.3 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#router rip
Router(config-router)#network 192.168.13.0
Router(config-router)#network 192.168.23.0
Router(config-router)#passive-interface f0/0
Router(config-router)#exit
Router(config)#exit
Router#
Router#conf t
Router(config)#int f0/0
Router(config-if)#standby 1 ?
  authentication  Authentication
  ip              Enable HSRP and set the virtual IP address
  mac-address     Virtual MAC address
  name            Redundancy name string
  preempt         Overthrow lower priority Active routers
  priority        Priority level
  timers          Hello and hold timers
  track           Priority tracking

Router(config-if)#standby 1 ip 192.168.13.254
Router(config-if)#standby 1 preempt
Router(config-if)#standby 1 timers 3 10
Router(config-if)#standby 1 authentication cisco
Router(config-if)#exit
Router(config)#exit
Router#conf
Router(config)#hostname R3
R3(config)#exit
R3#

PC 配置

=============
R12 和 R11  当PC使用

R12>en
R12#conf t
R12(config)#hostname PC12
PC12(config)#no ip routing
PC12(config)#int f0
PC12(config-if)#ip address 192.168.13.100 255.255.255.0
PC12(config-if)#no shut
PC12(config-if)#exit
PC12(config)#ip default-gateway 192.168.13.254               
//.254是虚拟网关

R11>en
R11#conf t
R11(config)#hostname PC11
PC11(config)#no ip routing
PC11(config)#int f0
PC11(config-if)#ip address 192.168.20.100 255.255.255.0
PC11(config-if)#no shut
PC11(config-if)#exit
PC11(config)#ip default-gateway 192.168.20.2


测试:ping (分别断开到R1和到R3的线路  下图可以看出自动就跳到另一条)

PC12#ping 192.168.20.100 repeat 500
Type escape sequence to abort.
Sending 500, 100-byte ICMP Echos to 192.168.20.100, timeout is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.....!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.............
.....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!

Success rate is 94 percent (473/500), round-trip min/avg/max = 16/80/424 ms
PC12#

traceroute  测试

PC12#traceroute 192.168.20.100                       //到R1和R3的线路都正常时
Type escape sequence to abort.
Tracing the route to 192.168.20.100
  1 192.168.13.1 456 msec 312 msec 284 msec
  2 192.168.12.2 528 msec 888 msec *
  3  *  *
    192.168.20.100 632 msec
PC12#traceroute 192.168.20.100                       //断开R1后测试结果
Type escape sequence to abort.
Tracing the route to 192.168.20.100
  1 192.168.13.3 368 msec 272 msec 228 msec
  2 192.168.23.2 488 msec 1084 msec 1048 msec
  3 192.168.20.100 928 msec *  556 msec
PC12#traceroute 192.168.20.100                      //断开R3后测试结果
Type escape sequence to abort.
Tracing the route to 192.168.20.100
  1 192.168.13.1 372 msec 928 msec 1552 msec
  2  *
    192.168.12.2 1604 msec 576 msec
  3  *  *  *
  4  *
    192.168.20.100 772 msec 668 msec
PC12#

发表于 2012-9-3 23:29:54 | 显示全部楼层

回帖奖励 +1 个鸿鹄币

谢谢分享!
沙发 2012-9-3 23:29:54 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-11-4 20:08:03 | 显示全部楼层
學習一下,謝啦!
板凳 2012-11-4 20:08:03 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2012-11-22 23:33:00 | 显示全部楼层
地板 2012-11-22 23:33:00 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2013-8-12 09:18:18 | 显示全部楼层
不错啊
5# 2013-8-12 09:18:18 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2015-1-9 16:14:13 | 显示全部楼层
感谢楼主分享资源
6# 2015-1-9 16:14:13 回复 收起回复
回复 支持 反对

使用道具 举报

发表于 2018-6-5 16:42:30 | 显示全部楼层
谢谢卤煮分享
10# 2018-6-5 16:42:30 回复 收起回复
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-4-24 14:20 , Processed in 1.502120 second(s), 25 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表