链路聚合和STP生成树及静态路由补充

  • 一、链路聚合
  • 概念
  • LACP模式
  • 配置命令:
  • 二、STP生成树协议的基本原理与简单配置
  • 环路的产生
  • 生成树的作用
  • BPDU(Bridge Protocol Data Unit)网桥协议数据单
  • 选举根交换机的原则及优先级修改
  • 端口角色及端口状态描
  • 配置命令
  • 三、浮动路由
  • 综合实验
  • r1
  • r2
  • sw1
  • SW3
  • LSW4


一、链路聚合

概念

1.端口绑定技术:链路聚合(Link Aggregation)是将一组物理接口捆绑在一起作为一个逻辑接口来增加带宽的一种方法。又称多接口负载均衡组(Load Sharing Group)或链路聚合组(Link Aggregation Group)通过两台设备之间建立链路聚合组,可以提供更高的通讯带宽和更高的可靠性,不仅为设备之间通信提供冗余保护,而且不需要对硬件进行升级减少成本
2.eth-trunk取值范围:0-63
3.注意事项

  • -每个eth-trunk接口下最多可以包含8个成员接口
  • 成员接口不能配置任何业务和静态MAC地址
  • 成员接口加入eth-trunk时,必须为缺省的hybrid类型接口
  • eth-trunk接口不能嵌套即成员接口不能是eth-trunk
  • 一个以太网接口只能加入到一个eth-trunk接口如果需要加入其他eth-trunk接口,必须先退出原来的eth-trunk接口
  • 一个eth-trunk接口中的成员接口必须是同一类型,例如FE接口速率和GE接口不能加入同一个eth-trunk接口
  • 成员接口的速率不一致时实际使用中的速率小的接口可能会出现拥塞导致丢包
  • 可以将不同接口模块上的以太网接口加入到同一eth-trunk
  • 如果本地设备使用了eth-trunk,与成员接口直连的对端接口也必须捆绑为eth-trunk接口两端才能正常通信
  • 当成员接口加入eth-trunk后学习mac地址时是按照eth-trunk来学习的而不是按照成员接口来学习的

LACP模式

4.LACP模式不仅可以实现增加带宽提高可靠性负载分担的目的而且提供eth-trunk的容错性提供备份的功能。LACP模式下部分链路是活动链路所有活动链路都参与数据的转发,如果某条链路故障会使用一条备份的链路作为活动链路始终保持一定数的活动链路

配置命令:

[Huawei]lacp priority 1000 #配置系统LACP优先级
[Huawei]int Eth-Trunk 1 #进入Eth-Trunk视图
[Huawei-Eth-Trunk 1]bpdu enable #配置接口上发送到BPDU报文到CPU处理,起到防环作用
[Huawei-Eth-Trunk 1]mode lacp-static #配置Eth-Trunk为静态LACP模式
[Huawei-Eth-Trunk 1]trunkport ethernet/ge 0/0/0 to 0/0/3 #批量添加接口到eth-trunk 1
或者
[Huawei]int e0/0/0
[Huawei-Ethernet0/0/1]eth-trunk 1 #进入接口逐个添加
[Huawei-Eth-Trunk1]port link-type trunk #配置聚合链路的通过的vlan
[Huawei-Eth-Trunk1]port trunk allow-pass vlan all

二、STP生成树协议的基本原理与简单配置

环路的产生

1.环路引起的问题之一广播风暴

环路引起的问题之二mac地址表不稳定

环路引起的问题之三多帧复制

广播风暴:三个交换机两两相连,互相广播,无限转发,产生广播风暴。

多帧复制:PC1发送的数据可以从SW1经过SW3再到SW2传达给PC2,也可以从SW1到SW2再到PC2,导致PC2收到两次数据帧。

MAC地址紊乱:产生环路后,PC1发送数据SW1向SW3进行广播使得SW3F0/1记录下PC1的MAC地址,SW1传到SW2,SW2再向SW3进行广播,导致SW3F0/2又记录了PC1的MAC地址,来回重复绑定MAC地址。

