![](https://img-blog.csdnimg.cn/img_convert/7b820097273655579fd15822b96b5a56.png)
Preparation
One switch (2960-24TT)
Four PCs
1. Configure the IP address of each PC
![](https://img-blog.csdnimg.cn/img_convert/270c614591b98ebeb733cc5673c561ed.png)
2. Create VLAN and assign ports
Step 1: Create vlan 10
Switch(config)#vlan 10
Switch(config-vlan)#
Step 2: Name it test10.
Switch(config-vlan)#name test10
Switch(config-vlan)#exit
Step 3: Create vlan 20 and name it test20.
Switch(config)#vlan 20
Switch(config-vlan)#name test20
Switch(config-vlan)#exit
Step 4: Assign the port to vlan10.
Switch(config)#int f0/1
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 10
Switch(config-if)#int range f0/1-10
Switch(config-if-range)#switch mode access
Switch(config-if-range)#switch access vlan 10
Switch(config-if-range)#exit
Step 5: Assign the port to vlan20.
Switch(config)#int f0/11
Switch(config-if)#switch mode access
Switch(config-if)#switch access vlan 20
Switch(config-if)#int range f0/11-20
Switch(config-if-range)#switch mode access
Switch(config-if-range)#switch access vlan 20
Switch(config-if-range)#exit
Step 6: Check vlan configuration
![](https://img-blog.csdnimg.cn/img_convert/5bf3313435a17ed21c5beb5556973767.png)
3. Test
Click "PC0" in the Packer tracer, click "run" under the "Desktop" tab in the pop-up window, enter ping 192.168.1.12 and ping 192.168.1.21, the test results are shown in the figure below, where PC0 and PC1 They are in the same VLAN and can be pinged successfully; PC0 and PC2 are not in the same VLAN, so they cannot be pinged successfully.
![](https://img-blog.csdnimg.cn/img_convert/c17f5a8a08fd64f5cb9e0b4d28c7ec5f.png)
![](https://img-blog.csdnimg.cn/img_convert/208ce856f454c182c8290ef0a3586501.png)