一、基础配置
1.新建拓扑图
2.配置vlan
a.CORE-S1
<Huawei>system-view
[Huawei]sysname CORE-S1
[CORE-S1]vlan 10
[CORE-S1-vlan10]vlan 20
[CORE-S1-vlan20]vlan 30
b.CORE-S2
<Huawei>system-view
[Huawei]sysname CORE-S2
[CORE-S2]vlan 10
[CORE-S2-vlan10]vlan 20
[CORE-S2-vlan20]vlan 30
c.S1
<Huawei>system-view
[Huawei]sysname S1
[S1]vlan 10
d.S2
<Huawei>system-view
[Huawei]sysname S2
[S2]vlan 20
e.S3
<Huawei>system-view
[Huawei]sysname S3
[S3]vlan 30
二、链路聚合配置
1.CORE-S1
[CORE-S1]interface Eth-Trunk 1
[CORE-S1-Eth-Trunk1]quit
[CORE-S1]interface GigabitEthernet 0/0/1
[CORE-S1-GigabitEthernet0/0/1]eth-trunk 1
[CORE-S1-GigabitEthernet0/0/1]quit
[CORE-S1]interface GigabitEthernet 0/0/2
[CORE-S1-GigabitEthernet0/0/2]eth-trunk 1
2.CORE-S2
[CORE-S2]interface Eth-Trunk 1
[CORE-S2-Eth-Trunk1]quit
[CORE-S2]interface GigabitEthernet 0/0/1
[CORE-S2-GigabitEthernet0/0/1]eth-trunk 1
[CORE-S2-GigabitEthernet0/0/1]quit
[CORE-S2]interface GigabitEthernet 0/0/2
[CORE-S2-GigabitEthernet0/0/2]eth-trunk 1
三、接口配置
1.CORE-S1
[CORE-S1]port-group group-member g0/0/3 to g0/0/5
[CORE-S1-port-group]port link-type trunk
[CORE-S1-port-group]port trunk allow-pass vlan all
[CORE-S1-port-group]quit
[CORE-S1]interface Eth-Trunk 1
[CORE-S1-Eth-Trunk1]port link-type trunk
[CORE-S1-Eth-Trunk1]port trunk allow-pass vlan all
2.CORE-S2
[CORE-S2]port-group group-member g0/0/3 to g0/0/5
[CORE-S2-port-group]port link-type trunk
[CORE-S2-port-group]port trunk allow-pass vlan all
[CORE-S2-port-group]quit
[CORE-S2]interface Eth-Trunk 1
[CORE-S2-Eth-Trunk1]port link-type trunk
[CORE-S2-Eth-Trunk1]port trunk allow-pass vlan all
3.S1
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S1-GigabitEthernet0/0/1]quit
[S1]interface GigabitEthernet 0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[S1-GigabitEthernet0/0/2]quit
[S1]interface GigabitEthernet 0/0/3
[S1-GigabitEthernet0/0/3]port link-type access
[S1-GigabitEthernet0/0/3]port default vlan 10
4.S2
[S2]interface GigabitEthernet 0/0/1
[S2-GigabitEthernet0/0/1]port link-type trunk
[S2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S2-GigabitEthernet0/0/1]quit
[S2]interface GigabitEthernet 0/0/2
[S2-GigabitEthernet0/0/2]port link-type trunk
[S2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[S2-GigabitEthernet0/0/2]quit
[S2]interface GigabitEthernet 0/0/3
[S2-GigabitEthernet0/0/3]port link-type access
[S2-GigabitEthernet0/0/3]port default vlan 20
5.S3
[S3]interface GigabitEthernet 0/0/1
[S3-GigabitEthernet0/0/1]port link-type trunk
[S3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[S3-GigabitEthernet0/0/1]quit
[S3]interface GigabitEthernet 0/0/2
[S3-GigabitEthernet0/0/2]port link-type trunk
[S3-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[S3-GigabitEthernet0/0/2]quit
[S3]interface GigabitEthernet 0/0/3
[S3-GigabitEthernet0/0/3]port link-type access
[S3-GigabitEthernet0/0/3]port default vlan 30
四、基本IP配置
1.CORE-S1
[CORE-S1]interface Vlanif 10
[CORE-S1-Vlanif10]ip address 192.168.10.254 24
[CORE-S1-Vlanif10]quit
[CORE-S1]interface Vlanif 20
[CORE-S1-Vlanif20]ip address 192.168.20.254 24
[CORE-S1-Vlanif20]quit
[CORE-S1]interface Vlanif 30
[CORE-S1-Vlanif30]ip address 192.168.30.254 24
2.CORE-S2
[CORE-S2]interface Vlanif 10
[CORE-S2-Vlanif10]ip address 192.168.10.253 24
[CORE-S2-Vlanif10]quit
[CORE-S2]interface Vlanif 20
[CORE-S2-Vlanif20]ip address 192.168.20.253 24
[CORE-S2-Vlanif20]quit
[CORE-S2]interface Vlanif 30
[CORE-S2-Vlanif30]ip address 192.168.30.253 24
3.PC端
a.PC1
b.PC2
c.PC3
五、VRRP主备配置
1.VRRP虚拟IP
a.CORE-S1
[CORE-S1]interface Vlanif 10
[CORE-S1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.252 //VLAN 接口 10 配置 VRRP虚拟 IP 地址为 192.168.10.252.
[CORE-S1-Vlanif10]quit
[CORE-S1]interface Vlanif 20
[CORE-S1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.252
[CORE-S1-Vlanif20]quit
[CORE-S1]interface Vlanif 30
[CORE-S1-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.252
b.CORE-S2
[CORE-S2]interface Vlanif 10
[CORE-S2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.252 //相同vlan的虚拟IP地址相同,配置后PC端将只能通过ping虚拟网关。
[CORE-S2-Vlanif10]quit
[CORE-S2]interface Vlanif 20
[CORE-S2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.252
[CORE-S2-Vlanif20]quit
[CORE-S2]interface Vlanif 30
[CORE-S2-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.252
3.ping通测试
以PC1为例:
PC端可以ping通虚拟IP网关。
2.VRRP优先级
设置CORE-S1为vlan10和vlan20的主设备,CORE-S2为vlan30的主设备。
a.CORE-S1
[CORE-S1]interface Vlanif 10
[CORE-S1-Vlanif10]vrrp vrid 10 priority 110 //VRRP的默认优先级是100,数字越大优先级越高。
[CORE-S1-Vlanif10]quit
[CORE-S1]interface Vlanif 20
[CORE-S1-Vlanif20]vrrp vrid 20 priority 110
b.CORE-S2
[CORE-S2]interface Vlanif 30
[CORE-S2-Vlanif30]vrrp vrid 30 priority 110
六、VRRP负载均衡配置
负载均衡的目的是让信息传递的路线达到以下效果:
1.生成树协议
a.STP生成树协议
[CORE-S1]display stp brief
此时的链路聚合组并没有启动,我们需要通过调整生成树的优先级将其启动。
[CORE-S1]stp priority 0 //优先级数字越小越优先
[CORE-S1]display stp brief
此时CORE-S2也随主设备的配置进行了改变,所以不用在CORE-S2上配置这条命令。
b.MSTP生成树协议
以CORE-S1为例:
[CORE-S1]stp region-configuration //进入 MST(多重生成树)配置模式,可以在此模式下定义区域的属性。
[CORE-S1-mst-region] region-name 1 //将 MST 区域的名称设置为“1”。
[CORE-S1-mst-region] revision-level 1 //将 MST 区域的修订级别设置为“1”。
[CORE-S1-mst-region] instance 1 vlan 10 20 //将 VLAN 10 和 VLAN 20 分配给 MST 实例 1。
[CORE-S1-mst-region] instance 2 vlan 30 40 //将 VLAN 30 和 VLAN 40 分配给 MST 实例 2。
[CORE-S1-mst-region] active region-configuration //激活当前的 MST 区域配置。
所有的交换机都需要配置以上命令。
所以交换机配置完成后,在CORE-S1上继续配置:
[CORE-S1]stp instance 1 priority 0
[CORE-S1]stp instance 2 priority 4096
CORE-S2上继续配置:
[CORE-S2]stp instance 1 priority 4096
[CORE-S2]stp instance 2 priority 0
配置完成后可以在S1,S2,S3上进行查看是否完成所需配置:
S1
S2
S3
七、VRRP的作用
1. 冗余备份
通过 VRRP,可以在网络中配置多个路由器作为冗余备份。如果主路由器(Master)发生故障,备份路由器(Backup)可以迅速接管其工作,保证网络通信不受影响。
2. 无缝切换
当主路由器故障时,VRRP 会自动将虚拟 IP 地址切换到备份路由器,客户端设备无感知地继续通信,不需要重新配置网关。
3. 负载均衡
在一些配置中,VRRP 也可以用来实现负载均衡,通过将流量分配到多个路由器上,优化网络性能。
4. 简单配置
VRRP 使得网络设备的配置更加简单,网络管理员只需设置虚拟路由器 ID 和虚拟 IP 地址,设备即可自动处理主备切换。