华为交换机VLAN及接口设置


system-view //进入全局配置模式

//设置端口类型
[Huawei] interface GigabitEthernet0/0/2  //进入端口2
[Huawei-GigabitEthernet0/0/2] port link-type access  //端口类型设置为access
[Huawei-GigabitEthernet0/0/2] quit
[Huawei] interface GigabitEthernet0/0/24  //进入端口24
[Huawei-GigabitEthernet0/0/24] port link-type trunk  //端口类型设置为trunk
[Huawei-GigabitEthernet0/0/24] quit

//创建端口组,批量设置端口类型
[Huawei] port-group 1  //创建端口组,组名为1
[Huawei-port-group-1] group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/5  //把端口1到5添加到端口组1中
[Huawei-port-group-1] port link-type access //将port-group-1组内的端口全部改为access口
[Huawei-port-group-1] display port-group1 //查看端口组1
[Huawei-port-group-1] quit

//查看vlan信息
[Huawei] display vlan //系统都会存在一个默认的vlan1,默认所有接口都在vlan1中

//创建和批量创建vlan
[Huawei] vlan 2 //创建vlan 2
[Huawei-vlan2] quit //退出系统配置模式
[Huawei] vlan batch 3 to 10 //批量创建vlan 3-10
[Huawei]display vlan //查看vlan信息

//为vlan配置IP地址和掩码
[Huawei] interface Vlanif 2 //进入配置vlan 2的模式
[Huawei-Vlanif2] ip address 192.168.0.2 255.255.255.0 //为vlan 2配置IP地址和掩码
[Huawei-Vlanif2] quit //退出系统配置模式

//删除和批量删除vlan(删除vlan--需要先删除vlanif信息--再删vlan)
[Huawei] undo vlan 2 //删除vlan 2
[Huawei] undo vlan batch 3 to 10 //批量删除vlan 3-10
[Huawei] display vlan //查看vlan信息
[Huawei] quit

//将端口或端口组加入到vlan中(删除时在相应命令前加undo)
[Huawei] interface GigabitEthernet0/0/2  //进入端口2
[Huawei-GigabitEthernet0/0/2] port default vlan 2   //将port2加入到我们创建好的vlan 2
[Huawei-GigabitEthernet0/0/2] display vlan   //查看配置的vlan信息
[Huawei-GigabitEthernet0/0/2] quit
[Huawei] port-group 1 //进入端口组1
[Huawei-port-group-1] port default vlan 2  //将port-group-1组内的端口全部加入到vlan 2
[Huawei-port-group-1]display vlan     //查看配置的vlan信息
[Huawei-port-group-1]quit

//绑定ip+mac+端口
[Huawei] ip source check user-bind enable //启用ip、mac检测功能
[Huawei] dis mac-address 448A-5BE2-5800 //查看mac地址所对应的端口 或者 dis arp | include 448A-5BE2-5800
[Huawei] user-bind static ip-address 192.168.2.2 mac-address 5489-9852-137A interface GigabitEthernet 0/0/2 //绑定ip+mac+端口

[Huawei] quit
save //保存所有配置