网络拓扑图:
SW2配置命令:将服务器划分至相应的vlan
<huawei>system-view #进入系统视图 [huawei]sysname SW2 #命名为SW2 [SW2]vlan batch 10 20 #创建vlan 10 20 [SW2]interface GigabitEthernet 0/0/2 #进入G0/0/2 [SW2-GigabitEthernet0/0/2]port link-type access #配置接口类型 [SW2-GigabitEthernet0/0/2]port default vlan 10 #划分至vlan 10 [SW2-GigabitEthernet0/0/2]inter gig0/0/3 #进入G0/0/3 [SW2-GigabitEthernet0/0/3]port link-type access #配置接口类型 [SW2-GigabitEthernet0/0/3]port default vlan 20 #划分至vlan 20 [SW2-GigabitEthernet0/0/3]inter gig0/0/1 #进入G0/0/1 [SW2-GigabitEthernet0/0/1]port link-type trunk #配置trunk [SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 #允许vlan 10 20数据通过
SW1配置:
<Huawei>system-view #进入系统视图 [Huawei]sysname SW1 #命名为SW1 [SW1]vlan batch 10 20 #创建vlan 10 20 [SW1]interface GigabitEthernet 0/0/1 #进入G0/0/1 [SW1-GigabitEthernet0/0/1]port link-type trunk #配置trunk [SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 #允许vlan 10 20数据包通过 [SW1-GigabitEthernet0/0/1]inter gig0/0/2 #进入G0/0/2 [SW1-GigabitEthernet0/0/2]port hybrid untagged vlan 10 20 #配置混合端口 [SW1-GigabitEthernet0/0/2]ip-subnet-vlan enable #开启基于IP子网划分 [SW1-GigabitEthernet0/0/2]quit #退出 [SW1]vlan 10 #进入vlan 10 [SW1-vlan10]ip-subnet-vlan ip 10.10.10.0 24 #10.10.10.0网段划分至vlan10 [SW1-vlan10]vlan 20 #进入vlan 20 [SW1-vlan20]ip-subnet-vlan ip 10.10.20.0 24 #10.10.20.0网段划分至vlan 20 [SW1-vlan20]ip-subnet-vlan ip 1.1.1.0 24 #1.1.1.0网段划分至vlan 20
查看IP网段:display ip-subnet-vlan vlan all