划分VLAN能有效地控制网络广播风暴,提高网络的安全可靠性,是有效的网络监控、数据流量控制的手段,还能实现不同地理位置的部门间的局域网通信,有效地节省构建网络时所需网络设备的费用。
1.配置要求

2.交换机VLAN的划分的拓扑结构
3.任务实施
交换机接口模式:
access 普通模式用于连接计算机
trunk 中继模式用于连接交换机
单一创建 vlan 10 vlan 20 ......
批量创建 vlan batch 10 20 30 ......
- 创建vlan
<Huawei>sys 进入系统视图,键入Ctrl+Z退回到用户视图。 [Huawei]sys SWA 修改主机名 [SWA]vlan 10 单一创建vlan [SWA-vlan10]description CAIWUBU 命名vlan [SWA-vlan10]q [SWA]vlan 20 [SWA-vlan20]description JISHUBU [SWA-vlan20]q
- 查看vlan的相关信息
[SWA]display vlan 查看Vlan The total number of vlans is : 3 -------------------------------------------------------------------------------- U: Up; D: Down; TG: Tagged; UT: Untagged; MP: Vlan-mapping; ST: Vlan-stacking; #: ProtocolTransparent-vlan; *: Management-vlan; -------------------------------------------------------------------------------- VID Type Ports -------------------------------------------------------------------------------- 1 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(D) Eth0/0/4(D) Eth0/0/5(U) Eth0/0/6(U) Eth0/0/7(D) Eth0/0/8(D) Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D) Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D) Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D) Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D) 10 common 20 common VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable CAIWUBU 20 enable default enable disable JISHUBU
- 配置Access接口划分到VLAN接口
[SWA]interface Ethernet 0/0/1 进入e 0/0/1 [SWA-Ethernet0/0/1]port link-type access 将接口设置为Access模式 [SWA-Ethernet0/0/1]port default vlan 10 将接口划分到Vlan10 [SWA-Ethernet0/0/1]q [SWA][SWA]int e 0/0/2 进入e 0/0/2 [SWA-Ethernet0/0/2]p l a 将接口设置为Access模式 [SWA-Ethernet0/0/2]p d v 10 将接口划分到Vlan10 [SWA-Ethernet0/0/2]q [SWA]int e 0/0/3 [SWA-Ethernet0/0/3]p l a [SWA-Ethernet0/0/3]p d v 10 [SWA-Ethernet0/0/3]q [SWA]int e 0/0/4 [SWA-Ethernet0/0/4]p l a [SWA-Ethernet0/0/4]p d v 10 [SWA-Ethernet0/0/4]q 把所有接口统一划分到vlan20 [SWA]port-group 1 创捷接口组1 [SWA-port-group-1]group-member e 0/0/5 to e 0/0/8 将e 0/0/5到e 0/0/8 划分到接口组1 [SWA-port-group-1]p l a [SWA-Ethernet0/0/5]p l a [SWA-Ethernet0/0/6]p l a [SWA-Ethernet0/0/7]p l a [SWA-Ethernet0/0/8]p l a [SWA-port-group-1]p d v 20 [SWA-port-group-1]p d v 20 [SWA-Ethernet0/0/5]p d v 20 [SWA-Ethernet0/0/6]p d v 20 [SWA-Ethernet0/0/7]p d v 20 [SWA-Ethernet0/0/8]p d v 20
4.查看vlan的相关信息
[SWA]dis vl
The total number of vlans is : 3
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------
VID Type Ports
--------------------------------------------------------------------------------
1 common UT:Eth0/0/9(D) Eth0/0/10(D) Eth0/0/11(D) Eth0/0/12(D)
Eth0/0/13(D) Eth0/0/14(D) Eth0/0/15(D) Eth0/0/16(D)
Eth0/0/17(D) Eth0/0/18(D) Eth0/0/19(D) Eth0/0/20(D)
Eth0/0/21(D) Eth0/0/22(D) GE0/0/1(D) GE0/0/2(D)
10 common UT:Eth0/0/1(U) Eth0/0/2(U) Eth0/0/3(D) Eth0/0/4(D)
20 common UT:Eth0/0/5(U) Eth0/0/6(U) Eth0/0/7(D) Eth0/0/8(D)
VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
1 enable default enable disable VLAN 0001
10 enable default enable disable CAIWUBU
20 enable default enable disable JISHUBU
[SWA]
4.任务验收
1.确认计算机已经正确连接到对应
VLAN
上的接口,如
PC1
、
PC2
接入的是
VLAN10
,只能接入交换机的
Ethernet 0/0/1
~
0/0/4
的接口上。
2.使用相同VLAN
的计算机进行
Ping
测试和不同
VLAN
间的计算机进行
ping
测试。下面分别用
PC1
和
PC2
、
PC1
和
PC3
进行
Ping
测试
。
pc1 ping pc2 相同vlan可以通信
PC>ping 192.168.10.2
Ping 192.168.10.2: 32 data bytes, Press Ctrl_C to break
From 192.168.10.2: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.10.2: bytes=32 seq=2 ttl=128 time=47 ms
From 192.168.10.2: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.10.2: bytes=32 seq=4 ttl=128 time=46 ms
From 192.168.10.2: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.10.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 46/50/63 ms
pc1 ping pc3 不同vlan不能通信
PC>ping 192.168.10.3
Ping 192.168.10.3: 32 data bytes, Press Ctrl_C to break
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
From 192.168.10.1: Destination host unreachable
--- 192.168.10.3 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss

5.任务总结
在一个交换机中,划分了VLAN后,所有计算机设置了同一个网段的IP地址,只有相同VLAN的PC间可以相互通信,不同VLAN的PC间不能通信。通过VLAN的划分,就可以实现广播域的控制。