SW1:
<Huawei>system-view
[Huawei]sysname SW1
[SW1]VLAN batch 10 20 //批量划分vlan
[SW1]interface GigabitEthernet0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access //设置为access口,access口允许单个vlan通过
[SW1-GigabitEthernet0/0/1]port default vlan 10
[SW1-GigabitEthernet0/0/1]int g0/0/3[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 20
[SW1-GigabitEthernet0/0/3]quit
[SW1-GigabitEthernet0/0/2]port link-type trunk //设置为trunk口,trunk口允许多个vlan通过
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20 //trunk口允许vlan 10 20通过
SW2:
<Huawei>system-view
[Huawei]sysname SW2
[SW2]vlan batch 10 20
[SW2]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 10
[SW2-GigabitEthernet0/0/2]int g0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 20
[SW2-GigabitEthernet0/0/3]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
结果: