Cisco模拟器HSRP

HSRP

路由器双机热备(Router Hot Standby)是一种网络设备冗余配置方式,其中两个路由器组成一对,一个为活动路由器(Active Router),另一个为备用路由器(Standby Router)。活动路由器处理所有数据流量和网络操作,而备用路由器则监控活动路由器的状态,并在必要时快速接管其职责以保持网络连通性。这种配置方式可以提高网络的可用性和鲁棒性。

HSRP(Hot Standby Router Protocol)是一种Cisco开发的路由器双机热备协议,用于提高默认网关的可用性和冗余性。在HSRP配置中,多个路由器组成一个虚拟路由器组,并且其中一个路由器被选为活动路由器来处理数据流量,而其他路由器则作为备用路由器等待接管职责。HSRP使用虚拟IP地址和虚拟MAC地址来实现无感知的故障转移。如果活动路由器失效,备用路由器将立即接管职责并继续为网络设备提供默认网关服务。

语法

  1. Virtual Router Redundancy Protocol (VRRP):

interface <interface>
 vrrp <group-number> ip <virtual-ip-address>
 standby <group-number> priority <priority-value>
 track <object-number> decrement <value>
  1. Hot Standby Router Protocol (HSRP):

interface <interface>
 standby <group-number> ip <virtual-ip-address>
 standby <group-number> preempt
 standby <group-number> priority <priority-value>
 track <object-number> decrement <value>
类型端口地址
PC10-1FastEthernet0/1172.17.165.2/24
PC10-2FastEthernet0/1172.17.165.1/24
PC10-3FastEthernet0/1dhcp
r0GigabitEthernet0/0172.17.165.253/24
r0GigabitEthernet0/1200.200.200.10/30
r1GigabitEthernet0/0172.17.165.252/24
r1GigabitEthernet0/1200.200.200.1/30
r2GigabitEthernet0/1200.200.200.2/30
r2GigabitEthernet0/2200.200.200.9/30
r2GigabitEthernet0/0192.168.1.254/24

在这里插入图片描述

