cisco配置hsrp配置实例

cisco配置hsrp配置实例1 实验环境使用 ciscopackett 模拟器实现网络拓扑配置 交换机使用 3560 路由器使用 2911 显示所有端口 Options gt Preferences gt 选中 AlwaysShowPo 2 网络拓扑如下 3 具体配置 PC1 目前只需要配置基础 ip 即可 我们使用路由器来模拟 PC 机 Router gt en

1、实验环境

使用cisco packet tracer模拟器实现网络拓扑配置,交换机使用3560,路由器使用2911。

显示所有端口

cisco配置hsrp配置实例

Options–>Preferences–>选中Always Show Port Labels:

cisco配置hsrp配置实例

2、网络拓扑如下

cisco配置hsrp配置实例

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

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

起起来立马就能在打印的日志里面看到状态有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#

仍然是通的,实验到此结束。

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233070.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • opencv图像角点提取

    opencv图像角点提取opencv角点检测(二)改进的Harris角点检测算法harris角点检测算法的结果一定程度上取决于系数k,有人对Harris的角点检测算法进行了改进,直接利用像素点协方差矩阵的特征值提取角点。而且不在进行非极大值抑制,而是采用一种容忍距离的形式,在角点的一定范围内只有一个角点。具体原理:首先计算图像每个像素点的协方差矩阵,并求取对应的特征值,将最小的特征值最大的那个像素点作为第

    2022年8月30日
    3
  • Spring计时器StopWatch使用

    Spring计时器StopWatch使用StopWatch是位于org.springframework.util包下的一个工具类,通过它可方便的对程序部分代码进行计时(ms级别),适用于同步单线程代码块。

    2022年6月23日
    34
  • 安装PyTorch(pytorch官网下载教程)

    安装PyTorch过程安装anaconda环境管理PyTorch安装检验安装安装anaconda登录anaconda的官网下载,anaconda是一个集成的工具软件不需要我们再次下载。anaconda官网点击下载跳转到这个页面如果你的Python版本正好是3.8版,那便可以直接根据系统去选择自己相应的下载版本就可以了。但是如果你的Python版本号不是当前页面的版本号,那我建议你去选择相对应的版本号。点击archive你就会跳转到下面的页面你可以访问这篇博客去找到当前与你python版本号相对

    2022年4月15日
    52
  • webrtc开发入门_统计的简单应用

    webrtc开发入门_统计的简单应用WebRTC介绍及简单应用WebRTC,即WebRealTimeCommunication,web实时通信技术。简单地说就是在web浏览器里面引入实时通信,包括音视频通话等。WebRT

    2022年8月1日
    5
  • Java构造方法(超详细!)

    Java构造方法(超详细!)1.构造方法有什么作用?构造方法是一个比较特殊的方法,通过构造方法可以完成对象的创建,以及实例变量的初始化。换句话说:构造方法是用来创建对象,并且同时给对象的属性赋值。注意:实例变量没有手动赋值的时候,系统会赋默认值。2.构造方法怎么定义,语法是什么?[修饰符列表]构造方法名(形式参数列表){ 构造方法体; 通常在构造方法体当中给属性赋值,完成属性的初始化。}注意:第一:修饰符列表目前统一写:public。千万不要写publicstatic。第二:构造方法名和类名必须一致。第

    2022年7月7日
    24
  • oracle导出建表sql_Oracle数据库语句汇总

    oracle导出建表sql_Oracle数据库语句汇总第一步:安装pl/sqlDeveloper(此程序Oracle必备软件,在此不再讨论)第二步:登录pl/sqlDeveloper                                           登录界面第三步在左侧菜单选择Tables第三步点开Tables后在要导出的表上右键-DBMS_MetaData-DDL即可导出创建表的DDL语句

    2025年9月8日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号