10、中小企业网络架构-扩展配置MSTP、VRRP负载分担

网络拓扑:

ISP:100.1.1.5

vlan2虚拟网关IP:192.168.2.254

vlan3虚拟网关IP:192.168.3.254

SW1:

Vlanif2:192.168.2.252

Vlanif3:192.168.3.252

SW2:

Vlanif2:192.168.3.253

Vlanif3:192.168.3.253

配置思路:

VRRP的作用是充当网关的默认网关的,可以说PC定义的默认网关不生效的话,则整个网络都访问不了,只能访问同一个VLAN内的,如果在没有部署VRRP之前,两台设备有2个IP地址,都可以充当PC的网关,而PC又没有任何的检测机制,来判断该网关是否出现了故障,而进行切换,所以如果没有VRRP之前,则只能通过人为修改,这个工作量肯定是巨大的,特别是中大型网络,而且非常不实际,不可能指望一个不懂技术的人去设置网关地址。 VRRP解决的问题就是,通过VRRP技术协商,虚拟一个IP地址出来(VRRP可以直接使用接口定义了的地址的),这样的好处是,下面PC只需要定义VRRP定义的那个地址作为网关即可,当主设备出现故障后,会自动切换到备用上面,从而对客户来说是透明的。
为什么需要负载分担:因为默认情况下,所有的数据包都是交给主处理的,只有当主出现故障的时候,备用才会处理数据报文,如果所有的主都定义在一台设备上面的话,就意味着所有的数据包默认情况下都是由该设备处理,而备用则被闲置了,浪费了资源不说,很可能导致主设备处理能力跟不上,导致网络延迟很大,所以我们需要规划的是,把下面网段的网关平均分配到两台设备上面,比如192.168.2.0/24网段定义A为主,B为备用,而192.168.3.0/24网段定义B为主,A为备用,这样实现负载分担,达到资源利用。

VRRP与MSTP配合:我们之前分析过MSTP是保证链路的有效分担利用的,可以把VLAN的流量分摊到不同链路上去,然后在上行设备上面定义不同实例的根,定义根的作用是,对应的实例内的VLAN会把流量引向根的方向,而根也分为主根与备份根,这个跟VRRP的主备相似,所以我们在定义VRRP与MSTP的时候,要保持主备统一,比如VLAN 2的根在A设备上面,那么对应的网关 VRRP,则A为主,B为备用,而VLAN 3的根在B设备上面,那么对应的网关VRRP,则B为主,A为备用。这样的话到达路劲最优,资源利用最大化,如果MSTP与VRRP的定义相反,那么就会造成,路径次优了,比如VLAN 3定义根是B设备,而对应的网关VRRP则为A,那么它们首先会把流量引向B设备,然后再由B设备交给A,这样中间转发又延迟了,也增加了设备的处理负担。

操作步骤:

一、VRRP负载分担

为减轻Switch1上数据流量的承载压力,vlan2以Switch1为默认网关接入Internet,Switch2作为备份网关;vlan3以Switch2为默认网关接入Internet,Switch1作为备份网关,以实现流量的负载均衡

1、配置SW1

[SW1]interface  Vlanif  2
[SW1-Vlanif2]vrrp vrid 2 virtual-ip 192.168.2.254    #虚拟网关
[SW1-Vlanif2]vrrp vrid 2 priority 105    #优先级105,默认100
[SW1-Vlanif2]vrrp vrid 2 preempt-mode  timer delay 5    #抢占延时为5秒
[SW1-Vlanif2]vrrp vrid 2 track interface GigabitEthernet 0/0/1 reduced 10    #检测上联接口,故障自动减少优先级10
[SW1-Vlanif2]quit

[SW1]interface  Vlanif  3
[SW1-Vlanif3]vrrp vrid 3 virtual-ip 192.168.3.254
[SW1-Vlanif3]quit

2、配置SW2

[SW2]interface  Vlanif  2
[SW2-Vlanif2]vrrp vrid  2 virtual-ip 192.168.2.254
[SW2-Vlanif2]quit

[SW2]interface  Vlanif  3
[SW2-Vlanif3]vrrp vrid 3 virtual-ip 192.168.3.254	
[SW2-Vlanif3]vrrp vrid 3 priority 105
[SW2-Vlanif3]vrrp vrid 3 preempt-mode timer delay 5
[SW2-Vlanif3]vrrp vrid 3 track interface  GigabitEthernet  0/0/1 reduced 10
[SW2-Vlanif3]quit

3、修改DHCP

[SW1]ip pool pool2
[SW1-ip-pool-pool2]undo  gateway-list 192.168.2.252    #如果前面文章没有配置可以不删
[SW1-ip-pool-pool2]undo  excluded-ip-address 192.168.2.254    #如果前面文章没有配置可以不删
[SW1-ip-pool-pool2]gateway-list 192.168.2.254
[SW1-ip-pool-pool2]quit

