跨交换机实现VLAN实验

一、实验要求:使在同一 VLAN 里的计算机能跨交换机进行相互通信,而在不同 VLAN 里的计算机系统不能进行相互通信。

二、拓扑图如下:

跨交换机实现VLAN实验_第1张图片

三、具体实验步骤:

sw0交换机配置:

switch0>enable    --进入特权模式
switch0#config t    --进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
switch0(config)#hostname sw1    --修改交换机名为sw1
sw0(config)#vlan 2    --创建并进入vlan 2端口
sw0(config-vlan)#vlan 3    --创建并进入vlan 3 端口
sw0(config-vlan)#exit    --返回上一级
sw0(config)#interface f0/11    --进入f0/11端口
sw0(config-if)#switchport mode access    --端口模式改为access模式
sw0(config-if)#switchport access vlan 2    --将f0/11端口划入到vlan 2 下
sw0(config-if)#interface f0/12   --进入f0/12端口
sw0(config-if)#switchport mode access     --端口模式改为access模式
sw0(config-if)#switchport access vlan 3    --将f0/12端口划入到vlan 3 下
sw0(config-if)#interface f0/1    --进入f0/1端口
sw0(config-if)#switchport mode trunk  --将f0/1改为trunk模式,这是实现跨交换机vlan通讯最重要的一部

S1(config-if)#end  --返回到特权模式
 

sw1交换机配置:

Switch1>enable    --进入特权模式
Switch1#config terminal    --进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw1    --修改交换机名为sw1
sw1(config)#vlan 2    --创建并进入vlan 2端口
sw1(config-vlan)#vlan 3    --创建并进入vlan 3端口
sw1(config-vlan)#exit    --返回上一级
sw1(config)#interface f0/13    --进入f0/13端口
sw1(config-if)#switchport mode access    --将端口模式改为access模式
sw1(config-if)#switchport access vlan 2    --将f0/13端口划入到vlan 2下
sw1(config-if)#interface f0/14   --进入f0/14端口
sw1(config-if)#switchport mode access    --将端口模式改为access模式
sw1(config-if)#switchport access vlan 2    --将f0/2端口划入到vlan 2下

sw1(config-if)#interface f0/15   --进入f0/15端口
sw1(config-if)#switchport mode access    --将端口模式改为access模式
sw1(config-if)#switchport access vlan 3    --将f0/2端口划入到vlan 3下
sw1(config-if)#interface f0/1    --进入f0/1端口
sw1(config-if)#switchport mode trunk    --将端口模式改为trunk模式,这是跨交换机vlan通讯最重要的一部
sw1(config-if)#end    --返回特权模式

 

四、验证同vlan下的两台主机是否互通:

vlan 2下的PC11和PC13:

跨交换机实现VLAN实验_第2张图片

VLAN3下的PC12和PC15:

跨交换机实现VLAN实验_第3张图片

不同VLAN下的PC11和PC15则无法连通:

跨交换机实现VLAN实验_第4张图片

 

你可能感兴趣的:(计算机网络,交换机)