核心提示:一、HSRP、SHRP介绍,热备份路由协议,主要为我们提供了这样的一个机制。其主要目的是在IP协议传输失败的情况下支持不间断的服务,保证网络的高可用性…



一、对公司的简介



SHRP的热备份路由协议。它主要为我们提供了这样一个机制。其主要目的是支持IP协议传输故障下的不间断的服务,保证了网络的高可用性。特别是,这个协议是用来防止第一跳路由当源主机不能动态学习第一跳路由器IP地址失败。它主要用于多址,多播和广播网络(如以太网)。



二、HSRP的工作原理



HSRP协议利用一个确定路由器配置HSRP协议是默认的主动路由器的优先级方案。如果一个路由器的优先级高于所有其他的路由器,路由器成为活动路由器。路由器的缺省优先级是100,所以如果只有一个路由器的优先级越高100,路由器将成为活动路由器。



HSRP协议通过广播HSRP优先级设置HSRP协议的路由器之间选择当前活动路由器。当主动路由器不能给你好在预定时间段的信息,具有最高优先级的备用路由变为主动路由器。路由器之间的数据包传输到网络上的所有主机透明。 U3000

以下三个组播报文交换配置HSRP协议的路由器:



hellomdash;mdash;mdash;hello消息通知其他路由器发送HSRP优先级和状态信息的路由器,路由器的默许和HSRP发送Hello消息每3秒。



coupmdash;mdash;mdash;发送消息时,备用政变路由器成为活动路由器;



resignmdash;mdash;mdash;当主动路由器停工或当有一个路由器发送Hello消息优先级高的当主动路由器发送一个辞职的消息。在任何时候,路由器配置了HSRP协议将在以下六种状态之一:



initialmdash;mdash;mdash;对HSRP的启动状态,路由器没有运行,一般状态时输入的端口配置或是刚刚开始。 U3000

learnmdash;mdash;mdash;路由器已经得到了虚拟IP地址,但它不是一种主动路由器或等待路由器。它一直听你好消息从活动路由器和等待路由器。



listenmdash;mdash;mdash;路由器是听你好消息。



speakmdash;mdash;mdash;在这个状态,路由器定期发送Hello消息并积极参与活动或等待路由器路由器。



standbymdash;mdash;mdash;路由器准备接管包传输时的主动路由器故障。



activemdash;mdash;mdash;路由器执行包传输功能,即路由器处于活动状态。



三。应用案例



1,案件1



(1)执行环境:思科小凡模拟器



(2)请求:



一个现有的网络,有两个VLAN,两个VLAN通过路由器进行通信,要达到网络的高可用性,还必须保证在路由器出现损坏的情况下,必须保证路由器在路由器使用时的效率。



(3)网络拓扑:



使用基于网络需求的绘图工具绘制网络拓扑,如图1所示。



图1:网络拓扑

(4)设备实现:



1)路由器R1的配置:

输入特权模式

路由器>启用

输入用户模式

路由器# config t

路由器(config)#居屋

修改名称

路由器R1(config)#主机名

R1(config)# int f0 / 0

启动/接口

R1(config-if)#没有关

R1(config-if)#退出

R1(config)# int f0 / 0.1

R1(config-subif)#封装D

/ /分为dot1q型接口包

R1(config-subif)#封装dot1q 10

配置IP地址

R1(config-subif)# IP添加192.168.10.1 255.255.255.0

R1(config-subif)#退出

输入/子接口

R1(config)# int f0 / 0.2

R1(config-subif)# EN

R1(config-subif)#封装D

出口包装dot1q / /字节

R1(config-subif)#封装dot1q 20

R1(config-subif)# IP添加192.168.20.1 255.255.255.0

/ / HSRP协议配置

R1(config)# int f0 / 0.1

R1(config-subif)# ST

R1(config-subif)#备用

编号10添加热备份和备份虚拟IP

R1(config-subif)#待机10 IP 192.168.10.254

R1(config-subif)#备用PRI

分配优先级(优先级越大,缺省值为100)

R1(config-subif)#优先级120

立即开始/抓住

R1(config-subif)#备用预

R1(config-subif)#待机抢占

R1(config)# int f0 / 0.2

R1(config-subif)#备用

编号20添加热备份和备份虚拟IP

R1(config-subif)#待机20 IP 192.168.20.254

R1(config-subif)#待机20优先级

分配优先级(优先级越大,缺省值为100)

R1(config-subif)#待机20优先100

R1(config-subif)#备用预

立即开始/抓住

R1(config-subif)#待机抢占



2)路由器R2配置:

路由器>启用

路由器# config t

修改名称

路由器R2(config)#主机名

R2(config)# int f0 / 0

启动/接口

R2(config-if)#没有关

R2(config-if)#退出

输入/子接口

R2(config)# int f0 / 0.1

R2(config-subif)#封装D

为dot1q式VLAN 10接口/包

R2(config-subif)#封装dot1q 10

R2(config-subif)# IP添加192.168.10.2 255.255.255.0

R2(config-subif)#退出

输入/子接口

R2(config)# int f0 / 0.2

为dot1q式VLAN 20接口/包

R2(config-subif)#封装dot1q 20

R2(config-subif)# IP添加192.168.20.2 255.255.255.0

R2(config)# int f0 / 0.1

R2(config-subif)#斯坦

编号10添加热备份和备份虚拟IP

R2(config-subif)#待机10 IP 192.168.10.254

R2(config-subif)#斯坦

R2(config-subif)#待机10优先级

分配优先级(优先级越大,缺省值为100)

R2(config-subif)#待机10优先100

R2(config-subif)#斯坦

R2(config-subif)#待机10预

立即开始/抓住

R2(config-subif)#待机10抢占

R2(config-subif)#退出

R2(config)# int F

输入/子接口

R2(config)# int f0 / 0.2

R2(config-subif)# sstan

R2(config-subif)#斯坦

编号10添加热备份和备份虚拟IP

R2(config-subif)#待机20 IP 192.168.20.254

R2(config-subif)#斯坦

R2(config-subif)#待机20优先级

分配优先级(优先级越大,缺省值为100)

R2(config-subif)#待机20优先120

R2(config-subif)# STA

R2(config-subif)#待机20预

立即开始/抓住

R2(config-subif)#待机20抢占



3)交换机S1的配置:

路由器> ENA

路由器# config t

输入配置命令,每行一个。结束与控制键/ Z.

路由器(config)#居屋

修改名称

路由器的主机名(config)# S1

S1(config)#退出

S1 # VLAN数据库

/ /创建vlan10

S1(VLAN)# VLAN 10

增加VLAN 10:

名称:vlan0010

/ /创建vlan10

S1(VLAN)# VLAN 20

增加VLAN 20:

名称:vlan0020

S1(VLAN)#退出

S1 # config t

输入/接口

S1(config)# int f0 / 0

接口/设置到主干

S1(config-if)# switchport mode trunk

主干允许所有VLAN通过

S1(config-if)#默认允许所有vlan

S1(config-if)#退出

S1(config)# int f0 / 1

S1(config-if)工作模式# TR

接口/设置到主干

S1(config-if)# switchport mode trunk

主干允许所有VLAN通过

S1(config-if)#默认允许所有vlan

S1(config-if)#退出

S1(config)# int f0 / 2

S1(config-if)工作模式# TR

接口/设置到主干

S1(config-if)# switchport mode trunk

主干允许所有VLAN通过

S1(config-if)#默认允许所有vlan

S1(config)# int f0 / 10

S1(config-if)# SW

S1(config-if)#是ACC

允许VLAN 10

S1(config-if)#交换机接入VLAN 10

S1(config-if)#退出

S1(config)# int f0 / 20

S1(config)# int f0 / 15

S1(config-if)#交换机接入VLAN 20



4)交换机S2的配置:

路由器> ENA

路由器# config t

路由器(config)#主机

修改名称

路由器的主机名(config)# S2

S2(config)#退出

S2 # VLAN数据

S2 # VLAN数据库

创建一个VLAN 10

S2(VLAN)# VLAN 10

增加VLAN 10:

名称:vlan0010

创建一个VLAN 20

S2(VLAN)# VLAN 20

增加VLAN 20:

名称:vlan0020

S2 # config t

S2(VLAN)#退出

输入/接口

S2(config)# int f0 / 0

S2(config-if)工作模式# TR

接口/设置到主干

