【Packet Tracer】VLAN配置实例

1.VLAN是什么

VLAN就是虚拟局域网

 (1)VLAN的好处

  • 控制广播域
  • 增强网络的安全性
  • 可以简化管理

2.配置实例

第一步:分别配置好四台主机的ip地址和子网掩码

 

 

 

 

 

 

  第二步:配置sw1的vlan

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname sw1
sw1(config)#vlan 10
sw1(config-vlan)#vlan 20
sw1(config-if)#int f0/1
sw1(config-if)#sw ac vlan 10
sw1(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up
sw1(config-if)#int f0/2
sw1(config-if)#sw ac vlan 20
sw1(config-if)#exit
sw1(config)#exit
sw1#sh vlan

 

 

配置sw2的vlan

Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname sw2
sw2(config)#vlan 10
sw2(config-vlan)#vlan 20
sw2(config-vlan)#int f0/1
sw2(config-if)#sw ac vlan 10
sw2(config-if)#int f0/2
sw2(config-if)#sw ac vlan 20
sw2(config-if)#^Z
Switch# %SYS-5-CONFIG_I: Configured from console by console Switch#sh vlan

 第三步:分别配置好sw1和sw2的f0/24端口的trunk模式,

sw1#en
sw1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
sw1(config)#int f0/24
sw1(config-if)#sw mo tr
sw1(config-if)#^Z
sw1#
%SYS-5-CONFIG_I: Configured from console by console
Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname sw2
sw2(config)#int f0/24
sw2(config-if)#sw mo tr
sw2(config-if)#^Z
sw2#
%SYS-5-CONFIG_I: Configured from console by console
sw2#

第四步:测试

此时192.168.10.10的主机无法ping通192.168.10.20的主机,因为它们不属于同一个VLAN。

 

  此时192.168.10.10的主机可以ping通192.168.10.30的主机,因为它们属于同一个VLAN。

 

  同一个vlan的主机可以通信,不同一个vlan的主机不可以通信。

如何查看交换机的端口是否启用了中继配置(trunk模式):show int trunk

 

posted @ 2022-12-27 08:58  YorkShare  阅读(403)  评论(0编辑  收藏  举报