1.配置Switch
# 创建VLAN
<HUAWEI> system-view
[HUAWEI] sysname Switch
[Switch] vlan batch 10 20 30
# 配置接口加入VLAN
[Switch] interface gigabitethernet 0/0/1
[Switch-GigabitEthernet0/0/1] port link-type access
[Switch-GigabitEthernet0/0/1] port default vlan 10
[Switch-GigabitEthernet0/0/1] quit
[Switch] interface gigabitethernet 0/0/2
[Switch-GigabitEthernet0/0/2] port link-type access
[Switch-GigabitEthernet0/0/2] port default vlan 20
[Switch-GigabitEthernet0/0/2] quit
[Switch] interface gigabitethernet 0/0/3
[Switch-GigabitEthernet0/0/3] port link-type access
[Switch-GigabitEthernet0/0/3] port default vlan 30
[Switch-GigabitEthernet0/0/3] quit
# 配置VLANIF接口的IP地址
[Switch] interface vlanif 10
[Switch-Vlanif10] ip address 192.168.50.1 24
[Switch-Vlanif10] quit
[Switch] interface vlanif 20
[Switch-Vlanif20] ip address 192.168.60.1 24
[Switch-Vlanif20] quit
[Switch] interface vlanif 30
[Switch-Vlanif30] ip address 192.168.70.1 24
[Switch-Vlanif30] quit
2.检查配置结果
在VLAN10中的User1主机上配置IP地址为192.168.50.2/24,缺省网关为VLANIF10接口的IP地址192.168.50.1/24。
在VLAN20中的User2主机上配置IP地址为192.168.60.2/24,缺省网关为VLANIF20接口的IP地址192.168.60.1/24。
在VLAN30中的User3主机上配置IP地址为192.168.70.2/24,缺省网关为VLANIF20接口的IP地址192.168.70.1/24。
配置完成后,VLAN10内的User1与VLAN20内的User2和VLAN30内的User3能够相互访问。
技术改变世界! --狂诗绝剑