esxi静态链路聚合 环路_网络

生成树的作用

a.消除环路:阻塞某个端口
b.链路备份
当有有环路存在时,广播的发送会引起全网的广播风暴,因此需要打破环路环路生成的条件,而生成树协议就是解决二层广播风暴的重要手段,通过阻塞一些端口打破环路产生条件,当链路出现问题时这些被阻塞的端口可以过渡到转发状态,实现链路备份的作用。

BPDU(Bridge Protocol Data Unit)网桥协议数据单

1.概念
a.STP的各种选举是通过交换BPDU报文来实现的,BPDU是直接封装在以太网帧中的
b.BPDU报文字段:根网ID,根径成本,发送网桥ID,端口ID
对于参与stp的所有交换机sw它们都通过数据消息的交换来获取网络中其他sw的信息这种消息就被称为BPDU
BPDU是直接封装在二层的协议
2.BPDU的功能
a.选举根桥
b.确定冗余路径的位置
c.通过阻塞特定端口来避免环路
d.通告网络的拓扑变更
e.监控生成树的状态
3.BPDU分为两种类型
a.配置BPDU
通常由根网桥协议周期性间隔发生包括STP参数用于进行各种选举
b.TCN(topology change notification)拓扑变更通告BPDU
这种BPDU是交换机检测到拓扑发生变更时产生可由非根网桥发出

选举根交换机的原则及优先级修改

lowest BID=网桥优先级+mac地址(越小越优先)交换机默认网桥优先级是32768
配置方法
a.修改网桥优先级命令
[sw1]stp priority 0 #数值是4096的倍数
b.设置此网桥为根网桥
[sw1]stp root primary #优先级是0
c.display stp #查看根网桥的命令
d.display stp brief #查看stp接口角色及状态信息

端口角色及端口状态描

1.端口角色
RP:根端口,每个非根网桥上有且只有一个,选举到达根网桥路径开销值最小的成为端口
DP:指定端口,根网桥上每个端口都是指定端口,非根网桥上需要转发数据的端口也是指定端口
AP:预备端口,该端口状态为blocking只收BPDU 不发送BPDU
2.端口状态
Disable(禁用状态):不转发数据帧,不学习MAC地址表,不参与生产数计算
Blocking/discaring(阻塞状态):不转发数据帧,不学习MAC地址表接送并处理BPDU,不发送BPDU,只接受BPDU
Listening(侦听状态):不转发数据帧,不学习MAC地址表,参与生成树计算,接受并发送BPDU
Learning(学习状态):不转发数据帧,学习MAC地址表,参与生成树计算,接受并发送BPDU
Forwarding(转发状态):转发数据帧,学习MAC地址表,参与生成树计算,接受并发送BPDU
从blocking—forwarding有50s延迟,blocking—listening有20s的老化时间,listening—learning有15s的过渡时间,learning—forwarding有15s时间
3.选举根端口指定端口的规则
a.Lowest path cost to root bridge(到达根的最小路径开销)
b.Lowest sender BID(最小发送方BID)
c.Lowest sender port ID(最小发送方PID)端口优先级+发送方端口

BW带宽

cost路径开销

10M

100

100M

19

1G

4

10G

2

4.修改网桥接口优先级命令
[SW1-Ethernet 0/0/2]stp port priority 0 #16的倍数

配置命令

[SW1]stp mode mstp #将交换机配置成MSTP模式,MSTP兼 容STP/RSTP
[SW1]stp region-configuration #进入MSTP域视图MSTP配置模式
[ SW1-mst-region] region-name huawe 1 #配置MSTP域的域名为huawei1,缺省为交换设备主控板上管理网口的MAC地址。
[ SW1- -mst- -region] revision-level 1 #配置MSTP域的MSTP修订级别的1,缺省情况下MSTP域的MSTP修订级别0,需要配置的主机一致
[ SW1 -mst-region] instance 1 vlan 10 #同一vlan的数据只能对应一个实例,而一个实例可以对应多个vlan(instance1vlan2to10)
将vlan 10加入实例1中
[ sw1-mst-region] instance 2 vlan 20
将vlan 20加入实例2中
[sw1 -mst-region] check region-configuration
查看MSTP域配置参数
[ sw1-mst-region] active region-configuration
激活配置(必须配置)
[ sw1-mst-region]q
以下命令只有根交换机需要配置各自的实例
[sw1]stp instance 1 root primary
配置此交换机实例1的主根桥
[sw1]stp instance 2 root secondary
配置此交换机为实例2的备份根桥

三、浮动路由

浮动路由是指配置两条静态路由,默认选取链路质量优(带宽大)作为主路径,当主路径出现故障时由带宽较小的备份路由顶替,保持网络不中断,备份链路优先级preference>60
IP route-static 0.0.0.0 0 下一跳地址 preference 61 #大于60静态路由的优先级是60

综合实验

esxi静态链路聚合 环路_网络_02

分析:关于生成树交换机实验部分 路由器是要配置浮动路由
与电脑连接的交换机用access
交换机与交换机用trunk 交换机sw2为实例1vlan10的根 sw4为实列2vlan20的根
与路由器连接的用access

r1

u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 12.1.1.1 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int e0/0/0
[Huawei-Ethernet0/0/0]ip add 21.1.1.1 24
[Huawei-Ethernet0/0/0]un sh
Info: Interface Ethernet0/0/0 is not shutdown.
[Huawei-Ethernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 2.2.2.2 32 12.1.1.2
[Huawei]ip route-static 2.2.2.2 32 21.1.1.2 perference 61
[Huawei]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]vlan-type dot1q 10 default
[Huawei-GigabitEthernet0/0/0.1]ip add 192.168.10.1 24
[Huawei-GigabitEthernet0/0/0.1]un sh
Info: Interface GigabitEthernet0/0/0.1 is not shutdown.
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]vlan-type dot1q 20 default
[Huawei-GigabitEthernet0/0/0.2]ip add 192.168.20.1 24
[Huawei-GigabitEthernet0/0/0.2]un sh
Info: Interface GigabitEthernet0/0/0.2 is not shutdown.
[Huawei-GigabitEthernet0/0/0.2]int g0/0/0.3
[Huawei-GigabitEthernet0/0/0.3]vlan-type dot1q 30 default
[Huawei-GigabitEthernet0/0/0.3]ip add 192.168.30.1 24
[Huawei-GigabitEthernet0/0/0.3]un sh
Info: Interface GigabitEthernet0/0/0.3 is not shutdown.
[Huawei-GigabitEthernet0/0/0.3]int g0/0/0.4
[Huawei-GigabitEthernet0/0/0.4]vlan-type dot1q 40 default
[Huawei-GigabitEthernet0/0/0.4]ip add 192.168.40.1 24
[Huawei-GigabitEthernet0/0/0.4]un sh
Info: Interface GigabitEthernet0/0/0.4 is not shutdown.
[Huawei-GigabitEthernet0/0/0.4]q

r2

u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 12.1.1.2 24
[Huawei-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]int e0/0/0
[Huawei-Ethernet0/0/0]ip add 21.1.1.2 24
[Huawei-Ethernet0/0/0]un sh
Info: Interface Ethernet0/0/0 is not shutdown.
[Huawei-Ethernet0/0/0]int loop 0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 1.1.1.1 32 12.1.1.1
[Huawei]ip route-static 1.1.1.1 32 21.1.1.1 perference 61
[Huawei]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]vlan-type dot1q 10 default
[Huawei-GigabitEthernet0/0/0.1]ip add 192.168.10.1 24
[Huawei-GigabitEthernet0/0/0.1]un sh
Info: Interface GigabitEthernet0/0/0.1 is not shutdown.
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]vlan-type dot1q 20 default
[Huawei-GigabitEthernet0/0/0.2]ip add 192.168.20.1 24
[Huawei-GigabitEthernet0/0/0.2]un sh
Info: Interface GigabitEthernet0/0/0.2 is not shutdown.
[Huawei-GigabitEthernet0/0/0.2]int g0/0/0.3
[Huawei-GigabitEthernet0/0/0.3]vlan-type dot1q 30 default
[Huawei-GigabitEthernet0/0/0.3]ip add 192.168.30.1 24
[Huawei-GigabitEthernet0/0/0.3]un sh
Info: Interface GigabitEthernet0/0/0.3 is not shutdown.
[Huawei-GigabitEthernet0/0/0.3]int g0/0/0.4
[Huawei-GigabitEthernet0/0/0.4]vlan-type dot1q 40 default
[Huawei-GigabitEthernet0/0/0.4]ip add 192.168.40.1 24
[Huawei-GigabitEthernet0/0/0.4]un sh
Info: Interface GigabitEthernet0/0/0.4 is not shutdown.
[Huawei-GigabitEthernet0/0/0.4]q

