使用access接口
拓扑图:
LSW1:
<Huawei>system-view //进入系统视图
[Huawei]sysname LSW1 //修改设备名称
[LSW1]vlan batch 10 20 //创建VLAN10 20
[LSW1]int g0/0/2 //进入端口
[LSW1-GigabitEthernet0/0/2]port link-type access //设置access接口
[LSW1-GigabitEthernet0/0/2]port default vlan 10 //设置默认vlan为10
[LSW1-GigabitEthernet0/0/2]dis this //查看当前的配置
#
interface GigabitEthernet0/0/2
port link-type access
port default vlan 10
#
return
[LSW1-GigabitEthernet0/0/2]
[LSW1]int g0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type access
[LSW1-GigabitEthernet0/0/3]port default vlan 20
[LSW1-GigabitEthernet0/0/3]dis vlan //查看vlan
[LSW1-GigabitEthernet0/0/3]quit
<LSW1>save //保存
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y //Y
Now saving the current configuration to the slot 0.
May 27 2022 15:14:07-08:00 LSW1 %%01CFM/4/SAVE(l)[1]:The user chose Y when decid
ing whether to save the configuration to the device.
Save the configuration successfully.
[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 //允许vlan10通过
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 //允许vlan20通过
<LSW1>save
LSW2:
<Huawei>system-view //进入系统视图
[Huawei]sysname LSW2 //修改设备名称
[LSW2]vlan batch 10 20 //创建VLAN10 20
[LSW2]int g0/