运用STP VTP HSRP 构建冗余的网络

来源:互联网 发布:潮流计算的软件 编辑:程序博客网 时间:2024/04/29 13:57

准备知识(如果清楚这些知识可以把本页拉到最后直接跳到第二页):

  STP(生成树协议)详解

  二层管理协议。在一个扩展的局域网中参与STP的所有交换机之间通过交换桥协议数据单元BPDU(Bridge Protocol Data Unit)来实现;为稳定的生成树拓扑结构选择一个根桥;为每个交换网段选择一台指定交换机;将冗余路径上的交换机置为Blocking,来消除网络中的环路。

  IEEE 802.1d是最早关于STP的标准,它提供了网络的动态冗余切换机制。STP使您能在网络设计中部署备份线路,并且保证:

  在主线路正常工作时,备份线路是关闭的。

  当主线路出现故障时自动使能备份线路,切换数据流。

  VTP:思科VLAN中继协议(VTP:Cisco VLAN Trunking Protocol)

  VLAN 中继协议(VTP)是思科第2层信息传送协议,主要控制网络范围内 VLANs 的添加、删除和重命名。VTP 减少了交换网络中的管理事务。当用户要为 VTP服务器配置新 VLAN 时,可以通过域内所有交换机分配 VLAN,这样可以避免到处配置相同的 VLAN.VTP 是思科私有协议,它支持大多数的Cisco Catalyst 系列产品。

  通过 VTP,其域内的所有交换机都清楚所有的 VLANs 情况,但当 VTP 可以建立多余流量时情况例外。这时,所有未知的单播(Unicasts)和广播在整个 VLAN 内进行扩散,使得网络中的所有交换机接收到所有广播,即使 VLAN 中没有连接用户,情况也不例外。而 VTP Pruning 技术正可以消除该多余流量。

  缺省方式下,所有Cisco Catalyst交换机都被配置为 VTP 服务器。这种情形适用于 VLAN 信息量小且易存储于任意交换机(NVRAM)上的小型网络。对于大型网络,由于每台交换机都会进行 NVRAM存储操作,但该操作对于某些点是多余的,所以在这些点必须设置一个“判决呼叫”(Judgment Call)。基于此,网络管理员所使用的 VTP 服务器应该采用配置较好的交换机,其它交换机则作为客户机使用。此外需要有某些 VTP 服务器能提供网络所需的一定量的冗余。

  到目前为止,VTP 具有三种版本。其中 VTP v2 与 VTP v1 区别不大,主要不同在于:VTP v2 支持令牌环 VLANs,而 VTP v1 不支持。通常只有在使用 Token Ring VLANs 时,才会使用到 VTP v2,否则一般情况下并不使用 VTP v2.

  VTPv3 不能直接处理 VLANs 事务,它只负责管理域(Administrative Domain)内不透明数据库的分配任务。与前两版相比,VTP v3 具有以下改进:

  * 支持扩展 VLANs.

  * 支持专用 VLANs 的创建和广告。

  * 提供服务器认证性能。

  * 避免“错误”数据库进入 VTP 域。

  * 与 VTP v1 和 VTP v2 交互作用。

  * 支持每端口(On a Per-Port Basis)配置。

  * 支持传播VLAN数据库和其它数据库类型。

  HSRP:热备份路由器协议(HSRP:Hot Standby Router Protocol)

  热备份路由器协议(HSRP)的设计目标是支持特定情况下 IP 流量失败转移不会引起混乱、并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情形下仍能维护路由器间的连通性。换句话说,当源主机不能动态知道第一跳路由器的 IP 地址时,HSRP 协议能够保护第一跳路由器不出故障。该协议中含有多种路由器,对应一个虚拟路由器。HSRP 协议只支持一个路由器代表虚拟路由器实现数据包转发过程。终端主机将它们各自的数据包转发到该虚拟路由器上。

  负责转发数据包的路由器称之为主动路由器(Active Router)。一旦主动路由器出现故障,HSRP 将激活备份路由器(Standby Routers)取代主动路由器。HSRP 协议提供了一种决定使用主动路由器还是备份路由器的机制,并指定一个虚拟的 IP 地址作为网络系统的缺省网关地址。如果主动路由器出现故障,备份路由器(Standby Routers)承接主动路由器的所有任务,并且不会导致主机连通中断现象。

  HSRP 运行在 UDP 上,采用端口号1985.路由器转发协议数据包的源地址使用的是实际 IP 地址,而并非虚拟地址,正是基于这一点,HSRP 路由器间能相互识别。


备注:

  使用的是2950.所以在交换机SW1 SW2 的f 0/5 没有封装 dot1q(默认)。

  R3 没有静态路由。这个拓扑只保障了到网关的负载均衡与冗余备份。没有写连接外网。

  网络拓扑:


 

  配置指令:

  SW1

switch > enable
switch # configure terminal
switch (config) # hostname sw1
sw1 (config) # vtp domain cisco
sw1 (config) # vtp mode server
sw1 (config) # vtp password cisco
sw1 (config) # exit
sw1 # vlan database
sw1 (vlan) # vlan 2
sw1 (vlan) # vlan 3
sw1 (vlan) # exit
sw1 # configure terminal
sw1 (config) # interface range fastethernet 0/1 - 5
sw1 (config-if) # switchport mode trunk
sw1 (config-if) # no shutdown
sw1 (config-if) # interface range fastethernet 0/3 - 4
sw1 (config-if) # channel-group 1 mode on
sw1 (config-if) # exit
sw1 (config) # spanning-tree vlan 2 root primary
sw1 (config) # spanning-tree vlan 3 root secondby
sw1 (config) # exit
sw1 #

  SW2

