配置trunk和access
拓扑图
![](https://img2020.cnblogs.com/blog/2098254/202101/2098254-20210120111223648-1473346222.png)
PC地址设置
PC1 :192.168.1.1 vlan10
PC2 :192.168.1.2 vlan10
交换机配置
- LSW3配置
<Huawei>system-view
[Huawei]vlan 10
[Huawei]interface Ethernet 0/0/1
[Huawei-Ethernet0/0/1]port link-type access
[Huawei-Ethernet0/0/1]port default vlan 10
[Huawei-Ethernet0/0/1]quit
[Huawei]interface Ethernet 0/0/2
[Huawei-Ethernet0/0/2]port link-type trunk
[Huawei-Ethernet0/0/2]port trunk allow-pass vlan 10
[Huawei-Ethernet0/0/2]quit
- LSW4配置
<Huawei>system-view
[Huawei]vlan 10
[Huawei]interface Eth 0/0/1
[Huawei-Ethernet0/0/1]port link-type trunk
[Huawei-Ethernet0/0/1]port trunk allow-pass vlan 10
[Huawei-Ethernet0/0/1]quit
[Huawei]interface Eth 0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 10
[Huawei-Ethernet0/0/2]quit
测试
PC>ping 192.168.1.2
Ping 192.168.1.2: 32 data bytes, Press Ctrl_C to break
From 192.168.1.2: bytes=32 seq=1 ttl=128 time=63 ms
From 192.168.1.2: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.1.2: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.1.2: bytes=32 seq=4 ttl=128 time=78 ms
From 192.168.1.2: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/62/78 ms