网络拓扑
其中SW-1交换机和SW-2交换机接口规划为:
Ethernet 0/0/1 VLAN ID为10,接口类型access
Ethernet 0/0/2 VLAN ID为10,接口类型access
Ethernet 0/0/5 VLAN ID为20,接口类型access
Ethernet 0/0/6 VLAN ID为20,接口类型access
GE 0/0/1 VLAN ID为1、10、20,接口类型为trunk
Host-1 ip为192.168.64.11/24
Host-2 ip为192.168.64.12/24
Host-3 ip为192.168.64.21/24
Host-4 ip为192.168.64.22/24
Host-5 ip为192.168.64.13/24
Host-6 ip为192.168.64.14/24
Host-7 ip为192.168.64.23/24
Host-8 ip为192.168.64.24/24
网关都为192.168.64.254
配置交换机SW-1
<Huawei>sys
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW-1
[SW-1]undo info-center enable
Info: Information center is disabled.
[SW-1]interface Ethernet 0/0/1
[SW-1-Ethernet0/0/1]port link-type access
[SW-1-Ethernet0/0/1]port default vlan 10
Error: The VLAN does not exist.
[SW-1-Ethernet0/0/1]quit
[SW-1]vlan batch 10 20 //创建VLAN10和VLAN20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-1]interface Ethernet 0/0/1
[SW-1-Ethernet0/0/1]port default vlan 10 //将接口划入VLAN10
[SW-1-Ethernet0/0/1]quit
[SW-1]interface Ethernet 0/0/2
[SW-1-Ethernet0/0/2]port link-type access //设置接口类型为access
[SW-1-Ethernet0/0/2]port default vlan 10 //将接口划入VLAN10
[SW-1-Ethernet0/0/2]quit
[SW-1]interface Ethernet 0/0/5
[SW-1-Ethernet0/0/5]port link-type access
[SW-1-Ethernet0/0/5]port default vlan 20
[SW-1-Ethernet0/0/5]quit
[SW-1]interface Ethernet 0/0/6
[SW-1-Ethernet0/0/6]port link-type access
[SW-1-Ethernet0/0/6]port default vlan 20
[SW-1-Ethernet0/0/6]quit
[SW-1]interface GigabitEthernet 0/0/1
[SW-1-GigabitEthernet0/0/1]port link-type trunk //设置接口类型为trunk
[SW-1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 //运行VLAN10和VLAN20的数据帧通过
[SW-1-GigabitEthernet0/0/1]quit
查看vlan信息。
配置SW-2,内容同SW-1。
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname SW-2
[SW-2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW-2]interface Ethernet 0/0/1
[SW-2-Ethernet0/0/1]port link-type access
[SW-2-Ethernet0/0/1]port default vlan 10
[SW-2-Ethernet0/0/1]quit
[SW-2]interface Ethernet 0/0/2
[SW-2-Ethernet0/0/2]port link-type access
[SW-2-Ethernet0/0/2]port default vlan 10
[SW-2-Ethernet0/0/2]quit
[SW-2]interface Ethernet 0/0/5
[SW-2-Ethernet0/0/5]port link-type access
[SW-2-Ethernet0/0/5]port default vlan 20
[SW-2-Ethernet0/0/5]quit
[SW-2]interface Ethernet 0/0/6
[SW-2-Ethernet0/0/6]port link-type access
[SW-2-Ethernet0/0/6]port default vlan 20
[SW-2-Ethernet0/0/6]quit
[SW-2]interface GigabitEthernet 0/0/1
[SW-2-GigabitEthernet0/0/1]port link-type trunk
[SW-2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[SW-2-GigabitEthernet0/0/1]quit
测试同交换机下,同一VLAN主机可以通信。
不同交换机下,同一VLAN主机也可以通信。
不同VLAN主机则不能通信。