一、實驗要求:實現跨交換地划分vlan的配置任務,使同一vlan下的主機能相互通訊
二、拓撲圖如下;

三、具體實驗步驟:
S1交換機配置:
S1>enable --進入特權模式
S1#config terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
S1(config)#hostname S1 --修改交換機名為S1
S1(config)#vlan 2 --創建並進入vlan 2端口,開啟
S1(config-vlan)#vlan 3 --創建並進入vlan 3 端口,開啟
S1(config-vlan)#exit --返回上一級
S1(config)#interface f0/1 進入f0/1端口
S1(config-if)#switchport mode access --端口模式改為access模式
S1(config-if)#switchport access vlan 2 --將f0/1端口划入到vlan 2 下
S1(config-if)#interface f0/2 --進入f0/2端口
S1(config-if)#switchport mode access --端口模式改為access模式
S1(config-if)#switchport access vlan 3 --將f0/2端口划入到vlan 3 下
S1(config-if)#interface f0/3 --進入f0/3端口
S1(config-if)#switchport mode trunk --將f0/3改為trunk模式,這是實現跨交換機vlan通訊最重要的一部
S1(config-if)#end --返回到特權模式
S1#copy running-config startup-config --保存配置
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up
%SYS-5-CONFIG_I: Configured from console by console
Destination filename [startup-config]?
Building configuration...
[OK] --保存成功
S2交換機配置:
Switch>enable --進入特權模式
Switch#config terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S2 --修改交換機名為S2
S2(config)#vlan 2 --創建並進入vlan 2端口,開啟
S2(config-vlan)#vlan 3 --創建並進入vlan 3端口,開啟
S2(config-vlan)#exit --返回上一級
S2(config)#interface f0/1 --進入f0/1端口
S2(config-if)#switchport mode access --將端口模式改為access模式
S2(config-if)#switchport access vlan 2 --將f0/1端口划入到vlan 2下
S2(config-if)#interface f0/2 --進入f0/2端口
S2(config-if)#switchport mode access --將端口模式改為access模式
S2(config-if)#switchport access vlan 3 --將f0/2端口划入到vlan 2下
S2(config-if)#interface f0/3 --進入f0/3端口
S2(config-if)#switchport mode trunk --將端口模式改為trunk模式,這是跨交換機vlan通訊最重要的一部
S2(config-if)#end --返回特權模式
S2#copy running-config startup-config --保存配置
%SYS-5-CONFIG_I: Configured from console by console
Destination filename [startup-config]?
Building configuration...
[OK] --保存成功
四、驗證同vlan下的兩台主機是否互通,
vlan 2下的PC1和PC3

vlan 3下的PC2和PC4

