企业网双核心交换机实现冗余和负载均衡(MSTP+VRRP)

发布于:2024-12-07 ⋅ 阅读:(28) ⋅ 点赞:(0)

MSTP(多生成树协议) 

通过创建多个VLAN实例,将原有的STP、RSTP升级,避免单一VLAN阻塞后导致带宽的浪费,通过将VLAN数据与实例绑定,有效提升网络速率。

VRRP(虚拟路由冗余协议)

用于提供冗余的网关功能,确保网络中的设备能够自动切换到备用网关,从而实现网络的高可用性。

如上图所示,为内网三层网络架构,最上层两台核心交换机实现负载均衡和冗余作用,保证网络的稳定和安全运行。

配置MSTP(VLAN 10 20主根桥在核心交换机1,VLAN 30 40主根桥在核心交换机2)

①所有交换机配置MSTP实例(instance,vlan 10 20 属于instance 1,vlan 30 40 属于instance 2),并激活配置

②核心交换机1配置instance 0,1 的主根桥,instance 2的次根桥(instance 0为默认实例,如vlan 1)

核心交换机2配置instance2 的主根桥,instance 0,1的次根桥(instance 0为默认实例,如vlan 1)

配置VRRP(核心交换机1为VLAN 10 20的主网关,核心交换机2为VLAN 30 40 的主网关)

①在核心交换机1和核心交换机2配置VLAN 10 、VLAN 20、VLAN 30、VLAN 40接口的虚拟网关地址为10.100.*.1

②在核心交换机1的VLAN 10 、VLAN 20、VLAN 30、VLAN 40接口配置地址为10.100.*.2,并配置在VLAN 10 和 VLAN 20 的优先级(priority )为120,即抢占为Master

②在核心交换机2的VLAN 10 、VLAN 20、VLAN 30、VLAN 40接口配置地址为10.100.*.3,并配置在VLAN 10 和 VLAN 20 的优先级(priority )为120,即即抢占为Master

一:核心交换机配置

核心交换机1配置:

sys
sys XIAN_CORE_SW_01
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99

配置地址池
ip pool 10
network 10.100.101.0 mask 24
gateway-list 10.100.101.1
dns-list 218.30.19.50 61.134.1.5
ip pool 20
network 10.100.102.0 mask 24
gateway-list 10.100.102.1
dns-list 218.30.19.50 61.134.1.5
ip pool 30
network 10.100.103.0 mask 24
gateway-list 10.100.103.1
dns-list 218.30.19.50 61.134.1.5
ip pool 40
network 10.100.104.0 mask 24
gateway-list 10.100.104.1
dns-list 218.30.19.50 61.134.1.5
port-group 1
group-member g0/0/1 to g0/0/5
p l t
p t a v a
q
配置MSTP(在核心交换机1上将VLAN 10、VLAN 20放在实例1里,将VLAN 30、VLAN 40放在实例2里)

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration 
q

配置实例的优先级
stp instance 0 root primary
stp instance 1 root primary
stp instance 2 root secondary

配置VRRP
interface vlanif 10
ip add 10.100.101.2 24
dhcp select global

配置网关的虚拟IP和优先级(VLAN 10和VLAN20网关在核心交换机1为Master,所以优先级高一些)
vrrp vrid 10 virtual-ip 10.100.101.1
vrrp vrid 10 priority 120
vrrp vrid 10 preempt-mode timer delay 20
interface vlanif 20
ip add 10.100.102.2 24
dhcp select global
vrrp vrid 20 virtual-ip 10.100.102.1
vrrp vrid 20 priority 120
vrrp vrid 20 preempt-mode timer delay 20
interface vlanif 30
ip add 10.100.103.2 24
dhcp select global
vrrp vrid 30 virtual-ip 10.100.103.1
interface vlanif 40
ip add 10.100.104.2 24
dhcp select global
vrrp vrid 40 virtual-ip 10.100.104.1
q

核心交换机2配置:

sys
sys XIAN_CORE_SW_02
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99

创建地址池:
ip pool 10
network 10.100.101.0 mask 24
gateway-list 10.100.101.1
dns-list 218.30.19.50 61.134.1.5
ip pool 20
network 10.100.102.0 mask 24
gateway-list 10.100.102.1
dns-list 218.30.19.50 61.134.1.5
ip pool 30
network 10.100.103.0 mask 24
gateway-list 10.100.103.1
dns-list 218.30.19.50 61.134.1.5
ip pool 40
network 10.100.104.0 mask 24
gateway-list 10.100.104.1
dns-list 218.30.19.50 61.134.1.5
port-group 1
group-member g0/0/1 to g0/0/5
p l t
p t a v a
q
配置MSTP(在核心交换机1上将VLAN 10、VLAN 20放在实例1里,将VLAN 30、VLAN 40放在实例2里)

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration 
q