[SW1]ip pool pool3
[SW1-ip-pool-pool3]undo gateway-list 192.168.3.252
[SW1-ip-pool-pool3]undo excluded-ip-address 192.168.3.254
[SW1-ip-pool-pool3]gateway-list 192.168.3.254
[SW1-ip-pool-pool3]quit

4、验证

跟踪路由发现vlan2走Switch1,符合预期规划线路

跟踪路由发现vlan3还是走Switch1,不符合预期规划线路,所以需要加上MSTP

5、留意一下STP端口状态(可选)

二、MSTP配置

STP可以有三种,一种为最先的STP、后续增强的RSTP,以及目前主流的MSTP,不使用STP与RSTP的原因其实很简单,因为它只能做到单一链路传输,而不能实现跟MSTP以实例的方式实现负载负担

1、配置SW1

进入了MSTP的配置域,定义了一个名字为huawei.com(这个同一个MSTP域必须保持一致),然后定义了2个实例,最终激活配置。

[SW1]stp region-configuration
[SW1-mst-region]region-name huawei.com
[SW1-mst-region]instance 1 vlan 2	
[SW1-mst-region]instance 2 vlan 3
[SW1-mst-region]active region-configuration
[SW1-mst-region]quit
	
[SW1]stp instance 1 root primary
[SW1]stp instance 2 root secondary 

2、配置SW2

[SW2]stp region-configuration 
[SW2-mst-region]region-name huawei.com
[SW2-mst-region]instance 1 vlan 2
[SW2-mst-region]instance 2 vlan 3
[SW2-mst-region]active region-configuration
[SW2-mst-region]quit 

[SW2]stp instance 1 root secondary
[SW2]stp instance 2 root  primary

3、配置SW3

[SW3]stp region-configuration
[SW3-mst-region]region-name huawei.com
[SW3-mst-region]instance 1 vlan 2	
[SW3-mst-region]instance 2 vlan 3
[SW3-mst-region]active region-configuration
[SW3-mst-region]quit

4、配置SW4

[SW4]stp region-configuration
[SW4-mst-region]region-name huawei.com
[SW4-mst-region]instance 1 vlan 2	
[SW4-mst-region]instance 2 vlan 3
[SW4-mst-region]active  region-configuration
[SW4-mst-region]quit

三、DHCP中继(可选,也可以在SW2增加DHCP服务器)

因为前面文章把DHCP配置在SW1,而现在vlan3的根桥是指向SW2,会导致无法获取IP,所以需要在SW2上配置DHCP中继。

1、创建DHCP服务器组

[SW2]dhcp server group dhcpgroup3
[SW2-dhcp-server-group-dhcpgroup3]dhcp-server  192.168.3.252
[SW2-dhcp-server-group-dhcpgroup3]quit

2、使能接口下DHCP中继功能,并绑定DHCP服务器组

[SW2]interface Vlanif 3
[SW2-Vlanif3]dhcp select relay
[SW2-Vlanif3]dhcp relay  server-select  dhcpgroup3
[SW2-Vlanif3]quit

3、抓包查看

如果只有DHCP Discover那就要查看配置是否正确

配置正确会有DHCP服务器回包

四、验证负载

1、vlan2

2、vlan3

五、故障演示

1、手动把SW1的上联接口G0/0/1 down,线路自动切换(PC1->SW2->FW1-ISP)

[SW1]interface  GigabitEthernet  0/0/1	
[SW1-GigabitEthernet0/0/1]shutdown
[SW1-GigabitEthernet0/0/1]quit

2、手动把SW1下联接口G0/0/2 down,发现路径次优(PC1->SW2->SW1-FW1-ISP)

[SW1]interface  GigabitEthernet  0/0/2
[SW1-GigabitEthernet0/0/1]shutdown
[SW1-GigabitEthernet0/0/1]quit

修改配置(SW1同时监测上下联接口状态,故障自动切换VRRP优先级)

[SW1]interface  Vlanif  2
[SW1-Vlanif2]vrrp vrid 2 track  interface  GigabitEthernet  0/0/2 reduced 10
[SW1-Vlanif2]quit

3、SW2的配置同理

[SW2]interface  Vlanif 3
[SW2-Vlanif3]vrrp vrid 3 track interface  GigabitEthernet  0/0/3 reduced 10
[SW2-Vlanif3]quit

[SW2]interface  GigabitEthernet  0/0/3
[SW2-GigabitEthernet0/0/3]shutdown
[SW2-GigabitEthernet0/0/3]quit

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章