sw1

LSW1
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]vlan bat 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]p l t
[Huawei-Ethernet0/0/1]p t a v a
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l t
[Huawei-Ethernet0/0/2]p t a v a
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/22
[Huawei-Ethernet0/0/22]p l t
[Huawei-Ethernet0/0/22]p t a v a
[Huawei-Ethernet0/0/22]q
[Huawei]stp mode mstp
[Huawei]stp region-configuration
[Huawei-mst-region]region-name huawei
[Huawei-mst-region]revision-level 1
[Huawei-mst-region]instance 1 vlan 10 20
[Huawei-mst-region]instance 2 vlan 30 40
[Huawei-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei-mst-region]q
[Huawei]stp instance 1 root primary
[Huawei]stp instance 2 root secondary
[Huawei]q

LSW2
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]vlan bat 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]p l t
[Huawei-Ethernet0/0/1]p t a v a
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l t
[Huawei-Ethernet0/0/2]p t a v a
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/22
[Huawei-Ethernet0/0/22]p l t
[Huawei-Ethernet0/0/22]p t a v a
[Huawei-Ethernet0/0/22]q
[Huawei]stp mode mstp
[Huawei]stp region-configuration
[Huawei-mst-region]region-name huawei
[Huawei-mst-region]revision-level 1
[Huawei-mst-region]instance 1 vlan 10 20
[Huawei-mst-region]instance 2 vlan 30 40
[Huawei-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei-mst-region]q
[Huawei]stp instance 2 root primary
[Huawei]stp instance 1 root secondary
[Huawei]q

SW3

u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]vlan bat 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]p l a
[Huawei-Ethernet0/0/1]p d v 10
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l a
[Huawei-Ethernet0/0/2]p d v 20
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/4
[Huawei-Ethernet0/0/4]p l t
[Huawei-Ethernet0/0/4]p t a v a
[Huawei-Ethernet0/0/4]q
[Huawei]stp mode mstp
[Huawei]stp region-configuration
[Huawei-mst-region]region-name huawei
[Huawei-mst-region]revision-level 1
[Huawei-mst-region]instance 1 vlan 10 20
[Huawei-mst-region]instance 2 vlan 30 40
[Huawei-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei-mst-region]q

LSW4

u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]user-interface console 0
[Huawei-ui-console0]idle-timeout 0 0
[Huawei-ui-console0]q
[Huawei]vlan bat 10 20 30 40
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]p l a
[Huawei-Ethernet0/0/1]p d v 30
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]p l a
[Huawei-Ethernet0/0/2]p d v 40
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/4
[Huawei-Ethernet0/0/4]p l t
[Huawei-Ethernet0/0/4]p t a v a
[Huawei-Ethernet0/0/4]q
[Huawei]stp mode mstp
[Huawei]stp region-configuration
[Huawei-mst-region]region-name huawei
[Huawei-mst-region]revision-level 1
[Huawei-mst-region]instance 1 vlan 10 20
[Huawei-mst-region]instance 2 vlan 30 40
[Huawei-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment…done.
[Huawei-mst-region]q