一、进入系统视图及基本配置
1.进入系统视图
命令:system-view
示例:
System View: return to User View with Ctrl+Z.
[Huawei]
2.交换机命名
命令:[Huawei]sysname [交换机名]
示例:[Huawei]sysname SwitchA
3.查看当前配置
命令:[SwitchA]display current-configuration
示例:
[SwitchA]display current-configuration
#
sysname SwitchA
#
二、VLAN配置
1.创建VLAN
命令:[SwitchA]vlan [VLAN号]
示例:[SwitchA]vlan 10
2.删除VLAN
命令:[SwitchA]undo vlan [VLAN号]
示例:[SwitchA]undo vlan 10
3.将端口加入VLAN
命令:[SwitchA-vlan10]port ethernet [端口号]
示例:[SwitchA-vlan10]port ethernet 0/1 to ethernet 0/4
4.配置VLAN的IP地址
命令:[SwitchA-Vlan-interface10]ip address [IP地址] [子网掩码]
示例:[SwitchA-Vlan-interface10]ip address 192.168.1.1 255.255.255.0
三、端口配置
1.进入接口视图
命令:[SwitchA]interface ethernet [端口号]
示例:[SwitchA]interface ethernet 0/1
2.配置端口工作速率
命令:[SwitchA-Ethernet0/1]speed {10|100|auto}
示例:[SwitchA-Ethernet0/1]speed 100
3.配置端口工作状态
命令:[SwitchA-Ethernet0/1]duplex {half|full|auto}
示例:[SwitchA-Ethernet0/1]duplex full
4.设置端口工作模式
命令:[SwitchA-Ethernet0/1]port link-type {trunk|access|hybrid}
示例:
配置为Access端口:[SwitchA-Ethernet0/1]port link-type access
配置为Trunk端口:[SwitchA-Ethernet0/1]port link-type trunk
配置为Hybrid端口:[SwitchA-Ethernet0/1]port link-type hybrid
5.为Access端口分配VLAN
命令:[SwitchA-Ethernet0/1]port default vlan [VLAN号]
示例:[SwitchA-Ethernet0/1]port default vlan 10
6.允许Trunk端口通过的VLAN
命令:[SwitchA-Ethernet0/1]port trunk allow-pass vlan [VLAN范围]
示例:
允许VLAN 10, 20, 30通过:[SwitchA-Ethernet0/1]port trunk allow-pass vlan 10 20 30
或允许所有VLAN通过:[SwitchA-Ethernet0/1]port trunk allow-pass vlan all
四、STP(生成树协议)配置
1.启用STP
命令:[SwitchA]stp enable
2.配置STP模式
命令:[SwitchA]stp mode [模式](如RSTP, MSTP)
示例:[SwitchA]stp mode rstp
3.配置MSTP实例
命令:[SwitchA]stp region-configuration
[SwitchA-mst-region]region-name [区域名]
[SwitchA-mst-region]instance [实例号] vlan [VLAN范围]
[SwitchA-mst-region]quit
示例:
[SwitchA]stp region-configuration
[SwitchA-mst-region]region-name MST_REGION
[SwitchA-mst-region]instance 1 vlan 10 20
[SwitchA-mst-region]instance 2 vlan 30 40
[SwitchA-mst-region]quit
五、保存配置
保存当前配置
命令:[SwitchA]save
示例:
[SwitchA]save
The current configuration will be written to the device.
Are you sure? [Y/N]:y
Now saving the current configuration to the slot 0...
Save the configuration successfully.
六、其他常用命令
1.重启交换机
命令:[SwitchA]reboot
2.查看版本信息
命令:[SwitchA]display version
3.查看MAC地址表
命令:[SwitchA]display mac-address-table
本文提供了华为交换机的基本配置、VLAN配置、端口配置、STP配置、保存配置以及其他常用命令的详细说明和示例。在实际操作中,请根据具体需求和网络环境进行配置。