switch > enable
switch # configure terminal
switch (config) # hostname sw 2
sw2 (config) # vtp domain cisco
sw2 (config) # vtp mode server
sw2 (config) # vtp password cisco
sw2 (config) # interface range fastethernet 0/1 - 5
sw2 (config-if) # switchport mode trunk
sw2 (config-if) # no shutdown
sw2 (config-if) # interface range fastethernet 0/3 - 4
sw2 (config-if) # channel-group 1 mode on
sw2 (config-if) # exit
sw2 (config) # spanning-tree vlan 3 root primary
sw2 (config)# spanning-tree vlan 2 root secondby
sw2 (config) # exit
sw2 #

  SW3

switch > enable
switch # configure terminal
switch (config) # hostname sw 3
sw3 (config) # vtp domain cisco
sw3 (config) # vtp mode client
sw3 (config) # vtp password cisco
sw3 (config) # interface range fastethernet 0/1 - 2
sw3 (config-if) # switchport mode trunk
sw3 (config-if) # no shutdown
sw3 (config-if) # interface fastethernet 0/3
sw3 (config-if) # switchport mode access
sw3 (config-if) # switchport access vlan 2
sw3 (config-if) # spanning-tree portfast
sw3 (config-if) # interface fastethernet 0/4
sw3 (config-if) # switchport mode access
sw3 (config-if) # switchport access vlan 3
sw3 (config-if) # spanning-tree portfast
sw3 (config-if) # exit
sw3 (config) # spanning-tree uplinkfast
sw3 (config) # spanning-tree vlan3
sw3 (config) # spanning-tree vlan2
sw3 (config) # exit
sw3 #

  SW4

switch > enable
switch # configure terminal
switch (config) # hostname sw 4
sw4 (config) # vtp domain cisco
sw4 (config) # vtp mode client
sw4 (config) # vtp password cisco
sw4 (config) # interface range fastethernet 0/1 - 2
sw4 (config-if) # switchport mode trunk
sw4 (config-if) # no shutdown
sw4 (config-if) # interface fastethernet 0/3
sw4 (config-if) # switchport mode access
sw4 (config-if) # switchport access vlan 2
sw4 (config-if) # spanning-tree portfast
sw4 (config-if) # interface fastethernet 0/4
sw4 (config-if) # switchport mode access
sw4 (config-if) # switchport access vlan 3
sw4 (config-if) # spanning 每tree portfast
sw4 (config-if) # exit
sw4 (config) # spanning-tree uplinkfast
sw4 (config) # spanning-tree vlan3
sw4 (config) # spanning-tree vlan2
sw4 (config) # exit
sw4 #

  R1

router > enable
router # configure terminal
router (config) # hostname r1
r1 (config) # interface fastethernet 0/0.1
r1 (config-subif) # ip add 192.168.2.254 255.255.255.0
r1 (config-subif) # encapsulation dot1q 2
r1 (config-subif) # standby 2 ip 192.168.2.1
r1 (config-subif) # standby 2 priority 105
r1 (config-subif) # standby 2 preempet
r1 (config-subif) # standby 2 track fastethernet 0/1
r1 (config-subif) # interface fastethernet 0/0.2
r1 (config-subif) # ip add 192.168.3.254 255.255.255.0
r1 (config-subif) # encapsulation dot1q 3
r1 (config-subif) # standby 3 ip 192.168.3.1
r1 (config-subif) # standby 3 preempet
r1 (config-subif) # standby 3 track fastethernet 0/1
r1 (config-if) # interface fastethernet 0/0
r1 (config-if) # no shutdown
r1 (config-if) # interface fastethernet 0/1
r1 (config-if) # ip add 192.168.4.2 255.255.255.0
r1 (config-if) # no shutdown
r1 (config-if) # exit
r1 (config) # exit
r1 #

  R2

router > enable
router # configure terminal
router (config) # hostname r2
r2 (config) # interface fastethernet 0/0.1
r2 (config-subif) # ip add 192.168.2.253 255.255.255.0
r2 (config-subif) # encapsulation dot1q 2
r2 (config-subif) # standby 2 ip 192.168.2.1
r2 (config-subif) # standby 2 preempet
r2 (config-subif) # standby 2 track fastethernet 0/1
r2 (config-subif) # interface fastethernet 0/0.2
r2 (config-subif) # ip add 192.168.3.253 255.255.255.0
r2 (config-subif) # encapsulation dot1q 3
r2 (config-subif) # standby 3 priority 105
r2 (config-subif) # standby 3 preempet
r2 (config-subif) # standby 3 ip 192.168.3.1
r2 (config-subif) # standby 3 track fastethernet 0/1
r2 (config-if) # interface fastethernet 0/0
r2 (config-if) # no shutdown
r2 (config-if) # interface fastethernet 0/1
r2 (config-if) # ip add 192.168.5.2 255.255.255.0
r2 (config-if) # no shutdown
r2 (config-if) # exit
r2 (config) # exit
r2 #

  R3

router > enable
router # configure terminal
router (config) # hostname r3
r3 (config) # interface thernet 0/0
r3 (config-if) # ip add 192.168.4.1 255.255.255.0
r3 (config-if) # no shutdown
r3 (config) # interface ethernet 0/1
r3 (config-if) # ip add 192.168.5.1 255.255.255.0
r3 (config-if) # no shutdown
r3 (config-if) # exit
r3 (config) # exit
r3 #