r0

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
#给路由器改名称
Router(config)#hostname r0
#给接口添加地址
r0(config)#int g0/0
r0(config-if)#ip add 172.17.165.253 255.255.255.0
r0(config-if)#no sh
r0(config-if)#ex
r0(config)#int g0/1
r0(config-if)#ip add 200.200.200.10 255.255.255.252
r0(config-if)#no sh
r0(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up
r0(config-if)#
#配置静态路由
r0(config)#ip route 192.168.1.0 255.255.255.0 200.200.200.9
r0(config)#
#配置HSRP
r0(config)#int g0/0
#配置虚拟网关
r0(config-if)#standby 10 ip 172.17.165.254
#配置优先级,优先级范围1-255,数字越大表示优先级越高,监听端口如果不可用,优先级默认自降10
r0(config-if)#standby 10 priority 195
#配置抢占模式
r0(config-if)#standby 10 preempt
#配置端口监听(监听端口是否可用)
r0(config-if)#standby 10 track g0/1
r0(config-if)#ex
r0(config)#
%HSRP-6-STATECHANGE: GigabitEthernet0/0 Grp 10 state Speak -> Standby
%HSRP-6-STATECHANGE: GigabitEthernet0/0 Grp 10 state Standby -> Active

r1

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname r1
r1(config)#int g0/0
r1(config-if)#ip add 172.17.165.252 255.255.255.0
r1(config-if)#no sh

r1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

r1(config-if)#ex
r1(config)#int g0/1
r1(config-if)#ip add 200.200.200.1 255.255.255.252
r1(config-if)#no sh

r1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

r1(config-if)#
r1(config)#ip route 192.168.1.0 255.255.255.0 200.200.200.2
r1(config)#
r1(config)#int g0/0
r1(config-if)#standby 10 ip 172.17.165.254
r1(config-if)#standby 10 priority 200
r1(config-if)#standby 10 preempt 
r1(config-if)#standby 10 track g0/1
%HSRP-6-STATECHANGE: GigabitEthernet0/0 Grp 10 state Speak -> Standby
ta
r1(config-if)#

r2

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname r2
r2(config)#int g0/1
	
r2(config-if)#ip add 200.200.200.2 255.255.255.252
r2(config-if)#no sh

r2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

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

r2(config-if)#ex
r2(config)#int g0/2
r2(config-if)#ip add 200.200.200.9 255.255.255.252
r2(config-if)#no sh

r2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

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

r2(config-if)#ex
r2(config)#int g0/0
r2(config-if)#ip add 192.168.1.254 255.255.255.0
r2(config-if)#no sh

r2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

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

r2(config-if)#ex
r2(config)#ip dhcp pool 1-254
r2(dhcp-config)#network 192.168.1.0 255.255.255.0
r2(dhcp-config)#default-router 192.168.1.254
r2(dhcp-config)#ex
r2(config)#ip dhcp excluded-address 192.168.1.240 192.168.1.254
r2(config)#ip route 172.17.165.0 255.255.255.0 200.200.200.1
r2(config)#ip route 172.17.165.0 255.255.255.0 200.200.200.10
r2(config)#

测试结果

ping -t 192.168.1.1一直法宝测试,手动断开r1的g0/1端口测试结果如下

在这里插入图片描述

三层交换机双机热备

在这里插入图片描述

ISP

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname isp
isp(config)#int g0/2
isp(config-if)#ip add 100.1.1.254 255.255.255.0
isp(config-if)#no sh

isp(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

isp(config-if)#ex
isp(config)#ip dhcp pool isp
isp(dhcp-config)#network 100.1.1.0 255.255.255.0
isp(dhcp-config)#default-router 100.1.1.254
isp(dhcp-config)#dns-server 114.114.114.114
isp(dhcp-config)#ex
isp(config)#ip dhcp ex
isp(config)#ip dhcp excluded-address 100.1.1.240 100.1.1.254
isp(config)#
isp(config)#int g0/1
isp(config-if)#ip add 200.1.1.10 255.255.255.252
isp(config-if)#no sh
isp(config-if)#ex
isp(config)#int g0/0
isp(config-if)#ip add 200.1.1.2 255.255.255.252
isp(config-if)#no sh
isp(config-if)#ex
isp(config)#ip route 0.0.0.0 0.0.0.0 200.1.1.1
isp(config)#ip route 0.0.0.0 0.0.0.0 200.1.1.9
isp(config)#

r1-1

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

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

Router(config-if)#ip add 172.17.166.2 255.255.255.252
Router(config-if)#ex
Router(config)#int g0/2
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

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

Router(config-if)#ip add 172.17.166.26 255.255.255.252
Router(config-if)#ex
Router(config)#
#这里只是为了方便,实际上应该用ospf
Router(config)#ip route 172.17.165.0 255.255.255.0 172.17.166.1
Router(config)#ip route 172.17.165.0 255.255.255.0 172.17.166.25
Router(config)#
Router(config)#int g0/1
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

Router(config-if)#ip add 200.1.1.1 255.255.255.252
Router(config-if)#ex
#这里按需求即可,不一定要使用ospf
Router(config)#ip route 100.1.1.0 255.255.255.0 200.1.1.2
Router(config)#

r1-2

Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

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

Router(config-if)#ip add 172.17.166.6 255.255.255.252
Router(config-if)#ex
Router(config)#int g0/2
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

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

Router(config-if)#ip add 172.17.166.22 255.255.255.252
Router(config-if)#ex
Router(config)#
#这里只是为了方便,实际上应该用ospf
Router(config)#ip route 172.17.165.0 255.255.255.0 172.17.166.5
Router(config)#ip route 172.17.165.0 255.255.255.0 172.17.166.21
Router(config)#
r1-2(config)#int g0/1
r1-2(config-if)#no sh

r1-2(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

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

r1-2(config-if)#ip add 200.1.1.9 255.255.255.252
r1-2(config-if)#ex
#这里按需求即可,不一定要使用ospf
r1-2(config)#ip route 100.1.1.0 255.255.255.0 200.1.1.10
r1-2(config)#

msw1

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname msw1
msw1(config)#int port-channel 1
msw1(config-if)#int range g1/0/21-24
msw1(config-if-range)#channel-group 1 mode on
msw1(config-if-range)#
%LINK-5-CHANGED: Interface Port-channel1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up

msw1(config-if-range)#ex
msw1(config)#int vlan 1
msw1(config-if)#ip add 172.17.165.252 255.255.255.0
msw1(config-if)#standby 1 ip 172.17.165.254
msw1(config-if)#standby 1 priority 200
msw1(config-if)#standby 1 preempt 
msw1(config-if)#standby 1 track g1/0/1
msw1(config-if)#standby 1 track g1/0/2
msw1(config-if)#ex
msw1(config)#
msw1(config)#int g1/0/1
msw1(config-if)#no sw
msw1(config-if)#no sh
msw1(config-if)#ip add 172.17.166.1 255.255.255.252
msw1(config-if)#ex
msw1(config)#int g1/0/2
msw1(config-if)#no sw
msw1(config-if)#no sh
msw1(config-if)#ip add 172.17.166.5 255.255.255.252
msw1(config-if)#ex
#这里只是为了方便,实际上应该用ospf
msw1(config)#ip route 0.0.0.0 0.0.0.0 172.17.166.2
msw1(config)#ip route 0.0.0.0 0.0.0.0 172.17.166.6
msw1(config)#spanning-tree vlan 1 root primary

msw2

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname msw2
msw2(config)#int port
msw2(config)#int port-channel 1
msw2(config-if)#int range g1/0/21-24
msw2(config-if-range)#channel-group 1 mode on
msw2(config-if-range)#
%LINK-5-CHANGED: Interface Port-channel1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up

msw2(config-if-range)#
%LINK-5-CHANGED: Interface Port-channel1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Port-channel1, changed state to up

msw2(config-if-range)#ex
msw2(config-if)#standby 1 ip 172.17.165.254
msw2(config-if)#standby 1 priority 195
msw2(config-if)#standby 1 preempt 
msw2(config-if)#standby 1 track g1/0/1
msw2(config-if)#standby 1 track g1/0/2
msw2(config)#int g1/0/1
msw2(config-if)#no sw
msw2(config-if)#no sh
msw2(config-if)#ip add 172.17.166.21 255.255.255.252
msw2(config-if)#ex
msw2(config)#int g1/0/2
msw2(config-if)#no sw
msw2(config-if)#no sh
msw2(config-if)#ip add 172.17.166.25 255.255.255.252
msw2(config-if)#ex
#这里只是为了方便,实际上应该用ospf
msw2(config)#ip route 0.0.0.0 0.0.0.0 172.17.166.22
msw2(config)#ip route 0.0.0.0 0.0.0.0 172.17.166.26
msw2(config)#ip routing
msw2(config)#spanning-tree vlan 1 root secondary 

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值