一、實驗目的:實現單交換機划分VLAN,使PC1主機和PC2主機不能通訊
二、拓撲圖
三、實驗步驟
最開始兩台主機都輸入的端口f0/1和f0/2都屬於vlan 1 可以相互通訊(如下圖)
現在需要讓PC1和PC2分別屬於2個不同的vlan,並且不互通,具體步驟如下
Switch>enable --進入特權模式
Switch#config terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname S1 --修改交換機主機名為S1
S1(config)#vtp domain test --創建一個vtp域
Changing VTP domain name from NULL to test
S1(config)#vtp mode server --設置當前vtp身份為server
Device mode already VTP SERVER.
S1(config)#vlan 2 --創建並進入vlan 2端口
S1(config-vlan)#name V2 --命名vlan 2名字為V2
S1(config-vlan)#vlan 3 --創建並進入vlan3端口
S1(config-vlan)#name V3 --命名為V3
S1(config-vlan)#interface f0/1 --進入f0/1端口
S1(config-if)#switchport mode access --將端口模式改為access模式
S1(config-if)#switchport access vlan 2 --將端口划分到vlan 2
S1(config-if)#interface f0/2 --進入到f0/2端口
S1(config-if)#switchport mode access --將端口模式改為access模式
S1(config-if)#switchport access vlan 3 --將端口划分到 vlan 3
S1(config-if)#end --發回特權模式
S1#copy running-config startup-config --保存配置
Destination filename [startup-config]?
%SYS-5-CONFIG_I: Configured from console by console
Building configuration...
[OK] --成功保存
四、驗證PC1和PC2是否不互通,f0/1和f0/2是否分別划分到vlan 2和vlan 3里
(1)驗證vlan
(2)驗證是否相互不能ping通
PC1:
PC2