在划分VLAN的网络中运行RSTP/STP。局域网内的所有VLAN共享一棵生成树,被阻塞后的链路将不再承载任何流量。无法在VLAN间实现数据流量的负载均衡;导致带宽利用率、设备资源利用率较低
两种方式:手工模式和LACP模式
所有链路都会参与流量转发,设备不支持主备,不支持链路备份,不能检测到端口是否连接错误,不支持跨设备
支持主备,支持链路备份,可以检测到端口连接错误,支持跨设备
为了使链路聚合接口正常工作,必须保证本端链路聚合接口中所有成员接口的对端接口:
在数据转发过程中实现对VLAN负载均衡。
MSTP将一个或多个VLAN映射到一个instance(实例),再基于instance计算生成树,映射到同一个instance的VLAN共享同一棵生成树
例:如图中例子,最终生成两棵生成树
instance1对应的生成树以SW1为根交换设备,转发VLAN1-VLAN10的报文
instance2对应的生成树以SW2为根交换设备,转发VLAN11-VLAN20的报文
不同的VLAN报文沿着不同的路径转发,实现了负载分担。
PS:生成树不是基于VLAN运行的,而是基于instance运行的
为了保证企业网络稳定性,仅进行设备备份是不够的,需要针对链路进行备份。避免出现链路故障导致网路无法正常通信。
以太网链路聚合Eth-Trunk:简称链路聚合,通过物理接口捆绑成一个逻辑接口,在不进行硬件升级的情况下,达到增加链路带宽的目的
LACPDU报文中包含设备优先级、MAC地址、接口优先级、接口号等
VRRP可监视(通过Track配置)上行端口状态,当设备感知到上行端口或者链路发生故障时,可主动减低VRPP优先级,从而保证上行链路正常的Backup设备通过选举切换为Master状态。指导报文转发。
[sw3]vlan batch 2 to 5
[sw3]int g0/0/3
[sw3-GigabitEthernet0/0/3]port link-type access
[sw3-GigabitEthernet0/0/3]port default vlan 2
[sw3]int g0/0/4
[sw3-GigabitEthernet0/0/4]port link-type access
[sw3-GigabitEthernet0/0/4]port default vlan 3
[sw3]port-group group-member g0/0/1 g0/0/2
[sw3-port-group]port link-type trunk
[sw3-GigabitEthernet0/0/1]port link-type trunk
[sw3-GigabitEthernet0/0/2]port link-type trunk
[sw3-port-group]port trunk allow-pass vlan 2
[sw3-port-group]port trunk allow-pass vlan 2 to 5
[sw3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 5
[sw3-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 5
[sw3-port-group]undo port trunk allow-pass vlan 1
[sw3-GigabitEthernet0/0/1]undo port trunk allow-pass vlan 1
[sw3-GigabitEthernet0/0/2]undo port trunk allow-pass vlan 1
[sw4]int g0/0/3
[sw4-GigabitEthernet0/0/3]port link-type access
[sw4-GigabitEthernet0/0/3]port default vlan 4
[sw4]int g0/0/4
[sw4-GigabitEthernet0/0/4]port link-type a
[sw4-GigabitEthernet0/0/4]port link-type access
[sw4-GigabitEthernet0/0/4]port default vlan 5
[sw4]port-group group-member g0/0/1 g0/0/2
[sw4-port-group] port link-type trunk
[sw4-GigabitEthernet0/0/1] port link-type trunk
[sw4-GigabitEthernet0/0/2] port link-type trunk
[sw4-port-group] undo port trunk allow-pass vlan 1
[sw4-GigabitEthernet0/0/1] undo port trunk allow-pass vlan 1
[sw4-GigabitEthernet0/0/2] undo port trunk allow-pass vlan 1
[sw4-port-group] port trunk allow-pass vlan 2 to 5
[sw4-GigabitEthernet0/0/1] port trunk allow-pass vlan 2 to 5
[sw4-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 5
[sw3]port-group group-member g0/0/3 g0/0/4
[sw3-port-group]stp edged-port enable---将接口划入边缘接口
[sw3-GigabitEthernet0/0/3]stp edged-port enable
[sw3-GigabitEthernet0/0/4]stp edged-port enable
[sw3]stp bpdu-protection---开启BPDU保护
[sw4]port-group group-member g0/0/3 g0/0/4
[sw4-port-group]stp edged-port enable
[sw4-GigabitEthernet0/0/3]stp edged-port enable
[sw4-GigabitEthernet0/0/4]stp edged-port enable
[sw4]stp bpdu-protection
[sw1]vlan batch 2 to 5
[sw1]port-group group-member g0/0/4 g0/0/5
[sw1-port-group]port link-type trunk
[sw1-GigabitEthernet0/0/4]port link-type trunk
[sw1-GigabitEthernet0/0/5]port link-type trunk
[sw1-port-group] undo port trunk allow-pass vlan 1
[sw1-GigabitEthernet0/0/4] undo port trunk allow-pass vlan 1
[sw1-GigabitEthernet0/0/5] undo port trunk allow-pass vlan 1
[sw1-port-group] port trunk allow-pass vlan 2 to 5
[sw1-GigabitEthernet0/0/4] port trunk allow-pass vlan 2 to 5
[sw1-GigabitEthernet0/0/5] port trunk allow-pass vlan 2 to 5
[sw2]vlan batch 2 to 5
[sw2]port-group group-member g0/0/4 g0/0/5
[sw2-port-group]port link-type trunk
[sw2-GigabitEthernet0/0/4]port link-type trunk
[sw2-GigabitEthernet0/0/5]port link-type trunk
[sw2-port-group] undo port trunk allow-pass vlan 1
[sw2-GigabitEthernet0/0/4] undo port trunk allow-pass vlan 1
[sw2-GigabitEthernet0/0/5] undo port trunk allow-pass vlan 1
[sw2-port-group] port trunk allow-pass vlan 2 to 5
[sw2-GigabitEthernet0/0/4] port trunk allow-pass vlan 2 to 5
[sw2-GigabitEthernet0/0/5] port trunk allow-pass vlan 2 to 5
[sw1]dhcp enable
[sw1]int vlan 2
[sw1-Vlanif3]ip add 10.1.2.1 24
[sw1-Vlanif3]dhcp select interface
[sw1]int vlan 3
[sw1-Vlanif3]ip add 10.1.3.1 24
[sw1-Vlanif3]dhcp select interface
[sw2]dhcp enable
[sw2]int vlan 4
[sw2-Vlanif4]ip add 10.1.4.1 24
[sw2-Vlanif4]dhcp select interface
[sw2]int vlan 5
[sw2-Vlanif5]ip add 10.1.5.1 24
[sw2-Vlanif5]dhcp select interface
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]stp edged-port enable
[sw1]stp bpdu-protection
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]stp edged-port enable
[sw2]stp bpdu-protection
[sw1]int Eth-Trunk 1
[sw1-Eth-Trunk1]trunkport g0/0/2
[sw1-Eth-Trunk1]trunkport g0/0/3
[sw1-Eth-Trunk1] port link-type trunk
[sw1-Eth-Trunk1] port trunk allow-pass vlan 2 to 5---因为默认流量在VLAN1上流通,所以此处需要放通VLAN1的流量
[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]trunkport g0/0/2
[sw2-Eth-Trunk1]trunkport g0/0/3
[sw2-Eth-Trunk1] port link-type trunk
[sw2-Eth-Trunk1] port trunk allow-pass vlan 2 to 5
[sw1]stp mode mstp
[sw1]stp region-configuration
[sw1-mst-region] region-name HW
[sw1-mst-region] revision-level 1
[sw1-mst-region] instance 1 vlan 2 to 3
[sw1-mst-region] instance 2 vlan 4 to 5
[sw1-mst-region] active region-configuration
[sw2]stp mode mstp
[sw2]stp region-configuration
[sw2-mst-region] region-name HW
[sw2-mst-region] revision-level 1
[sw2-mst-region] instance 1 vlan 2 to 3
[sw2-mst-region] instance 2 vlan 4 to 5
[sw2-mst-region] active region-configuration
[sw3]stp mode mstp
[sw3]stp region-configuration
[sw3-mst-region] region-name HW
[sw3-mst-region] revision-level 1
[sw3-mst-region] instance 1 vlan 2 to 3
[sw3-mst-region] instance 2 vlan 4 to 5
[sw3-mst-region] active region-configuration
[sw4]stp mode mstp
[sw4]stp region-configuration
[sw4-mst-region] region-name HW
[sw4-mst-region] revision-level 1
[sw4-mst-region] instance 1 vlan 2 to 3
[sw4-mst-region] instance 2 vlan 4 to 5
[sw4-mst-region] active region-configuration
[sw1]stp instance 1 root primary
[sw1]stp instance 0 root primary
[sw1]stp instance 2 root secondary
[sw2]stp instance 1 root secondary
[sw2]stp instance 0 root secondary
[sw2]stp instance 2 root primary
[sw1]port-group group-member g0/0/4 g0/0/5
[sw1-port-group]stp root-protection
[sw1-GigabitEthernet0/0/4]stp root-protection
[sw1-GigabitEthernet0/0/5]stp root-protection
[sw1]int vlan 2
[sw1-Vlanif2]ip add 10.1.2.3 24
[sw1-Vlanif2]dhcp select interface
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 10.1.2.1---不修改本地VLANIF的IP地址,将不进行Master选举,直接成为Master
[sw1-Vlanif2]vrrp vrid 1 priority 120---优先级越大越优
[sw2]int vlan 2
[sw2-Vlanif2]ip add 10.1.2.2 24
[sw2-Vlanif2]dhcp select interface
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 10.1.2.1
[sw2-Vlanif2]vrrp vrid 1 priority 100
[sw1]int vlan 4
[sw1-Vlanif4]ip add 10.1.4.2 24
[sw1-Vlanif4]dhcp select interface
[sw1-Vlanif4]vrrp vrid 2 virtual-ip 10.1.4.1
[sw1-Vlanif4]vrrp vrid 2 priority 100
[sw2]int vlan 4
[sw2-Vlanif4]ip add 10.1.4.3 24
[sw2-Vlanif2]dhcp select interface
[sw2-Vlanif4]vrrp vrid 2 virtual-ip 10.1.4.1
[sw2-Vlanif4]vrrp vrid 2 priority 120
[sw1]int vlan 2
[sw1-Vlanif2]vrrp vrid 1 track interface g0/0/1 reduced 30
[sw2]int vlan 4
[sw2-Vlanif4]vrrp vrid 2 track interface g0/0/1 reduced 30
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 200
[sw1]int vlan 200
[sw1-Vlanif200]ip add 12.1.1.2 24
[sw1]int vlan 150
[sw1-Vlanif150]ip add 23.1.1.1 24
[sw2]int vlan 150
[sw2-Vlanif150]ip add 23.1.1.2 24
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 100
[sw2]int vlan 100
[sw2-Vlanif100]ip add 13.1.1.2 24
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 13.1.1.1 24
[r1]int g0/0/2
[r1-GigabitEthernet0/0/2]ip add 14.1.1.1 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 14.1.1.2 24
[r2]int lo0
[r2-LoopBack0]ip add 4.4.4.4 24
[sw2]ospf 1 router-id 3.3.3.3
[sw2-ospf-1]a 0
[sw2-ospf-1-area-0.0.0.0]network 13.1.1.2 0.0.0.0
[sw2-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0
[sw2-ospf-1]a 1
[sw2-ospf-1-area-0.0.0.1]network 10.1.2.0 0.0.0.255
[sw2-ospf-1-area-0.0.0.1]network 10.1.4.0 0.0.0.255
[sw2-ospf-1]silent-interface Vlanif 2---沉默接口,让其停止发送hello包
[sw2-ospf-1]silent-interface Vlanif 4
[sw1]ospf 1 router-id 2.2.2.2
[sw1-ospf-1]a 0
[sw1-ospf-1-area-0.0.0.0]network 12.1.1.2 0.0.0.0
[sw1-ospf-1-area-0.0.0.0]network 23.1.1.1 0.0.0.0
[sw1-ospf-1]a 1
[sw1-ospf-1-area-0.0.0.1]network 10.1.4.0 0.0.0.255
[sw1-ospf-1-area-0.0.0.1]network 10.1.2.0 0.0.0.255
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]a 0
[r1-ospf-1-area-0.0.0.0]network 12.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 13.1.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 14.1.1.1 0.0.0.0
[r1-ospf-1]silent-interface g0/0/2
[sw1-ospf-1]int vlan 200
[sw1-Vlanif200]ospf network-type p2p
[sw1-ospf-1]int vlan 150
[sw1-Vlanif150]ospf network-type p2p
[sw2-ospf-1]int vlan 100
[sw2-Vlanif100]ospf network-type p2p
[sw2-ospf-1]int vlan 150
[sw2-Vlanif150]ospf network-type p2p
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ospf network-type p2p
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ospf network-type p2p
[sw1]int vlan 2
[sw1-Vlanif2]vrrp vrid 1 virtual-ip 10.1.2.1---不修改本地VLANIF的IP地址,将不进行Master选举,直接成为Master
[sw1-Vlanif2]vrrp vrid 1 priority 120---优先级越大越优
[sw2]int vlan 2
[sw2-Vlanif2]ip add 10.1.2.2 24
[sw2-Vlanif2]vrrp vrid 1 virtual-ip 10.1.2.1
[sw2-Vlanif2]vrrp vrid 1 priority 100
[sw1]int vlan 4
[sw1-Vlanif4]ip add 10.1.4.2 24
[sw1-Vlanif4]vrrp vrid 2 virtual-ip 10.1.4.1
[sw1-Vlanif4]vrrp vrid 2 priority 100
[sw2]int vlan 4
[sw2-Vlanif4]vrrp vrid 2 virtual-ip 10.1.4.1
[sw2-Vlanif4]vrrp vrid 2 priority 120
[r2]ospf 1 router-id 4.4.4.4
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]network 14.1.1.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0