cisco配置hsrp配置实例
1、实验环境
使用cisco packet tracer模拟器实现网络拓扑配置,交换机使用3560,路由器使用2911。
显示所有端口
Options-->Preferences-->选中Always Show Port Labels:
2、网络拓扑如下
3、具体配置
PC1目前只需要配置基础ip即可:
我们使用路由器来模拟PC机
Router>en
Router#conf t
Router(config)#interface GigabitEthernet0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#end
Router#write
配置SW1,SW2,SW3基础ip,其中SW1和SW2做三层交换机使用,SW3做为二层交换机使用。
SW3:
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#interface FastEthernet0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10
Switch(config-if)#end
Switch#write
SW1:
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#interface FastEthernet0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/1
Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.1.252 255.255.255.0
Switch(config-if)#exit
SW2:
Switch>en
Switch#conf t
Switch(config)#vlan 10
Switch(config-vlan)#exit
Switch(config)#interface FastEthernet0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan 10
Switch(config-if)#exit
Switch(config)#interface FastEthernet0/1
Switch(config-if)#no switchport
Switch(config-if)#ip address 192.168.3.1 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface vlan 10
Switch(config-if)#ip address 192.168.1.253 255.255.255.0
Switch(config-if)#exit
此时从PC1上去ping SW1和SW2的vlan接口ip是能通的:
Router#ping 192.168.1.253
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.253, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Router#ping 192.168.1.252
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.252, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Router#
配置SW1和SW2上的hsrp,我们通过优先级控制SW1为主设备,SW2为备用设备
SW1:
en
conf t
Switch(config)#interface vlan 10
Switch(config-if)#standby 1 ip 192.168.1.254
Switch(config-if)#standby 1 priority 200
Switch(config-if)#standby 1 preempt
SW2:
en
conf t
Switch(config)#interface vlan 10
Switch(config-if)#standby 1 ip 192.168.1.254
Switch(config-if)#standby 1 priority 195
Switch(config-if)#standby 1 preempt
此时查看hsrp协议状态:
SW1:
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 200 P Active local 192.168.1.252 192.168.1.254
Switch#
SW2:
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 195 P Standby 192.168.1.253 local 192.168.1.254
Switch#
可以看到由于SW1优先级为200,高于SW2的195的优先级,所以SW1是active的,作为主设备;SW2是standby的。
配置出口路由器R3
Router>en
Router#conf t
Router(config)#interface GigabitEthernet0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.2.2 255.255.255.0
Router(config-if)#exit
Router(config)#interface GigabitEthernet0/1
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.3.2 255.255.255.0
Router(config-if)#exit
Router(config)#interface loopback 0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.4.1 255.255.255.0
Router(config-if)#exit
配置SW1、SW2和R3上三层设备的rip协议,当然也可以使用静态路由,我们这里使用rip。
SW1:
Switch#conf t
Switch(config)#ip routing
Switch(config)#router rip
Switch(config-router)#version 2
Switch(config-router)#no auto-summary
Switch(config-router)#network 192.168.1.0
Switch(config-router)#network 192.168.2.0
Switch(config-router)#end
SW2:
Switch#conf t
Switch(config)#ip routing
Switch(config)#router rip
Switch(config-router)#version 2
Switch(config-router)#no auto-summary
Switch(config-router)#network 192.168.1.0
Switch(config-router)#network 192.168.3.0
Switch(config-router)#end
R3:
Router#conf t
Router(config)#ip routing
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#network 192.168.2.0
Router(config-router)#network 192.168.3.0
Router(config-router)#network 192.168.4.0
分别查看三台设备的路由:
SW1:
Switch#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, 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.1.0/24 is directly connected, Vlan10
C 192.168.2.0/24 is directly connected, FastEthernet0/1
R 192.168.3.0/24 [120/1] via 192.168.2.2, 00:00:14, FastEthernet0/1
[120/1] via 192.168.1.252, 00:00:14, Vlan10
R 192.168.4.0/24 [120/1] via 192.168.2.2, 00:00:14, FastEthernet0/1
Switch#
可以看到192.168.1.0和192.168.2.0是直连路由,192.168.3.0和192.168.4.0是通过rip协议获取到的路由。
SW2:
Switch#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, 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.1.0/24 is directly connected, Vlan10
R 192.168.2.0/24 [120/1] via 192.168.3.2, 00:00:06, FastEthernet0/1
[120/1] via 192.168.1.253, 00:00:02, Vlan10
C 192.168.3.0/24 is directly connected, FastEthernet0/1
R 192.168.4.0/24 [120/1] via 192.168.3.2, 00:00:06, FastEthernet0/1
Switch#
SW2上192.168.1.0和192.168.3.0是直连路由,而192.168.2.0和192.168.4.0是rip协议获取到的。
Router#show ip route
Codes: L - local, C - connected, S - static, 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, 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
R 192.168.1.0/24 [120/1] via 192.168.3.1, 00:00:22, GigabitEthernet0/1
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.2.0/24 is directly connected, GigabitEthernet0/0
L 192.168.2.2/32 is directly connected, GigabitEthernet0/0
192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.3.0/24 is directly connected, GigabitEthernet0/1
L 192.168.3.2/32 is directly connected, GigabitEthernet0/1
192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.4.0/24 is directly connected, Loopback0
L 192.168.4.1/32 is directly connected, Loopback0
Router#
R3上192.168.2.0、192.168.3.0和192.168.4.0都是直连路由,而192.168.1.0是通过rip协议获取到的。
此时我们试试从PC1上ping R3上的loopback0上的192.168.4.1看看:
Router#ping 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
发现不通,而此时PC1到SW1和SW2的都是通的,这是由于PC1到SW1和SW2是直接通过二层vlan透传的,但是在到R3的时候,由于是三层通信了,所以必须得有路由。而我们使用的是路由器模拟PC机,无法直接在接口上配置网关,所以可以通过在PC1上增加一条默认路由器出去即可。
PC1:
Router#conf t
Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.254
此时在ping192.168.4.1即可发现通了:
Router#ping 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/3/12 ms
Router#write
此时我们测试在主设备SW1的上行端口down掉了以后,通过配置track主设备的上行端口进行主备切换
Switch>en
Switch#conf t
Switch(config)#interface vlan 10
Switch(config-if)#standby 1 track FastEthernet0/1
Switch(config-if)#exit
手工shutdown模拟端口故障:
Switch(config)#interface FastEthernet0/1
Switch(config-if)#shutdown
Switch(config-if)#end
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 190 P Standby 192.168.1.252 local 192.168.1.254
Switch#
此时我们看到SW1已经变成standby了。
SW2:
Switch>en
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 195 P Active local 192.168.1.253 192.168.1.254
Switch#
此时我们看到SW2变成了active状态了。在主设备上没有配置上行端口down了以后优先级减多少的情况下,默认优先级是减10的。
此时我们在PC1上ping R3上的192.168.4.1,还是能ping通的
Router#ping 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/2/11 ms
Router#
此时我们去SW1上把上行接口起起来:
SW1:
Switch#conf t
Switch(config)#interface FastEthernet0/1
Switch(config)#interface FastEthernet0/1
Switch(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#
%HSRP-6-STATECHANGE: Vlan10 Grp 1 state Standby -> Active
起起来立马就能在打印的日志里面看到状态有standby变成了active了。
我们来分别检查一下SW1和SW2:
SW1:
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 200 P Active local 192.168.1.252 192.168.1.254
Switch#
SW2:
Switch#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Vl10 1 195 P Standby 192.168.1.253 local 192.168.1.254
Switch#
发现SW1已经变成了主设备active的状态。因为我们主备上面都配置了抢占,所以主设备在恢复的时候能立马抢占回主设备的角色。
此时我们在测试一下连通性
在PC1上ping R3的loopback0
Router#ping 192.168.4.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.4.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Router#
仍然是通的,实验到此结束。
cisco配置hsrp配置实例相关推荐
- Cisco思科路由器HSRP配置和排障那些事儿~~
首先亮出必备命令来: 配置HSRP的成员: Router(config-if)#standby 备份组号 ip 备份组虚拟IP地址 配置HSRP优先级: Router(config-if)#stand ...
- CISCO路由器产品配置手册
CISCO路由器产品配置手册 第一章 路由器配置基础2 一.基本设置方式2 二.命令状态2 三.设置对话过程3 四.常用命令5 五.配置IP寻址6 六.配置静态路由8 第二章 广域网协议设置10 一. ...
- 万众期待的《Cisco/H3C路由器配置与管理完全手册》开锣了
自<Cisco/H3C交换机配置与管理完全手册>一书上市以来,得到许多热心网友和读者的支持与关注.虽然也有不少反对的声音,但听到最多的还是许多读者的真正肯定与对在书中提到的下一本图 ...
- cisco 6509交换配置
. 6509介绍 Cisco Catalyst 6500系列交换机提供3插槽.6插槽.9插槽和13插槽的机箱,以 及多种集成式服务模块,包括数千兆位网络安全性.内容交换.语音和网络分析模块. C ...
- 思科交换机MST配置命令步骤-实例讲解
配置MST的基本参数 启用MST的过程需要多不操作,它需要将一定的范围的VLAN映射到单个MSTI. 因为MST适用于多个VLAN的情况,所以它就比PVST+或RPVST+要求更多的其他配置.当用户 ...
- Cisco PVLAN的配置
Cisco PVLAN的配置 VLAN即私有VLAN(Private VLAN),PVLAN采用两层VLAN隔离技术,只有上层VLAN全局可见,下层VLAN相互隔离. 每个pVLAN 包含2种VLAN ...
- n3k配置vpc是否还需要配置hsrp_连结7000系列交换机使用HSRP配置示例
本文为热备份路由协议(HSRP)提供一配置示例在Cisco连结7000系列设备,并且显示HSRP配置哪个提供首跳共享在两连结7000系列交换机之间的冗余协议(FHRP)和负载. 尝试进行此配置之前,请 ...
- Cisco路由器基本配置
Cisco IOS软件简介 路由器就是一个具有多个端口的计算机,只不过它在网络中起到的作用与一般的PC不同而已.和普通计算机一样,路由器也需要一个操作系统,Cisco把这个操作系统叫作Cisc ...
- CISCO动态VLAN配置
CISCO动态VLAN配置 一.基于VMPS的动态VLAN配置实例 网络中VLAN实现分为静态VLAN和动态VLAN.静态VLAN又被称为是基于端口的VLAN.顾名思义,就是明确指定各端口属于哪个VL ...
最新文章
- 纯CSS制作各种各样的网页图标(三角形、暂停按钮、下载箭头、加号等)
- 两天,我把分布式事务搞完了!
- Kafka从上手到实践 - 实践真知:Kafka Java Consumer | 凌云时刻
- 代码实现最简单的游戏————空中飞机
- SpaceClaim功能解析与应用介绍
- PROTEL 99 使用之添加库
- r语言clind函数_19 函数进阶 | R语言教程
- Google Scholar 谷歌学术文献检索技巧总结
- 多天线技术(MIMO)基础
- 程序员、架构师、技术经理、技术总监、CTO,怎么定位?
- 【Rust日报】2022-09-11 Shuttle 创建和部署带有ShuttleSerenity的 Discord 机器人!
- 运维危险操作之windows server打开或关闭windows功能
- 鸡和兔放在一起,一共有20个头和56只脚,问鸡和兔各几只?
- Byval 和 Byref的区别
- 回归分析之汽车保险数据分析
- 逻辑回归分类器(linear_model.LogisticRegression)
- 分布式服务框架 dubbo/dubbox 入门示例(2)
- 威纶触摸屏使用U盘/SD卡上传或下载程序步骤及编译失败处理对策
- 10.2.0.1到12.2.0.1数据库迁移expdp+dblink导入失败
- 加薪必备,SpringMVC精品面试题(这必须收藏啊!)