S2(config-if)# switchport mode trunk

S2(config-if)#退出

S2(config)# int f0 / 1

S2(config-if)工作模式# TR

接口/设置到主干

S2(config-if)# switchport mode trunk

允许所有中继通过VLAN

S2(config-if)#默认允许所有vlan

S2(config-if)# int f0 / 2

S2(config-if)工作模式# TR

S2(config-if)# switchport mode trunk

S2(config-if)#默认允许所有vlan

S2(config-if)#退出

S2(config)# int f0 / 10

S2(config-if)#工作交流

S2(config-if)#交换机接入VLAN 10

S2(config-if)# int f0 / 15

界面设计是为了让vlan20 / /

S2(config-if)#交换机接入

S2(config-if)#交换机接入VLAN 20



(5)试验验证:

1)看看R1的HSRP协议:

查看R1的HSRP协议如下所示:



2)1平4



3)断开R2的接口,即当R2损坏,看看R1的HSRP协议





2,案件2



(1)执行环境:思科小凡模拟器



(2)请求:



一个现有的网络,有两个VLAN,两个VLAN通过路由器进行通信,现在需要很高的可用性来实现网络,但也必须保证在路由器出现损坏的情况下,必须保证路由器在两个路由器的有效利用,而两个VLAN主机可以接入互联网。



(3)网络拓扑:



使用基于网络需求的绘图工具绘制网络拓扑,如图2所示。



图2:网络拓扑



(4)设备的配置:



1)路由器R1的配置:

输入特权模式

路由器>启用

输入用户模式

路由器# config t

路由器(config)#居屋

修改名称

路由器R1(config)#主机名

R1(config)# int S1 / 0

配置IP地址

R1(config-if)# IP地址192.168.1.1 255.255.255.0

R1(config-if)#没有关

R1(config-if)#退出

R1(config)# int f0 / 0

R1(config-if)#没有关

R1(config-if)#退出

输入/子接口

R1(config)# int f0 / 0.1

R1(config-subif)# EN

R1(config-subif)#封装D

为dot1q / / vlan10接口封装

R1(config-subif)#封装dot1q 10

配置IP地址

R1(config-subif)# IP添加192.168.10.1 255.255.255.0

R1(config-subif)#退出

R1(config)# int f0 / 0.2

为dot1q / / vlan10接口封装

R1(config-subif)#封装D

R1(config-subif)#封装dot1q 20

配置IP地址

R1(config-subif)# IP添加192.168.20.1 255.255.255.0

/ / HSRP协议配置

R1(config)# int f0 / 0.1

R1(config-subif)# ST

R1(config-subif)#备用

编号10添加热备份和备份虚拟IP

R1(config-subif)#待机10 IP 192.168.10.254

R1(config-subif)#备用PRI

分配优先级(优先级越大,缺省值为100)

R1(config-subif)#优先级120

立即开始/抓住

R1(config-subif)#备用预

R1(config-subif)#待机抢占

配置跟踪接口,当接口减少30时中断优先级

R1(config-subif)#待机10轨道S1 / 0 30

R1(config)# int f0 / 0.2

R1(config-subif)#备用

R1(config-subif)#待机20 IP

编号10添加热备份和备份虚拟IP

R1(config-subif)#待机20 IP 192.168.20.254

R1(config-subif)#待机20优先级

分配优先级(优先级越大,缺省值为100)

R1(config-subif)#待机20优先100

R1(config-subif)#备用预

立即开始/抓住

R1(config-subif)#待机抢占

配置默认路由

R1(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1

配置访问控制列表

R1(config)#访问列表10允许192.168.10.0 255.255.255.0

R1(config)#访问列表10允许192.168.20.0 255.255.255.0

R1(config)# int f0 / 0.1

R1(config-subif)# IP NAT

在接口配置中允许NAT进入。

R1(config-subif)# ip nat inside

R1(config-subif)# int f0 / 0.2

在接口配置中允许NAT进入。

R1(config-subif)# IP NAT

R1(config-subif)# ip nat inside

R1(config-subif)# int S1 / 0

R1(config-if)# NAT出去

NAT接口的应用

R1(config-if)# NAT外

R1(config)# NAT源列表10 int

R1 (config) #ip NAT source list 10 interface s1/0

2)路由器R2配置:

路由器>启用

路由器# config t

修改名称

路由器R2(config)#主机名

R2(config)# int S1 / 1

配置IP地址

R2(config-if)# IP添加192.168.2.1 255.255.255.0

R2(config-if)#没有关

R2(config-if)#退出

R2(config)# int f0 / 0

启动/接口

R2(config-if)#没有关

R2(config-if)#退出

输入/子接口

R2(config)# int f0 / 0.1

R2(config-subif)#封装D

为dot1q式VLAN 10接口/包

R2(config-subif)#封装dot1q 10

R2(config-subif)# IP添加192.168.10.2 255.255.255.0

R2(config-subif)#退出

输入/子接口

R2(config)# int f0 / 0.2

为dot1q式VLAN 20接口/包

R2(config-subif)#封装dot1q 20

R2(config-subif)# IP添加192.168.20.2 255.255.255.0

R2(config)# int f0 / 0.1

R2(config-subif)#斯坦

编号10添加热备份和备份虚拟IP

R2(config-subif)#待机10 IP 192.168.10.254

R2(config-subif)#斯坦

R2(config-subif)#待机10优先级

分配优先级(优先级越大,缺省值为100)

R2(config-subif)#待机10优先100

R2(config-subif)#斯坦

R2(config-subif)#待机10预

立即开始/抓住

R2(config-subif)#待机10抢占

R2(config-subif)#退出

R2(config)# int F

输入/子接口

R2(config)# int f0 / 0.2

R2(config-subif)# sstan

R2(config-subif)#斯坦

编号10添加热备份和备份虚拟IP

R2(config-subif)#待机20 IP 192.168.20.254

R2(config-subif)#斯坦

R2(config-subif)#待机20优先级

分配优先级(优先级越大,缺省值为100)

R2(config-subif)#待机20优先120

R2(config-subif)# STA

R2(config-subif)#待机20预

立即开始/抓住

R2(config-subif)#待机20抢占

配置默认路由

R2(config)# ip route 0.0.0.0 0.0.0.0 192.168.2.1

当接口跟踪失败优先级降低30时,配置接口。

R2(config-subif)#待机20轨道S1 / 1 30

配置访问控制列表允许所有20

R2(config)#访问列表20允许任何

R2(config)# int f0 / 0.1

在接口集中

R2(config-subif)# NAT的INS

R2(config-subif)# ip nat inside

R2(config-subif)# int f0 / 0.2

R2(config-subif)# IP NAT

在接口集中

R2(config-subif)# ip nat inside

R2(config-subif)# int S1 / 1

R2(config-if)# IP Na

接口中的访问设置

R2(config-if)# NAT的欧

R2(config-if)# NAT外

动态配置

R2(config)# NAT源列表20接口S1 / 1

3)路由器R3的配置:

路由器> ENA

路由器# conf t

修改名称

路由器的主机名(config)# R3

R3(config)# int S1 / 0

如果# r3config)IP地址

配置IP地址

R3(config-if)# IP地址192.168.1.1 255.255.255.0

打开接口

R3(config-if)#没有关

R3(config-if)#退出

输入/接口

R3(config)# int S1 / 1

R3(config-if)# IP地址

配置IP地址

R3(config-if)# IP地址192.168.2.1 255.255.255.0

R3(config-if)#没有关

R3(config)# int噜

R3(config)# int回送0

R3(config-if)# IP地址

R3(config-if)# IP地址1.1.1.1 255.255.255.0



(5)试验验证:

1)ping1.1.1.1和PC1路由跟踪,如下:



qtvkwgnvulzbmtuxlmpwzw = =src= / / /上传下载文件2014 / 0509 / 20140509092202377.jpgtitle=9.png />。

2)看路由器R1的HSRP协议



3)断开R2的S1 / 1接口,看看R2的变化和R1 HSRP

R2(config-if)#关

R2(config-if)#

* 3月1日06:09:06.914:% hsrp-5-statechange:加入 / 0.2玻璃20激活状态->说 / /从这里你可以看到S2 F0 / 0.2接口激活到SPEEK状态。

在路由器R1 HSRP的变化如下图所示:



5)pc4ping1.1.1.1中断后,R2的S1 / 1界面,如下图: