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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 黑盒测试的常见的测试用例设计方法有哪些[通俗易懂]

    黑盒测试的常见的测试用例设计方法有哪些[通俗易懂]测试用例怎么设计?一般根据业务知识掌握,之前已有的回归测试用例,测试知识库,测试需求开始设计。黑盒测试的常见的测试用例设计方法有哪些?1)等价类划分:等价类是指某个输入域的子集合.在该子集合中,各个输入数据对于揭露程序中的错误都是等效的.并合理地假定:测试某等价类的代表值就等于对这一类其它值的测试.因此,可以把全部输入数据合理划分为若干等价类,在每一个等价类中取一个数据作为测试的输入条件,就可以用少量代表性的测试数据.取得较好的测试结果.等价类划分可有两种不同的情况:有效等价类和无效等价类.

    2022年6月29日
    23
  • PR曲线 可算是明白了 precision recall曲线

    PR曲线 可算是明白了 precision recall曲线Inst#是样本序号,图中有20个样本。Class是groundtruth标签,p是positive样本(正例),n当然就是negative(负例)score是我的分类器对于该样本属于正例的可能性的打分。因为一般模型输出的不是0,1的标注,而是小数,相当于置信度。然后设置一个从高到低的阈值y,大于等于阈值y的被我正式标注为正例,小于阈值y的被我正式标注为负例。显然,我设置n个阈值…

    2022年6月16日
    26
  • 正则表达式:匹配不包含某些字符和不包含某些字符串的写法「建议收藏」

    正则表达式:匹配不包含某些字符和不包含某些字符串的写法「建议收藏」不包含某些字符:不包含某些字符串:当然下面不包含字符串可以演变为不包含字符使用,看你喜欢使用。

    2022年7月2日
    30
  • 两数之和 II – 输入有序数组(Java实现)

    两数之和 II – 输入有序数组(Java实现)给定一个已按照升序排列的有序数组,找到两个数使得它们相加之和等于目标数。函数应该返回这两个下标值index1和index2,其中index1必须小于index2。

    2022年5月27日
    32
  • C#的一些关键字的总结

    C#的一些关键字的总结

    2021年7月27日
    62
  • 什么是泛型,怎么使用泛型分析

    什么是泛型,怎么使用泛型分析1、泛型1:什么是泛型?泛型就是广泛的类型,也是一种数据类型,而这种数据类型可以是任意类型,编写过程中当中不能确定类型,创建对象时必须指定具体类型,不指定也可以,但是会出现一些错误。泛型是编译器行为,只能在编译期有效,如果能够跨过编译器,那么泛型就没有任何意义了。2、泛型类怎么定义泛型类?在类后面加<&g…

    2022年6月22日
    38

发表回复

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

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