配置实例的优先级
stp instance 0 root secondary
stp instance 1 root secondary
stp instance 2 root primary

配置VRRP
interface vlanif 10
ip add 10.100.101.3 24
dhcp select global
vrrp vrid 10 virtual-ip 10.100.101.1
interface vlanif 20
ip add 10.100.102.3 24
dhcp select global
vrrp vrid 20 virtual-ip 10.100.102.1
interface vlanif 30
ip add 10.100.103.3 24
dhcp select global

配置网关的虚拟IP和优先级(VLAN30和VLAN40的网关在核心交换机2为Master,所以优先级高一些)
vrrp vrid 30 virtual-ip 10.100.103.1
vrrp vrid 30 priority 120
vrrp vrid 30 preempt-mode timer delay 20
interface vlanif 40
ip add 10.100.104.3 24
dhcp select global
vrrp vrid 40 virtual-ip 10.100.104.1
vrrp vrid 40 priority 120
vrrp vrid 40 preempt-mode timer delay 20
q

配置汇聚交换机1:(接口配置+MSTP配置)

sys
sys XIAN_AGGREGATION_SW_01
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
port-group 1
group-member g0/0/1 g0/0/2 g0/0/23 g0/0/24
p l t
p t a v all
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration
q

配置汇聚交换机2:(接口配置+MSTP配置)

sys
sys XIAN_AGGREGATION_SW_02
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
port-group 1
group-member g0/0/1 g0/0/2 g0/0/23 g0/0/24
p l t
p t a v all
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

配置汇聚交换机3:(接口配置+MSTP配置)

sys
sys XIAN_AGGREGATION_SW_03
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
port-group 1
group-member g0/0/1 g0/0/2 g0/0/23 g0/0/24
p l t
p t a v all
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

配置汇聚交换机4:(接口配置+MSTP配置)

sys
sys XIAN_AGGREGATION_SW_04
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
port-group 1
group-member g0/0/1 g0/0/2 g0/0/23 g0/0/24
p l t
p t a v all
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机1:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_01
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 10
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机2:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_02
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 10
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机3:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_03
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 20
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机4:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_04
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 20
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机5:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_05
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 30
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机6:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_06
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 30
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机7:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_07
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 40
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

接入交换机8:(接口配置+MSTP配置)

sys
sys XIAN_ACCESS_SW_08
dhcp enable
stp enable
stp mode mstp
vlan batch 10 20 30 40 99
int g0/0/2
p l t
p t a v all
int e0/0/1
p l a
p d v 40
q

stp region-configuration
region-name RE_01
revision-level 1
instance 1 vlan 10 20
instance 2 vlan 30 40
active region-configuration

q

验证MSTP:(如拓扑图所示,红色圈标记的为在instance 1上阻塞的接口,绿色圈标记的为在instance 2阻塞的接口)

在核心交换机1上输入命令display stp brief

在instance 1 中,所有接口为DESI(指定端口),即核心交换机在instance 1 上为主根桥

在核心交换机2上输入命令display stp brief

在instance 2 中,所有接口为DESI(指定端口),即核心交换机在instance 2 上为主根桥

验证VRRP

在核心交换机1上输入命令display vrrp brief

vlanif 10 和vlanif 20接口的状态为Master

在核心交换机2上输入命令display vrrp brief

vlanif 30 和vlanif 40接口的状态为Master

终端PC上验证:ipconfig /renew

测试交换机的主备切换:

关闭核心交换机1:

查看核心交换机2的STP和VRRP状态

核心交换机2的instance 1 和 instance 2 都为主根桥(即所有接口都为DESI指定端口)

核心交换机2所有vlanif接口的VRRP状态都为Master

测试二:打开已经关闭的核心交换机1

查看核心交换机的STP状态

核心交换机1在instance 1 上又成为主根桥,核心交换机2在instance 2还是主根桥

查看核心交换机的VRRP状态

核心交换机1抢占到vlanif 10 和vlanif 20接口的状态为Master

核心交换机2的vlanif 30 和vlanif40接口的状态保持为Master

总结:

①MSTP不像STP和RSTP那样会直接将接口阻塞掉来防止环路,而是将包含VLAN的实例关联的接口进行阻塞,这样能最大化的利用所有线路的带宽,从而提升网络性能。

②配置VRRP中可以将多个网关平均分配给两台核心设备,这样既实现了负载均衡,又实现了链路冗余。