拓扑.jpg

最近学习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#