一、vlan的概念
VLAN(Virtual Local Area Network)即虚拟局域网,是将一个物理的局域网在逻辑上划分成多个广播域的技术。通过在交换机上配置VLAN,可以实现在同一个VLAN内的用户可以进行二层互访,而不同VLAN间的用户被二层隔离。这样既能够隔离广播域,又能够提升网络的安全性。
二、实验拓扑
三、实验配置
1、swa配置
system-view
[Huawei]sysname swa
更改交换机名字
[swa]vlan 3
[swa-vlan3]q
[swa]vlan 5
[swa-vlan5]q
创建vlan 3 和 5
[swa]interface Eth0/0/1 //进入端口
[swa-Ethernet0/0/1]port link-type access //端口设置为access
[swa-Ethernet0/0/1]port default vlan 3 //添加到vlan
[swa-Ethernet0/0/1]q //退出
[swa]interface Eth0/0/2
[swa-Ethernet0/0/2]port link-type access
[swa-Ethernet0/0/2]port default vlan 5
[swa-Ethernet0/0/2]q
以上两步是分别把端口添加到vlan中去,并设置为access,接下来就需要对Eth0/0/10 的端口进行trunk配置。在缺省的情况下只允许vlan 1 ,但是我们创建了vlan 3和vlan 5,所以需要把我们创建的两个vlan加进去
[swa]interface Eth0/0/10
[swa-Ethernet0/0/10]port link-type trunk
[swa-Ethernet0/0/10]port trunk allow-pass vlan 3 5
[swa-Ethernet0/0/10]q
2、对swb进行配置
system-view
[Huawei]sysname swb
[swb]vlan batch 3 5
[swb]interface Eth0/0/3
[swb-Ethernet0/0/3]port link-type access
[swb-Ethernet0/0/3]port default vlan 3
[swb-Ethernet0/0/3]q
[swb]interface Eth0/0/4
[swb-Ethernet0/0/4]port link-type access
[swb-Ethernet0/0/4]port default vlan 5
[swb-Ethernet0/0/4]q
[swb]interface Eth0/0/5
[swb-Ethernet0/0/5]port link-type access
[swb-Ethernet0/0/5]port default vlan 5
[swb-Ethernet0/0/5]q
[swb]interface Eth0/0/10
[swb-Ethernet0/0/10]port link-type trunk
[swb-Ethernet0/0/10]port trunk allow-pass vlan all
[swb-Ethernet0/0/10]q
[swb]
配置完成
四、测试通信