实验二(1)VLAN 基础实验
【实验目的】
理解同一交换机VLAN 的特点。 【背景描述】
假设某企业有两个主要部门:销售部和技术部,但为了数据安全起见,销售部和技术部需要进行相互隔离,现要在交换机上做适当配置来实现这一目标。 【实现功能】
使在同一VLAN 里的计算机系统能进行相互通信,而在不同VLAN 里的计算机系统不能进行相互通信。 【实验设备】
S3760EG(1台)、主机(3 台)、直连线(3 条) 【实验拓扑】
实验时,按照拓扑图进行网络的连接,注意主机和交换机连接的端口。
【实验步骤】
步骤一、在交换机SwitchA 上创建Vlan 10,并将F0/10 和F0/11端口划分到Vlan 10 中。
SwitchA#configure terminal SwitchA(config)# vlan 10 SwitchA(config-vlan)# name sales
- 16 -
PC1:192.168.10.10 VLAN 10 F0/10 F0/24
VLAN 20 PC2:192.168.20.10 PC3:192.168.10.30 SwitchA
F0/11
VLAN 10
SwitchA(config-vlan)#exit
SwitchA(config)#interface range fastethernet0/10-11 SwitchA(config-if)#switchport access vlan 10
步骤二、在交换机switchA 上创建Vlan 20,并将F0/24 端口划分到Vlan 20 中。 SwitchA(config)# vlan 20
SwitchA(config-vlan)# name technical SwitchA(config-vlan)#exit
SwitchA(config)#interface fastethernet0/24 SwitchA(config-if)#switchport access vlan 20
步骤三、按照拓扑图配置PC1,PC2,PC3的IP地址,验证PC1,PC2,PC3之间互相通信情况。 【实验结论】
- 17 -
实验二(2)跨交换机实现VLAN
【实验目的】
理解VLAN如何跨交换机实现。
【背景描述】
假设某企业有2个主要部门:销售部和技术部,其中销售部门的个人计算机
系统分散连接在2台交换机上,他们之间需要相互进行通信,但为了数据安全起见,销售部和技术部需要进行相互隔离,现要在交换机上做适当配置来实现这一目标。 【实现功能】
使在同一VLAN里的计算机系统能跨交换机进行相互通信,而在不同VLAN里的计算机系统不能进行相互通信。 【实验拓扑】
PC1:192.168.10.10 VLAN 10 F0/5 F0/15
VLAN 20 PC2:192.168.20.10 PC3:192.168.10.30 SwitchA SwitchB
F0/24 F0/24
F0/5
VLAN 10
【实验步骤】
步骤一、在交换机SwitchA上创建VLAN 10,并将0/5端口划分到VLAN 10中。
SwitchA # configure terminal !进入全局配置模式。 SwitchA(config) # vlan 10 !创建vlan 10。
SwitchA(config-vlan) # name sales !将Vlan 10命名为sales。 SwitchA(config-vlan) # exit
SwitchA(config) # interface fastethernet 0/5 !进入接口配置模式。
SwitchA(config-if) # switchport access vlan 10 !将0/5端口划分到Vlan 10。
- 18 -
验证测试:验证已创建了Vlan 10,并将0/5端口已划分到Vlan 10 中。
SwitchA # show vlan id 10
VLAN Name Status Ports 10 sales active Fa0/5
步骤二、在交换机SwitchA 上创建Vlan 20,并将0/15端口划分到Vlan 20中。
SwitchA(config) # vlan 20 !创建vlan 20。
SwitchA(config-vlan) # name technical !将Vlan 20命名为techniacal。 SwitchA(config-vlan) # exit
Switch(config) # interface fastethernet 0/15 !进入接口配置模式。
Switch(config-if) # switchport access vlan 20 !将0/5端口划分到Vlan 20。
验证测试:验证已创建了Vlan 20,并将0/15端口已划分到Vlan 20 中。
SwitchA # show vlan id 20
VLAN Name Status Ports 20 technical active Fa0/15
步骤三、在交换机SwitchA上将SwitchB相连的端口(假设为0/24端口)定义为tag vlan模式
SwitchA(config)#interface fastethernet 0/24 !进入接口配置模式。
SwitchA(config-if)#switchport mode trunk !将fastethernet 0/24端口设为tag vlan模式
验证测试:验证fastethernet 0/24端口已被设置为tag vlan模式
SwitchA#show interfaces fastethernet 0/24 switchport
interface Switchport Mode Access Native Protected Vlan Lists Fa0/24 Enable Trunk 1 1 Disabled All
步骤四、在交换机SwitchB上创建Vlan10,并将0/5端口划分到Vlan10中。
SwitchB#configure terminal !进入全局配置模式 SwitchB(config)#vlan 10 !创建Vlan 10
SwitchB(config-vlan)#name sales !将Vlan 10命名为sales SwitchB(config-vlan)#exit
SwitchB(config)#interface fastethernet 0/5 !进入接口配置模式
SwitchB(config-if)#switchport access vlan 10 !将0/5端口划分到Vlan 10
验证测试:验证已在SwitchB上创建了Vlan10,并将0/5端口已划分到Vlan10中
SwitchB#show vlan id 10
VLAN Name Status Ports
- 19 -
10 sales active Fa0/5
步骤五、在交换机SwitchB上将与SwitchA相连的端口(假设为0/24端口)定义为tag vlan模式
SwitchB(config)#interface fastethernet 0/24 !进入接口配置模式
SwitchB(config-if)#switchport mode trunk !将fastethernet 0/24端口设为tag vlan模式
验证测试:验证fastethernet 0/24端口已被设置为tag vlan模式
SwitchB#show interfaces fastethernet 0/24 switchport
Interface Switchport Mode Access Native Protected Vlan lists Fa0/24 Enabled Trunk 1 1 Disabled All
步骤六、验证PC1与PC3能互相通信,但PC2与PC3不能互相通信。
C:\\>ping 192.168.10.30 !在PC1的命令行方式下验证能Ping通PC3 Pinging 192.168.10.30 with 32 bytes of data:
Reply from 192.168.10.30:bytes=32 time<10ms TTL=128 Reply from 192.168.10.30:bytes=32 time<10ms TTL=128 Reply from 192.168.10.30:bytes=32 time<10ms TTL=128 Reply from 192.168.10.30:bytes=32 time<10ms TTL=128
Ping statistics for 192.168.10.30:
Packets: Sent=4, Received=4, Lost=0(0% loss), Approximate round trip times in milli-secends: Minimum=0ms,Maximum=0ms,Average=0ms
C:\\>ping 192.168.10.30 !在PC2的命令行方式下验证不能Ping通PC3
Request timed out. Request timed out. Request timed out. Request timed out.
Ping statistics for 192.168.10.30:
Packets: Sent=4, Received=0, Lost=4(100% loss), Approximate round trip times in milli-secends: Minimum=0ms,Maximum=0ms,Average=0ms
【注意事项】
两台交换机之间相连的端口应该设置为tag vlan模式 【参考配置】
SwitchA#show running-config !显示交换机SwitchA的全部配置
- 20 -